Scenario:
I have a k8s cluster with host01, host02 and host03.
I'm running master on host01 and slaves on host02 and host03, and I want to open a port for client connections on master, ie I want to open: host01:32702.
Using following service.yaml, I managed to open host01:32702. To my surprise host02:32702 and host03:32702 are also open.
kind: Service
# ...
spec:
type: NodePort
ports:
- name: dashboard
port: 8265
targetPort: 8265
nodePort: 32702
selector:
podonhost01: yes
Questions:
- Is this intended NodePort behavior? Is the selector not working?
- If yes, then why is this the intended NodePort behavior? If I have 1000s hosts, then single service will open port 32702 on all these hosts?
- How do I only open port 32702 on
host01and not the rest of hosts?