Reputation: 979
Suppose I have 4 deployment files and for that I have 1 combined service file which will create service objects for all 4 services(deployment.yaml). Now I want to expose only 1 service pod as NodePort service, for which I have nodeport defined along with port and target port. for rest of the 3 services I have only defined port and target port and not the nodeport. Question is, in this case whether the K8 master assign some random nodeport for rest of the 3 services for which nodeport not defined? Service.YAML:
I can always declare 4 nodePorts for 4 services. But How K8s Master will handle below manifest is more I am interested to explore for my app deployment
apiVersion: v1
kind: Service
metadata:
name: myapp-uwsgi-service
namespace: myspace
labels:
central-app: myapp-uwsgi
spec:
clusterIP: 10.3.0.106
type: NodePort
selector:
central-app: configuration-uwsgi
ports:
-
name: service-app-1
port: 10010
targetPort: 10010
nodePort: 32123
-
name: service-app-2
port: 10011
targetPort: 10011
-
name: service-app-3
port: 10012
targetPort: 10012
-
name: service-app-4
port: 10013
targetPort: 10013
My expectation and understanding is that rest of the 3 service-app will assigned with some random nodePort from K8s master.
Upvotes: 0
Views: 548
Reputation: 17689
Service type nodeport would assign random ports to others port defined in the service YAML. In your case you would end up with four nodeports
Upvotes: 1