kubectl deploy only one component from a yaml

Viewed 123

I have a yaml file which works if I deploy it using

kubectl apply -f myComponents.yaml

My question is, is there a way to deploy just one component from this YAML? For example, if my YAML has both deployment and service and I just want to deploy the service

I am looking for something like

kubectl apply -f myComponents.yaml Service
2 Answers

No. ⛔

At least not yet. Currently, you can take advantage of tools like kustomize, to apply/create/delete what you'd like, but that's not necessarily the same thing.

Having said I've made a feature request for kubectl .

✌️

No. You can use a command line tool to do this like yq though, depending on how fancy you want to be:

cat myComponents.yaml | yq 'some selector' | kubectl apply -f -
Related