diff --git a/charts/invenio/templates/_helpers.tpl b/charts/invenio/templates/_helpers.tpl index 96dcc8a..d4fe007 100644 --- a/charts/invenio/templates/_helpers.tpl +++ b/charts/invenio/templates/_helpers.tpl @@ -5,6 +5,24 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name, the release name will be used as a full name. +*/}} +{{- define "invenio.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + {{/* Create chart name and version as used by the chart label. */}} @@ -283,7 +301,7 @@ Get the sentry secret name {{- else if .Values.invenio.sentry.secret_name -}} {{- print .Values.invenio.sentry.secret_name -}} {{- else -}} - {{- "sentry-secrets" -}} + {{- printf "%s-%s" (include "invenio.fullname" .) "sentry" -}} {{- end -}} {{- end -}} @@ -340,6 +358,6 @@ Get the invenio general secret name {{- if .Values.invenio.existingSecret -}} {{- tpl .Values.invenio.existingSecret . -}} {{- else -}} - {{- "invenio-secrets" -}} + {{- printf "%s-%s" (include "invenio.fullname" .) "secrets" -}} {{- end -}} {{- end -}} diff --git a/charts/invenio/templates/ingress.yaml b/charts/invenio/templates/ingress.yaml index 70ddcf4..3c93f30 100644 --- a/charts/invenio/templates/ingress.yaml +++ b/charts/invenio/templates/ingress.yaml @@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: invenio-ingress + name: {{ include "invenio.fullname" . }} {{- if .Values.ingress.annotations }} annotations: {{- .Values.ingress.annotations | toYaml | nindent 4}} diff --git a/charts/invenio/templates/install-init-job.yaml b/charts/invenio/templates/install-init-job.yaml index 6938d53..631c39f 100644 --- a/charts/invenio/templates/install-init-job.yaml +++ b/charts/invenio/templates/install-init-job.yaml @@ -2,7 +2,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: install-init + name: {{ include "invenio.fullname" . }}-install-init labels: {{- include "invenio.labels" . | nindent 4 }} app: install-init @@ -32,7 +32,7 @@ spec: ] envFrom: - configMapRef: - name: invenio-config + name: {{ include "invenio.fullname" . }}-config - secretKeyRef: name: {{ include "invenio.secretName" . }} env: @@ -59,7 +59,7 @@ spec: volumes: - name: vocabularies configMap: - name: "invenio-vocabularies" + name: "{{ include "invenio.fullname" . }}-vocabularies" {{- end }} {{- if .Values.web.imagePullSecret }} imagePullSecrets: diff --git a/charts/invenio/templates/invenio-configmap.yaml b/charts/invenio/templates/invenio-configmap.yaml index 52c48e2..70d1973 100644 --- a/charts/invenio/templates/invenio-configmap.yaml +++ b/charts/invenio/templates/invenio-configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: invenio-config + name: {{ include "invenio.fullname" . }}-config labels: {{- include "invenio.labels" . | nindent 4 }} data: diff --git a/charts/invenio/templates/nginx-configmap.yaml b/charts/invenio/templates/nginx-configmap.yaml index 7154b00..52eba50 100644 --- a/charts/invenio/templates/nginx-configmap.yaml +++ b/charts/invenio/templates/nginx-configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: nginx-config + name: {{ include "invenio.fullname" . }}-nginx-config labels: {{- include "invenio.labels" . | nindent 4 }} data: diff --git a/charts/invenio/templates/secret.yaml b/charts/invenio/templates/secret.yaml index 93604fa..4206989 100644 --- a/charts/invenio/templates/secret.yaml +++ b/charts/invenio/templates/secret.yaml @@ -4,9 +4,8 @@ apiVersion: v1 kind: Secret type: Opaque metadata: - name: invenio-secrets + name: {{ include "invenio.secretName" . }} labels: - app: invenio-secrets {{- include "invenio.labels" . | nindent 4 }} annotations: helm.sh/resource-policy: keep diff --git a/charts/invenio/templates/sentry-secret.yaml b/charts/invenio/templates/sentry-secret.yaml index f4b4705..c461ae3 100644 --- a/charts/invenio/templates/sentry-secret.yaml +++ b/charts/invenio/templates/sentry-secret.yaml @@ -5,7 +5,7 @@ apiVersion: v1 kind: Secret type: Opaque metadata: - name: sentry-secrets + name: {{ include "invenio.sentrySecretName" . }} labels: {{- include "invenio.labels" . | nindent 4 }} app: sentry-secrets diff --git a/charts/invenio/templates/uwsgi-configmap.yaml b/charts/invenio/templates/uwsgi-configmap.yaml index 636c14d..7b82b27 100644 --- a/charts/invenio/templates/uwsgi-configmap.yaml +++ b/charts/invenio/templates/uwsgi-configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: uwsgi-config + name: {{ include "invenio.fullname" . }}-uwsgi-config labels: {{- include "invenio.labels" . | nindent 4 }} data: diff --git a/charts/invenio/templates/vocabularies-configmap.yaml b/charts/invenio/templates/vocabularies-configmap.yaml index 6d740c9..cbf6aad 100644 --- a/charts/invenio/templates/vocabularies-configmap.yaml +++ b/charts/invenio/templates/vocabularies-configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: invenio-vocabularies + name: {{ include "invenio.fullname" $ }}-vocabularies labels: {{- include "invenio.labels" $ | nindent 4 }} data: diff --git a/charts/invenio/templates/web-deployment.yaml b/charts/invenio/templates/web-deployment.yaml index 67ce4ac..a9359d6 100644 --- a/charts/invenio/templates/web-deployment.yaml +++ b/charts/invenio/templates/web-deployment.yaml @@ -2,18 +2,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: web + name: {{ include "invenio.fullname" . }}-web labels: {{- include "invenio.labels" . | nindent 4 }} + app.kubernetes.io/component: web spec: replicas: {{ .Values.web.replicas }} selector: matchLabels: - app: web + app.kubernetes.io/component: web template: metadata: labels: - app: web + app.kubernetes.io/component: web spec: terminationGracePeriodSeconds: {{ .Values.web.terminationGracePeriodSeconds }} containers: @@ -29,7 +30,7 @@ spec: {{- end }} envFrom: - configMapRef: - name: invenio-config + name: {{ include "invenio.fullname" . }}-config - secretKeyRef: name: {{ include "invenio.secretName" . }} env: @@ -243,7 +244,7 @@ spec: - name: nginx-config configMap: defaultMode: 420 - name: nginx-config + name: {{ include "invenio.fullname" . }}-nginx-config - name: var-run emptyDir: {} - name: var-cache-nginx @@ -253,7 +254,7 @@ spec: - name: uwsgi-config configMap: defaultMode: 420 - name: uwsgi-config + name: {{ include "invenio.fullname" . }}-uwsgi-config - name: nginx-invenio-assets emptyDir: {} {{- if .Values.persistence.enabled }} @@ -268,7 +269,7 @@ spec: {{- if .Values.invenio.vocabularies }} - name: vocabularies configMap: - name: "invenio-vocabularies" + name: "{{ include "invenio.fullname" . }}-vocabularies" {{- end }} {{- if .Values.web.imagePullSecret }} imagePullSecrets: diff --git a/charts/invenio/templates/web-service.yaml b/charts/invenio/templates/web-service.yaml index a1b365a..7cb55ff 100644 --- a/charts/invenio/templates/web-service.yaml +++ b/charts/invenio/templates/web-service.yaml @@ -2,10 +2,10 @@ apiVersion: v1 kind: Service metadata: - name: web + name: {{ include "invenio.fullname" . }}-web labels: {{- include "invenio.labels" . | nindent 4 }} - run: web + app.kubernetes.io/component: web {{- if .Values.web.annotations }} annotations: {{- toYaml .Values.web.annotations | nindent 4 }} @@ -16,5 +16,5 @@ spec: port: 80 targetPort: 8080 selector: - app: web + app.kubernetes.io/component: web type: {{ .Values.web.service.type }} diff --git a/charts/invenio/templates/worker-beat-deployment.yaml b/charts/invenio/templates/worker-beat-deployment.yaml index d467f02..1daa559 100644 --- a/charts/invenio/templates/worker-beat-deployment.yaml +++ b/charts/invenio/templates/worker-beat-deployment.yaml @@ -2,18 +2,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: worker-beat + name: {{ include "invenio.fullname" . }}-worker-beat labels: {{- include "invenio.labels" . | nindent 4 }} + app.kubernetes.io/component: worker-beat spec: replicas: 1 selector: matchLabels: - app: worker-beat + app.kubernetes.io/component: worker-beat template: metadata: labels: - app: worker-beat + app.kubernetes.io/component: worker-beat spec: containers: - name: worker-beat @@ -42,7 +43,7 @@ spec: {{- end }} envFrom: - configMapRef: - name: invenio-config + name: {{ include "invenio.fullname" . }}-config - secretKeyRef: name: {{ include "invenio.secretName" . }} env: @@ -116,7 +117,7 @@ spec: {{- if .Values.invenio.vocabularies }} - name: vocabularies configMap: - name: "invenio-vocabularies" + name: "{{ include "invenio.fullname" . }}-vocabularies" {{- end }} {{- if .Values.worker.imagePullSecret }} imagePullSecrets: diff --git a/charts/invenio/templates/worker-deployment.yaml b/charts/invenio/templates/worker-deployment.yaml index 0036ddd..7a79891 100644 --- a/charts/invenio/templates/worker-deployment.yaml +++ b/charts/invenio/templates/worker-deployment.yaml @@ -2,18 +2,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: worker + name: {{ include "invenio.fullname" . }}-worker labels: {{- include "invenio.labels" . | nindent 4 }} + app.kubernetes.io/component: worker spec: replicas: {{ .Values.worker.replicas }} selector: matchLabels: - app: worker + app.kubernetes.io/component: worker template: metadata: labels: - app: worker + app.kubernetes.io/component: worker spec: containers: - name: worker @@ -33,7 +34,7 @@ spec: - ALL envFrom: - configMapRef: - name: invenio-config + name: {{ include "invenio.fullname" . }}-config - secretKeyRef: name: {{ include "invenio.secretName" . }} env: @@ -154,7 +155,7 @@ spec: {{- if .Values.invenio.vocabularies }} - name: vocabularies configMap: - name: "invenio-vocabularies" + name: "{{ include "invenio.fullname" . }}-vocabularies" {{- end }} {{- if .Values.worker.imagePullSecret }} imagePullSecrets: diff --git a/charts/invenio/values.yaml b/charts/invenio/values.yaml index b2cd1e4..35578c6 100644 --- a/charts/invenio/values.yaml +++ b/charts/invenio/values.yaml @@ -3,6 +3,13 @@ global: timezone: "Europe/Zurich" +## @param nameOverride String to partially override common.names.name +## +nameOverride: "" +## @param fullnameOverride String to fully override common.names.fullname +## +fullnameOverride: "" + ingress: annotations: {} enabled: false