Helm Hook

In case you need to execute some kubectl commands after some deployments in a helm chart, you can create a Helm job that uses a kubectl image like this example:

apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ .Release.Name }}"
  namespace: default
  finalizers: []
  labels:
    helm.sh/chart: {{.Chart.Name}}
    application: token-job
  annotations:
    # This is what defines this resource as a hook. Without this line, the
    # job is considered part of the release.
    "helm.sh/hook": post-install
    "helm.sh/hook-weight": "-5"
    "helm.sh/hook-delete-policy": hook-succeeded
spec:
  template:
    metadata:
      name: "{{ .Release.Name }}"
      labels:
        helm.sh/chart: {{.Chart.Name}}
    spec:
      serviceAccountName: token-job
      restartPolicy: Never
      containers:
        - name: kubectl
          image: "k8s.gcr.io/hyperkube:v1.12.1"
          imagePullPolicy: "IfNotPresent"
          command:
            - /bin/sh
            - -c
            - >
              sleep 30;
              kubectl get secret -o json link1 -n {{.Values.sites.public.namespace}} | jq 'del(.metadata.namespace)' > ./token.json;
              kubectl apply -f ./token.json -n {{.Values.sites.private.namespace}};              

Remember that the job needs to have permissions in the namespaces you need to operate.

You can see the full example here