Skip to content

Commit

Permalink
chore: provide name uniqueness to resources
Browse files Browse the repository at this point in the history
  • Loading branch information
egabancho committed Jan 14, 2025
1 parent 914a80e commit c1508c1
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 33 deletions.
22 changes: 20 additions & 2 deletions charts/invenio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/}}
Expand Down Expand Up @@ -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 -}}
Expand Down Expand Up @@ -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 -}}
2 changes: 1 addition & 1 deletion charts/invenio/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
6 changes: 3 additions & 3 deletions charts/invenio/templates/install-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -32,7 +32,7 @@ spec:
]
envFrom:
- configMapRef:
name: invenio-config
name: {{ include "invenio.fullname" . }}-config
- secretKeyRef:
name: {{ include "invenio.secretName" . }}
env:
Expand All @@ -59,7 +59,7 @@ spec:
volumes:
- name: vocabularies
configMap:
name: "invenio-vocabularies"
name: "{{ include "invenio.fullname" . }}-vocabularies"
{{- end }}
{{- if .Values.web.imagePullSecret }}
imagePullSecrets:
Expand Down
2 changes: 1 addition & 1 deletion charts/invenio/templates/invenio-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: invenio-config
name: {{ include "invenio.fullname" . }}-config
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
Expand Down
2 changes: 1 addition & 1 deletion charts/invenio/templates/nginx-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions charts/invenio/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/invenio/templates/sentry-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/invenio/templates/uwsgi-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charts/invenio/templates/vocabularies-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: invenio-vocabularies
name: {{ include "invenio.fullname" $ }}-vocabularies
labels:
{{- include "invenio.labels" $ | nindent 4 }}
data:
Expand Down
15 changes: 8 additions & 7 deletions charts/invenio/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -29,7 +30,7 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: invenio-config
name: {{ include "invenio.fullname" . }}-config
- secretKeyRef:
name: {{ include "invenio.secretName" . }}
env:
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions charts/invenio/templates/web-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -16,5 +16,5 @@ spec:
port: 80
targetPort: 8080
selector:
app: web
app.kubernetes.io/component: web
type: {{ .Values.web.service.type }}
11 changes: 6 additions & 5 deletions charts/invenio/templates/worker-beat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,7 +43,7 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: invenio-config
name: {{ include "invenio.fullname" . }}-config
- secretKeyRef:
name: {{ include "invenio.secretName" . }}
env:
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions charts/invenio/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +34,7 @@ spec:
- ALL
envFrom:
- configMapRef:
name: invenio-config
name: {{ include "invenio.fullname" . }}-config
- secretKeyRef:
name: {{ include "invenio.secretName" . }}
env:
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions charts/invenio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c1508c1

Please sign in to comment.