I was playing with k8s deployment with change of port for service,container and ingress.I am curious to know how the deployment is working.
my scenario : To deploy one rest service application hosting 2 endpoints.
Case 1:
containerPort: 8081 - # port for container
port: 8081 #port of the service targetPort: 8081
Host1 port : 8081 #port of the ingress Host2 port :8081
Result : deployed successfully using bamboo pipeline as expected.
Case 2: containerPort: 8080 - # port for container
_
port: 8080 #port of the service targetPort: 8081
_
Host1 port : 8081 #port of the ingress Host2 port :8081 Result : Deployment is getting failed in bamboo but health check and all end points are working fine.
Case 3:
containerPort: 8080 - # port for container
port: 8080 #port of the service targetPort: 808
Host1 port : 8080 #port of the ingress Host2 port :8080
Result : deployment unsuccessful in bamboo which is also expected because another host is running also in 8080 in the same cluster.
I am really not sure why Case 2 is failing. Can someone help me?
Case 2:
containerPort: 8080 - # port for container
port: 8080 #port of the service targetPort: 8081
Host1 port : 8081 #port of the ingress Host2 port :8081
Result : Deployment is getting failed in bamboo but health check and all end points are working fine.
I am really not sure why Case 2 is failing. Can someone help me?
You cannot expect it to be working if you set targetPort
in your Service
to 8081
and the port that your container exposes (port that your pod is listening on) is 8080
. These two values must much. Please refer to this article in official k8s documentation.