To get the NodePort assigned to a specific service in Kubernetes, you can use the following command:
kubectl get service <service-name> -o jsonpath='{.spec.ports[0].nodePort}'
Replace <service-name> with the name of your service. This command will output the NodePort number directly.
Example
If your service is named my-service, you would run:
kubectl get service my-service -o jsonpath='{.spec.ports[0].nodePort}'
This will return the NodePort assigned to my-service.
