I got a question to expose a deployment via nodeport with tcp port of 8888. But, . . .

Pradeep:
I got a question to expose a deployment via nodeport with tcp port of 8888. But, when I mention nodePort: 8888 in the yaml file. It says, it is not a standard range port. How could we resolve this?

Tej_Singh_Rana:
Hello, @Pradeep
NodePort range between 30000 - 32767.

Pradeep:
So, should I mention one of them of my own choice if they didn’t mention the port in the question

Balaji K:
@Pradeep you will never specify a specific nodeport when creating. So you will always allow it to take and yes later you can edit via kube edit and update if question says a specific port.

Pradeep:
got you. I am assuming we need to mention it always when creating service with nodeport.

Tej_Singh_Rana:
No, that’s not necessary. Please give it a try in the lab.

Tej_Singh_Rana:
Note - If you will not specify, then by default it will choose between 30000-32767.

Pradeep:
Sure, thank you

Joe:
What is the imperative command to create a nodeport service? I believe by default it chooses clusterip

Pradeep:
@Joe

k expose deploy deployment-name --name=service-name --port=8888 --type=NodePort