Skip to content

Commit

Permalink
Various kube-ui-server ocm improvements
Browse files Browse the repository at this point in the history
- use pre-* hooks for registering crds
- ensure jobs names are <= 52 char
- commonn template for kubectl image

Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Mar 26, 2024
1 parent afe0101 commit 0fae3d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions charts/kube-ui-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ Returns the enabled monitoring agent name
{{- define "monitoring.agent" -}}
{{- .Values.monitoring.agent }}
{{- end }}

{{- define "kubectl.image" -}}
{{ list .Values.registryFQDN "appscode/kubectl-nonroot:1.25" | compact | join "/" }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
automountServiceAccountToken: false
containers:
- name: kubectl
image: {{ include "image.registry" $ }}/kubectl:1.23
image: {{ include "kubectl.image" $ }}
workingDir: /var/run/secrets/ocm
command:
- sh
Expand Down
13 changes: 7 additions & 6 deletions charts/kube-ui-server/templates/ocm-mc/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

{{ $content := toString $data }}
{{ $crd := dig "spec" "names" "plural" "" ($content | fromYaml) }}
{{ $job := printf "kube-ui-server-regcrd-%s" $crd | trunc 52 }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "kube-ui-server.fullname" $ }}-regcrd-{{ $crd }}
name: {{ $job }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "kube-ui-server.labels" $ | nindent 4 }}
annotations:
"helm.sh/hook-weight": "0"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
data:
crd.yaml: |
Expand All @@ -23,13 +24,13 @@ data:
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "kube-ui-server.fullname" $ }}-regcrd-{{ $crd }}
name: {{ $job }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "kube-ui-server.labels" $ | nindent 4 }}
annotations:
"helm.sh/hook-weight": "1"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook": pre-install,pre-upgrade,pre-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
spec:
ttlSecondsAfterFinished: 0
Expand All @@ -40,7 +41,7 @@ spec:
automountServiceAccountToken: false
containers:
- name: kubectl
image: {{ include "image.registry" $ }}/kubectl:1.23
image: {{ include "kubectl.image" $ }}
workingDir: /var/run/secrets/ocm
command:
- sh
Expand All @@ -61,7 +62,7 @@ spec:
secretName: {{ $.Values.kubeconfigSecretName }}
- name: crd-volume
configMap:
name: {{ include "kube-ui-server.fullname" $ }}-regcrd-{{ $crd }}
name: {{ $job }}
restartPolicy: Never
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/kube-ui-server/templates/ocm-mc/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
automountServiceAccountToken: true
containers:
- name: kubectl
image: {{ include "image.registry" $ }}/kubectl:1.23
image: {{ include "kubectl.image" $ }}
workingDir: /var/run/secrets/ocm
command:
- sh
Expand Down

0 comments on commit 0fae3d3

Please sign in to comment.