-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: install apiservices using helm hooks (#192)
* feat: install apiservices using helm hooks Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: chart linter Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: bump chainsaw Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: add patch permissions Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: simplify permissions Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: charts and images Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> --------- Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
- Loading branch information
1 parent
94a2def
commit 02c8d53
Showing
13 changed files
with
465 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
charts/reports-server/templates/hooks/post-install-api-services.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{{- if .Values.apiServicesManagement.enabled -}} | ||
{{- if not .Values.templating.enabled -}} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "reports-server.fullname" . }}-post-install-install-api-services | ||
namespace: {{ $.Release.Namespace }} | ||
labels: | ||
{{- include "reports-server.labels" . | nindent 4 }} | ||
annotations: | ||
helm.sh/hook: post-install | ||
helm.sh/hook-weight: "100" | ||
spec: | ||
backoffLimit: 2 | ||
template: | ||
metadata: | ||
{{- with .Values.apiServicesManagement.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.podLabels }} | ||
labels: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
serviceAccount: {{ include "reports-server.serviceAccountName" . }} | ||
{{- with .Values.apiServicesManagement.podSecurityContext }} | ||
securityContext: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
restartPolicy: Never | ||
{{- with .Values.apiServicesManagement.imagePullSecrets | default .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: kubectl | ||
image: "{{ .Values.apiServicesManagement.image.registry }}/{{ .Values.apiServicesManagement.image.repository }}:{{ .Values.apiServicesManagement.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.apiServicesManagement.image.pullPolicy }} | ||
command: | ||
- /bin/bash | ||
- '-c' | ||
- |- | ||
set -euo pipefail | ||
kubectl wait -n {{ $.Release.Namespace }} pod --for=condition=ready -l app.kubernetes.io/name={{ include "reports-server.fullname" . }} --timeout=120s | ||
kubectl apply -f - <<EOF | ||
{ | ||
"apiVersion": "apiregistration.k8s.io/v1", | ||
"kind": "APIService", | ||
"metadata": { | ||
"name": "v1alpha2.wgpolicyk8s.io", | ||
"namespace": {{ $.Release.Namespace | quote }}, | ||
"labels": { | ||
"kube-aggregator.kubernetes.io/automanaged": "false" | ||
}, | ||
"annotations": { | ||
"helm.sh/hook": "post-install" | ||
} | ||
}, | ||
"spec": { | ||
"group": "wgpolicyk8s.io", | ||
"groupPriorityMinimum": 100, | ||
"insecureSkipTLSVerify": true, | ||
"service": { | ||
"name": {{ include "reports-server.fullname" . | quote }}, | ||
"namespace": {{ $.Release.Namespace | quote }} | ||
}, | ||
"version": "v1alpha2", | ||
"versionPriority": 100 | ||
} | ||
} | ||
EOF | ||
kubectl apply -f - <<EOF | ||
{ | ||
"apiVersion": "apiregistration.k8s.io/v1", | ||
"kind": "APIService", | ||
"metadata": { | ||
"name": "v1.reports.kyverno.io", | ||
"namespace": {{ $.Release.Namespace | quote }}, | ||
"labels": { | ||
"kube-aggregator.kubernetes.io/automanaged": "false" | ||
}, | ||
"annotations": { | ||
"helm.sh/hook": "post-install" | ||
} | ||
}, | ||
"spec": { | ||
"group": "reports.kyverno.io", | ||
"groupPriorityMinimum": 100, | ||
"insecureSkipTLSVerify": true, | ||
"service": { | ||
"name": {{ include "reports-server.fullname" . | quote }}, | ||
"namespace": {{ $.Release.Namespace | quote }} | ||
}, | ||
"version": "v1", | ||
"versionPriority": 100 | ||
} | ||
} | ||
EOF | ||
{{- with .Values.apiServicesManagement.securityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.tolerations | default .Values.tolerations}} | ||
tolerations: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.nodeSelector | default .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
{{- if or .Values.apiServicesManagement.podAntiAffinity .Values.apiServicesManagement.podAffinity .Values.apiServicesManagement.nodeAffinity }} | ||
affinity: | ||
{{- with .Values.apiServicesManagement.podAntiAffinity }} | ||
podAntiAffinity: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.podAffinity }} | ||
podAffinity: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.nodeAffinity }} | ||
nodeAffinity: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
{{- end -}} |
76 changes: 76 additions & 0 deletions
76
charts/reports-server/templates/hooks/pre-delete-api-service-cleanup.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{{- if .Values.apiServicesManagement.enabled -}} | ||
{{- if not .Values.templating.enabled -}} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "reports-server.fullname" . }}-pre-delete-api-services-cleanup | ||
namespace: {{ $.Release.Namespace }} | ||
labels: | ||
{{- include "reports-server.labels" . | nindent 4 }} | ||
annotations: | ||
helm.sh/hook: pre-delete | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed | ||
helm.sh/hook-weight: "100" | ||
spec: | ||
backoffLimit: 2 | ||
template: | ||
metadata: | ||
{{- with .Values.apiServicesManagement.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.podLabels }} | ||
labels: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
serviceAccount: {{ include "reports-server.serviceAccountName" . }} | ||
{{- with .Values.apiServicesManagement.podSecurityContext }} | ||
securityContext: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
restartPolicy: Never | ||
{{- with .Values.apiServicesManagement.imagePullSecrets | default .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: kubectl | ||
image: "{{ .Values.apiServicesManagement.image.registry }}/{{ .Values.apiServicesManagement.image.repository }}:{{ .Values.apiServicesManagement.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.apiServicesManagement.image.pullPolicy }} | ||
command: | ||
- /bin/bash | ||
- '-c' | ||
- |- | ||
set -euo pipefail | ||
kubectl wait -n {{ $.Release.Namespace }} pod --for=condition=ready -l app.kubernetes.io/name={{ include "reports-server.fullname" . }} --timeout=120s | ||
kubectl delete apiservice v1alpha2.wgpolicyk8s.io v1.reports.kyverno.io --ignore-not-found=true | ||
{{- with .Values.apiServicesManagement.securityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.tolerations | default .Values.tolerations}} | ||
tolerations: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.nodeSelector | default .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- tpl (toYaml .) $ | nindent 8 }} | ||
{{- end }} | ||
{{- if or .Values.apiServicesManagement.podAntiAffinity .Values.apiServicesManagement.podAffinity .Values.apiServicesManagement.nodeAffinity }} | ||
affinity: | ||
{{- with .Values.apiServicesManagement.podAntiAffinity }} | ||
podAntiAffinity: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.podAffinity }} | ||
podAffinity: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} | ||
{{- with .Values.apiServicesManagement.nodeAffinity }} | ||
nodeAffinity: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.