Add a strategic merge patch
Create a strategic merge patch and register it in kustomization.yaml
cat > patch.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
template:
spec:
containers:
- name: myapp
resources:
limits:
memory: 512Mi
EOF
echo 'patches:\n- path: patch.yaml' >> kustomization.yaml
- tool
- kustomize23 commands
More kustomize commands
-
kustomize build --enable-helm ./overlayRender the helmCharts: block into manifests; helm must be in PATH
-
cat <<'EOF' >> kustomization.yaml components: - ../../components/monitoring EOFMix in reusable patches and resources with components: (Kustomize v4+)
-
cat <<'EOF' >> kustomization.yaml replacements: - source: {kind: ConfigMap, name: cfg, fieldPath: data.host} targets: - select: {kind: Deployment} fieldPaths: [spec.template.spec.containers.0.env.0.value] EOFCopy a field from one resource to another; replacements: is the modern way instead of the deprecated vars:
-
cat <<'EOF' >> kustomization.yaml patches: - target: {kind: Deployment, labelSelector: app=api} patch: |- - op: replace path: /spec/replicas value: 3 EOFApply a JSON6902 patch to all matching resources, no separate file needed
-
kustomize edit set image app=registry.example.com/app@sha256:<id>Pin the image to an immutable digest; you can also set newName and digest in the images: block