I have a Kustomize like below:
├── base
│ ├── kustomization.yaml
| ├── deployment.yaml
│ └── service.yaml
└── overlays
└── development
├── kustomization.yaml
└── service.yaml
I want to define my-service
as NodePort, and use different nodePort
value for each environment.
My base/service.yaml
:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app/name: my-service
ports:
- name: http
protocol: TCP
port: 9000
targetPort: 80
- name: https
protocol: TCP
port: 9001
targetPort: 443
type: NodePort
overlays/development/kustomization.yaml
:
resources:
- ../../base
patchesStrategicMerge:
- service.yaml
And overlays/development/service.yaml
:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports:
- name: http
nodePort: 30000
- name: https
nodePort: 31000
But with above configurations, kustomize cannot make proper ports
.
$ kubectl kustomize overlays/development
...
---
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports: []
selector:
app/name: my-service
type: NodePort
---
...
What is wrong with my configurations?