kubernetes: kubectl expose does not work with kind and selector

Is this a BUG REPORT or FEATURE REQUEST?: /kind bug

What happened: Trying to expose a pod using a selector

What you expected to happen: To be able to create a service with a kind and selector only

How to reproduce it (as minimally and precisely as possible): kubectl expose pod --selector='app=MYAPP' --name myappsvc --port=4242

Anything else we need to know?: It fails with:

$ k expose pod --selector='app=iscsi-demo-target' --name kk --port=55
error: resource(s) were provided, but no name, label selector, or --all flag specified
See 'kubectl expose -h' for help and examples.

Environment:

  • Kubernetes version (use kubectl version): 1.8
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools: minikube
  • Others:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 23 (11 by maintainers)

Most upvoted comments

/remove-lifecycle rotten

I guess this is still relevant.

How I imagine this flag to work - and I actually thought it worked this way:

kubectl expose pod --selector='mylabel=myvalue' --name=mysvc --port=42

Here I’d expect that a service mysvc is created, exposing port 42 of all pods matching the labelSelector mylabel=myvalue.