Skip to content

Commit

Permalink
#95 remove name collisions in helm chart
Browse files Browse the repository at this point in the history
use the helm release name to generate the name of the loadbalancer
  • Loading branch information
alexander-dammeier committed Jul 19, 2024
1 parent 800d640 commit 0c34fe7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions k8s/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{{- define "k8s-ces-setup.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "k8s-ces-setup-finisher.name" -}}
{{- "k8s-ces-setup-finisher"}}
{{ include "k8s-ces-setup.name" . }}{{- "k8s-ces-setup-finisher"}}
{{- end }}

{{- define "k8s-ces-loadbalancer.name" -}}
{{ include "k8s-ces-setup.name" . }}-ces-loadbalancer
{{- end }}


{{/* All-in-one labels */}}
Expand Down
1 change: 1 addition & 0 deletions k8s/helm/templates/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
{{- include "k8s-ces-setup.labels" .| nindent 4 }}
data:
# TODO: we need to change this too, if we change names of resources or labels
entrypoint.sh: "#!/bin/bash\nSTATE=$(kubectl get configmap k8s-setup-config -o jsonpath='{.data.state}');\nif [[ ${STATE} == \"installed\" ]]; then \n kubectl delete configmap k8s-ces-setup-json || true\n kubectl delete configmap k8s-setup-config || true\n kubectl delete deployments,services,configmaps,secrets,roles,rolebindings,clusterroles,clusterrolebindings,serviceaccounts -l app.kubernetes.io/name=k8s-ces-setup || true\n kubectl patch cronjob cleanup -p '{\"spec\" : {\"suspend\" : true }}'\n kubectl delete configmap k8s-ces-setup-cleanup-script\n kubectl delete cronjob k8s-ces-setup-finisher\n kubectl delete serviceaccount k8s-ces-setup-finisher\n kubectl delete rolebinding k8s-ces-setup-finisher\nelse \n echo \"setup seems not to be installed or successfully executed\";\nfi"
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
6 changes: 3 additions & 3 deletions k8s/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
selector:
matchLabels:
app.kubernetes.io/name: k8s-ces-setup
app.kubernetes.io/name: {{ include "k8s-ces-setup.name" . }}
template:
metadata:
labels:
Expand Down Expand Up @@ -73,10 +73,10 @@ spec:
readOnly: true
volumes:
- configMap:
name: {{ include "k8s-ces-setup.name" . }}-config
name: k8s-ces-setup-config
name: k8s-ces-setup-config
- configMap:
name: {{ include "k8s-ces-setup.name" . }}-json
name: k8s-ces-setup-json
optional: true
name: k8s-ces-setup-json
- name: dogu-registry-cert
Expand Down
3 changes: 2 additions & 1 deletion k8s/helm/templates/setup-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "k8s-ces-setup.name" . }}-config
name: k8s-ces-setup-config
labels:
{{- include "k8s-ces-setup.labels" .| nindent 4 }}
data:
k8s-ces-setup.yaml: |
component_operator_chart: "{{ .Values.component_operator_chart }}"
component_operator_crd_chart: "{{ .Values.component_operator_crd_chart }}"
loadbalancer_name: "{{ include "k8s-ces-loadbalancer.name" . }}"
{{- if .Values.components }}
components:
{{- toYaml .Values.components | nindent 6}}
Expand Down
2 changes: 1 addition & 1 deletion k8s/helm/templates/setup-json.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "k8s-ces-setup.name" . }}-json
name: k8s-ces-setup-json
labels:
{{- include "k8s-ces-setup.labels" .| nindent 4 }}
data:
Expand Down

0 comments on commit 0c34fe7

Please sign in to comment.