Category: Deployment, Kubernetes, firewall, yaml

I can safely assume either you are a Kubernetes learner or seeking more clarity on different port types being used in service and pod container spec. Kubernetes uses different types of ports when you write pod container specs or when you create a service for your deployment or set of pods as endpoints.

In container spec, you need to define port which container is going to use.

Hence, in the context of service spec “Port” is used to define the port on which service listens. targetPort and containerPort must be identical most of the time because whatever port is open for your application in a container that would be the same port you will wish to send traffic from service via targetPort.

Related Articles