Ports in Kubernetes Services (Kubernetes)
Just a quick reminder how ports definition in k8s services works. Service definition example below, just forgot all but port definition and take a closer look. NodePort
1 2 3 4 5 6 7 8 9 10 11 12 |
apiVersion: v1 kind: Service metadata: name: client-node-port spec: type: NodePort ports: - port: 3050 targetPort: 3000 nodePort: 31515 selector: component: web |
We can see port definition 3 times (it’s array and you can use as many of them as open ports you need): port, targetPort and nodePort. Why 3 ports? If you are familiar with Docker (Swarm) you would expect only 2, right…? NodePort port : other pod/service inside our cluster can access…