Héctor
Héctor

Reputation: 26084

Is it possible to define nodePort in "kubectl expose" command?

I have a ReplicationController and I expose it as a Service by:

kubectl expose rc my-rc --port=9000 --target-port=8080 --type=NodePort --name=my-service

Then, Kubernetes gives me a random public port for the exposed Service, 31289 for instance. If you create the Service using a yaml file, you can define that port in spec.ports[*].nodePort field. In this case, I have to create the Service via expose command instead of declaratively using a yaml.

Is there a way to define the nodePort in kubectl expose command?

Upvotes: 0

Views: 514

Answers (1)

Robert Bailey
Robert Bailey

Reputation: 18230

There isn't a way to specify a NodePort when creating a service of type NodePort. Feel free to file a feature request to add this feature (or send a pull request).

Upvotes: 1

Related Questions