I have a base and overlay system. Something similar to the following code part.
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
spec:
selector:
matchLabels:
app: frontend-deployment
template:
metadata:
labels:
app: frontend-deployment
spec:
containers:
- name: app
image: foo/bar:latest
ports:
- name: http
containerPort: 80
protocol: TCP
Now I would like to patch the “containerPort: 80” to something different like “containerPort:1080”
in my kustomize.yaml
I have
namePrefix: qa1-
transformers:
- deploy-prefix-transformer.yaml
[...]
patchesStrategicMerge:
- patches/backup-cronjob-overlay.yaml # works like a charm
[...]
patches:
- path: patches/change-containerport.yaml
target:
kind: Deployment
name: qa1-frontend-deployment
within the change-containerport.yaml
- op: replace
path: "/spec/template/spec/containers/0/ports/0/containerPort"
# also tested path: spec.template.spec.containers[0].ports[0].containerPort"
value: 1080
Within kubectl apply -k .
there comes no error messages, but the result is that the containerPort is NOT change to 1080.
What is the right way to replace the value?
Kind regards.