Apply strategic merge patch kustomize
Use patchesStrategicMerge to partially override base resources
# Add patchesStrategicMerge in kustomization.yaml
more kustomize
all 23 commands →
Apply strategic merge patch
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
Inflate Helm charts in kustomize build
kustomize build --enable-helm ./overlay
Apply a reusable component overlay
cat <<'EOF' >> kustomization.yaml
components:
- ../../components/monitoring
EOF
Copy a field with replacements
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]
EOF
Inline patch with target selector
cat <<'EOF' >> kustomization.yaml
patches:
- target: {kind: Deployment, labelSelector: app=api}
patch: |-
- op: replace
path: /spec/replicas
value: 3
EOF