label-ns.yaml

Use Helm hook to add labels to a namespace before chart installation

1

Votes

# 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: kube-system
  labels:
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  annotations:
    helm.sh/hook: pre-install
    helm.sh/hook-delete-policy: hook-succeeded
spec:
  template:
    spec:
      containers:
      - name: labeler
        image: gcr.io/google_containers/hyperkube:v1.9.7
        command:
        - kubectl
        - label
        - ns
        - {{ .Release.Namespace }}
        - istio-injection=enabled
      restartPolicy: Never
      # use tiller service account since it should have permissions to do namespace labeling
      serviceAccountName: tiller

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png