skip to Main Content

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?

3

Answers


  1. 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

    Login or Signup to reply.
  2. # 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.

    Login or Signup to reply.
  3. You can apply a YAML file using kubectl apply recursively in all folders by using the –recursive flag.

    Here is the basic syntax once you are in the root folder:

    kubectl apply --recursive -f .
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search