kubernetes: Possible Bug: `kubectl get svc --export` omits `NodePort`

We’ve defined a Service that needs to be port-bound to the host-machine on a specific port, which is then associated with our ELB. This Service fronts a Deployment that acts like our “mesh” router (which we call edge-router). When we --export a service, the nodePort we originally defined is dropped. Upon re-import, it will be assigned some random nodePort.

what

  • Using --export with kubectl get svc causes nodePort to be dropped, even if it was explicitly set

expectation

  • Using --export option should produce output that resembles original resource as submitted by using kubectl apply
  • If the original resource was created with an explicit nodePort, the value should be preserved when using --export

reproduction

  1. create a new service called foo with an explicit nodePort defined
  2. apply the foo service
  3. run kubectl get svc foo -o yaml --export
  4. observe that the nodePort is missing

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@AdoHe Thanks - that helps explain what’s going on. I’d prefer that --export work for lists as well. I also think “cluster-specific” should be qualified. Fields dynamically generated by the cluster should be stripped off with --export; however, fields that I specify should always be preserved by exports. I also think that the following fields should be stripped from exports because they were generated by the cluster. We do this currently with sed -E /\b(creationTimestamp|resourceVersion|uid|selfLink):/d.

@kubernetes/kubectl I think there are two things we need to with export: 1. “cluster-specific” should be qualified, or users will get confused. 2. how export should work with list resources.

@liggitt Is there some documentation about it somewhere ? It would be interesting to have it available easily(Not on a GitHub issue).