Kubernetes apply all files inside a directory, "kubectl apply --all"?

Viewed 2556

Just wondering, let's say I have X Kubernetes deployment.yaml, pod.yaml, persistedvolumecliam.yaml and service.yaml files inside a directory.

The tutorials would tell us to do the following:

kubectl apply -f frontend-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml

Is there a way just to do something like:

kubectl apply all

or

kubectl apply -f *

or some variation thereof to spin all of the kube stuffs within on directory?

2 Answers

You can apply everything inside a directory with kubectl apply -f /path/to/dir. To include subdirectories use the paramter -R, like kubectl apply -R -f /path/to/dir

# Apply resources from a directory
kubectl apply -f dir/

# Process the directory used in -f recursively
kubectl apply -R -f dir/

For more details check the reference documentation.

Related