From da38b0d69bb719312cc10ad537e4963a58f74dae Mon Sep 17 00:00:00 2001 From: Kyle White Date: Sun, 21 Jan 2018 02:22:26 -0500 Subject: [PATCH] Added Ingress option w/ ssl for secure deploys (#3304) * Added Ingress option w/ ssl for secure deploys Moved configmap to values to allow for custom config map passing Added initialdelay to allow pod to come up before health checks Added dirty check to restart pods on configmap change Updated notes with ingress docs * Update default version to 2.7.3 Add https to notes. * Update appVersion field --- stable/verdaccio/Chart.yaml | 4 +- stable/verdaccio/templates/NOTES.txt | 11 +++- stable/verdaccio/templates/configmap.yaml | 58 +------------------ stable/verdaccio/templates/deployment.yaml | 5 +- stable/verdaccio/templates/ingress.yaml | 32 +++++++++++ stable/verdaccio/values.yaml | 66 +++++++++++++++++++++- 6 files changed, 114 insertions(+), 62 deletions(-) create mode 100644 stable/verdaccio/templates/ingress.yaml diff --git a/stable/verdaccio/Chart.yaml b/stable/verdaccio/Chart.yaml index 454eac537f..acdda82bab 100644 --- a/stable/verdaccio/Chart.yaml +++ b/stable/verdaccio/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 description: A lightweight private npm proxy registry (sinopia fork) name: verdaccio -version: 0.1.3 -appVersion: 2.7.1 +version: 0.2.0 +appVersion: 2.7.3 icon: https://raw.githubusercontent.com/verdaccio/verdaccio/master/assets/bitmap/logo/logo-twitter.png sources: - http://www.verdaccio.org diff --git a/stable/verdaccio/templates/NOTES.txt b/stable/verdaccio/templates/NOTES.txt index 04928414a4..254ccba755 100644 --- a/stable/verdaccio/templates/NOTES.txt +++ b/stable/verdaccio/templates/NOTES.txt @@ -1,5 +1,14 @@ 1. Get the application URL by running these commands: -{{- if contains "NodePort" .Values.service.type }} +{{- $tls := .Values.ingress.tls }} +{{- if .Values.ingress.enabled }} + {{- range $host := .Values.ingress.hosts }} + {{- if $tls }} + https://{{ $host }} + {{- else }} + http://{{ $host }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "verdaccio.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT diff --git a/stable/verdaccio/templates/configmap.yaml b/stable/verdaccio/templates/configmap.yaml index 70035506e0..b429a2a293 100644 --- a/stable/verdaccio/templates/configmap.yaml +++ b/stable/verdaccio/templates/configmap.yaml @@ -1,4 +1,3 @@ -{{- if not .Values.customConfigMap }} apiVersion: v1 kind: ConfigMap metadata: @@ -9,58 +8,5 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - config.yaml: | - # - # This is the config file used for the docker images. - # It allows all users to do anything, so don't use it on production systems. - # - # Do not configure host and port under `listen` in this file - # as it will be ignored when using docker. - # see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration - # - # Look here for more config file examples: - # https://github.com/verdaccio/verdaccio/tree/master/conf - # - - # path to a directory with all packages - storage: /verdaccio/storage/data - - auth: - htpasswd: - file: /verdaccio/storage/htpasswd - # Maximum amount of users allowed to register, defaults to "+infinity". - # You can set this to -1 to disable registration. - #max_users: 1000 - - # a list of other known repositories we can talk to - uplinks: - npmjs: - url: https://registry.npmjs.org/ - - packages: - '@*/*': - # scoped packages - access: $all - publish: $authenticated - proxy: npmjs - - '**': - # allow all users (including non-authenticated users) to read and - # publish all packages - # - # you can specify usernames/groupnames (depending on your auth plugin) - # and three keywords: "$all", "$anonymous", "$authenticated" - access: $all - - # allow all known users to publish packages - # (anyone can register by default, remember?) - publish: $authenticated - - # if package is not available locally, proxy requests to 'npmjs' registry - proxy: npmjs - - # log settings - logs: - - {type: stdout, format: pretty, level: http} - #- {type: file, path: verdaccio.log, level: info} -{{- end }} + config.yaml: |- +{{ .Values.configMap | indent 4 }} diff --git a/stable/verdaccio/templates/deployment.yaml b/stable/verdaccio/templates/deployment.yaml index c4257c11ca..47b97b8aac 100644 --- a/stable/verdaccio/templates/deployment.yaml +++ b/stable/verdaccio/templates/deployment.yaml @@ -13,8 +13,9 @@ spec: type: Recreate template: metadata: - {{- if .Values.podAnnotations }} annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- if .Values.podAnnotations }} {{ toYaml .Values.podAnnotations | indent 8 }} {{- end }} labels: @@ -31,10 +32,12 @@ spec: httpGet: path: / port: 4873 + initialDelaySeconds: 5 readinessProbe: httpGet: path: / port: 4873 + initialDelaySeconds: 5 resources: {{ toYaml .Values.resources | indent 12 }} volumeMounts: diff --git a/stable/verdaccio/templates/ingress.yaml b/stable/verdaccio/templates/ingress.yaml new file mode 100644 index 0000000000..6ab36a6a6b --- /dev/null +++ b/stable/verdaccio/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled }} +{{- $serviceName := include "verdaccio.fullname" . -}} +{{- $servicePort := .Values.service.port -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "verdaccio.fullname" . }} + labels: + app: {{ template "verdaccio.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end}} diff --git a/stable/verdaccio/values.yaml b/stable/verdaccio/values.yaml index 71fa80e06f..b2fdc72dd1 100644 --- a/stable/verdaccio/values.yaml +++ b/stable/verdaccio/values.yaml @@ -1,6 +1,6 @@ image: repository: verdaccio/verdaccio - tag: 2.7.1 + tag: 2.7.3 pullPolicy: IfNotPresent service: @@ -33,8 +33,70 @@ resources: {} # cpu: 100m # memory: 512Mi -customConfigMap: false +ingress: + enabled: false +# hosts: +# - npm.blah.com +# annotations: +# kubernetes.io/ingress.class: nginx +# tls: +# - secretName: secret +# hosts: +# - npm.blah.com +configMap: | + # This is the config file used for the docker images. + # It allows all users to do anything, so don't use it on production systems. + # + # Do not configure host and port under `listen` in this file + # as it will be ignored when using docker. + # see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration + # + # Look here for more config file examples: + # https://github.com/verdaccio/verdaccio/tree/master/conf + # + + # path to a directory with all packages + storage: /verdaccio/storage/data + + auth: + htpasswd: + file: /verdaccio/storage/htpasswd + # Maximum amount of users allowed to register, defaults to "+infinity". + # You can set this to -1 to disable registration. + #max_users: 1000 + + # a list of other known repositories we can talk to + uplinks: + npmjs: + url: https://registry.npmjs.org/ + + packages: + '@*/*': + # scoped packages + access: $all + publish: $authenticated + proxy: npmjs + + '**': + # allow all users (including non-authenticated users) to read and + # publish all packages + # + # you can specify usernames/groupnames (depending on your auth plugin) + # and three keywords: "$all", "$anonymous", "$authenticated" + access: $all + + # allow all known users to publish packages + # (anyone can register by default, remember?) + publish: $authenticated + + # if package is not available locally, proxy requests to 'npmjs' registry + proxy: npmjs + + # log settings + logs: + - {type: stdout, format: pretty, level: http} + #- {type: file, path: verdaccio.log, level: info} persistence: enabled: true ## A manually managed Persistent Volume and Claim