i'm trying to path deployment by using kustomize i need to change only env in the spec.template.spec.containers. but during kustomisation other fields are deleting too
tree:
k8s
|_base
|_ deployment.yaml
|_ kustomisation.yaml
|_ svc.yaml
|_overlays
|prod
|_ kustomisation.yaml
|_ patches.yaml
|_stage
|_dev
base.deployment.yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: __NAME__
name: __NAME__
namespace: __NAME__
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/name: __NAME__
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: __NAME__
app.kubernetes.io/name: __NAME__
spec:
containers:
- name: __NAME__
image: __IMAGE__
env:
- name: name_
value: value_
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 8081
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 1
ports:
- containerPort: 8081
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 8081
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 1500m
memory: 1Gi
requests:
cpu: 250m
memory: 128Mi
securityContext:
runAsGroup: 1001
runAsUser: 1001
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
overlays.prod.kustomization.yaml
resources:
- ../../base/
patches:
- target:
kind: Deployment
name: __NAME__
path: patches.yaml
overlays.prod.patches.yaml
kind: Deployment
metadata:
name: __NAME__
spec:
template:
spec:
containers:
- name: __NAME__
env:
- name: ENV_VAR_NAME_1
value: new_value_1
- name: ENV_VAR_NAME_2
value: new_value_2
after the command kubectl kustomize overlays/prod/ -o stage_test.yaml
output is
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: __NAME__
name: __NAME__
namespace: __NAME__
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/name: __NAME__
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: __NAME__
app.kubernetes.io/name: __NAME__
spec:
containers:
- env:
- name: ENV_VAR_NAME_1
value: new_value_1
- name: ENV_VAR_NAME_2
value: new_value_2
name: __NAME__
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
as you can see kustomise - deleting probes, ports and othes stuff
How to avoid deleting? i need only to change envs. ofc if i put all other stuff into patches.yaml kustomize will add it into output
tried to set annotation annotations: kustomize.kubernetes.io/ignore-patches: "true" and run kustomize with it (not worked - same output)
pathes to patchesStrategicMerge (worked identically)
versions if it's matter:
Kustomize Version: v4.5.7
Client Version: 1.26
Platform: darwin/arm64