How to add things to a list using kustomize. This is useful for example when you need to patch additional environment variables into a pod.
A simple example, adding the MY_SETTING
environment variable to pods in a deployment called external-deployment
while keeping all pre-existing environment variables in the list.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- base/deployment.yaml
patches:
- target:
group: apps
version: v1
kind: Deployment
name: external-deployment
path: patches/external-deployment.yaml
- op: add
path: "/spec/template/spec/containers/0/env/0"
value:
name: MY_SETTING
value: "my value"