Search code examples
kuberneteskubectl

Is there a way to kubectl apply all the files in a directory?


I am writing an ansible playbook right now that deploys a dockerized application in kubernetes. However, for molecularity purposes I would rather not hard code the files that need to be apply after doing kompose convert -f docker-compose.yaml --volumes hostPath Is there a way to apply all the files in a directory?


Solution

  • You can apply all files in a folder with

    kubectl apply -f <folder> 
    

    You may also be interested in parameterization of your manifest files using Kustomize e.g. use more replicas in a prod-namespace than in a test-namespace. You can apply parameterized manifest files with

    kubectl apply -k <folder>