To get all NodePorts for all services in your Kubernetes cluster, you can use the following command:
kubectl get services --field-selector spec.type=NodePort -o jsonpath='{range .items[*]}{.metadata.name}: {.spec.ports[0].nodePort}{"\n"}{end}'
This command filters the services to only show those of type NodePort and outputs their names along with their corresponding NodePort numbers.
Example Output
The output will look something like this:
my-service: 30001
another-service: 30002
This way, you can see all the NodePorts for the services in your cluster.
