Deploy Node App on Kubernetes Task - Can't reach the App

Hi guys,

Can you please advise as to why the application is not reachable via the nodeport? What am I missing?

Please find below ;

Testing

Configs status

Deployment

Service

Pod status


Thanks,
Salim

Hi guys,

I was able to spot the issue and it was because I did not create the service in that given namespace.

TIP: I left the task and went to get some rest and come back later. Don’t do the tasks when you are tired or hungry :rofl:


Cheers,
Salim

1 Like

HI
I have gone this task, did it successfully
but one thing I did not understand is that the container port was set 80 - containerPort: 80
while in service target port is set as 8080 i.e targetPort: 8080
so how does that map? as per my understanding target port should also 80

Cc @Ayman

@hjavaid, port : Refers to the port of the service

TargetPort: This is the actual port on which your application is running inside the container

A Service can map any incoming port to a targetPort. By default and for convenience, the targetPort is set to the same value as the port field. It is not absolutely necessary that both should be using same port.

@tgp my question is still unanswered
if the container is listening on port 80 so the targetPort should also be 80 so that any hit coming on nodeport service should be forwarded on port 80

As you can see in the picture below pod is running on port 80 hence TargetPort is also 80

@hjavaid, In most cases we use both port and target port same for our convenience. But it is absolutely not necessary to be the same.