When starting to work with Kubernetes there are many port declarations in configuration files and it can be easy to forget which port is responsible for which traffic, I hope this post can be a reference for you when those situations arise.
Ports defined in deployment configuration:
spec.containers.ports.containerPort- This is the port at which the pod/container is reachable.
Ports defined in service configuration:
spec.ports.nodePort- This is the port of the node(s) in the cluster. It is the port at which the node can be reached from external traffic.
spec.ports.port- This is the port of the cluster service itself. After receiving a valid request the traffic will be forwarded to the pod/containers
spec.ports.targetPort- This is the port the service will forward requests to. It is the port your pod/container is listening for requests on.
- How to use a secrets file for postgres credentials using Kubernetes
- When to use which service type in Kubernetes
- Connecting Kubernetes Deployments to Pods
- How to view a Kubernetes pods IP address
- How to view the status data in a Kubernetes Deployment
- Create your first Rails app cluster with Kubernetes and Docker
- Kubernetes kubectl commands for newbies