-
-
Save jasoares/5976145e0f4a3cde44b3b560ce81978a to your computer and use it in GitHub Desktop.
Use Helm hook to add labels to a namespace before chart installation
This file contains hidden or 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 hook depends on helm creating the target namespace if it doesn't exist | |
# before the hook is called. This is the case on Helm v2.9.1 | |
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: label-ns | |
namespace: cicd | |
labels: | |
release: {{ .Release.Name }} | |
heritage: {{ .Release.Service }} | |
annotations: | |
helm.sh/hook: pre-install | |
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded | |
spec: | |
template: | |
spec: | |
containers: | |
- name: labeler | |
image: bitnami/kubectl:1.20.10 | |
command: | |
- /bin/sh | |
- -ec | |
- | | |
kubectl label --overwrite namespace {{ .Release.Namespace }} elbv2.k8s.aws/pod-readiness-gate-inject=enabled | |
restartPolicy: OnFailure | |
# use circleci-user service account setup on cicd namespace for permissions to change namespaces | |
serviceAccountName: circleci-user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment