My current directory contents are:
$ tree
├── README.md
├── deploy.sh
├── grizzly
│ ├── configs
│ │ ├── nginx-conf.yml
│ │ └── proxy-conf.yml
│ ├── deployments
│ │ ├── api.yml
│ │ ├── celery.yml
│ │ └── proxy.yml
│ ├── secrets
│ └── services
│ ├── api.yml
│ └── proxy.yml
├── ingress.yml
└── shared
├── configs
│ └── rabbitmq.yml
└── env
└── variables.yml
I plan to create a script that will run $ kubectl apply
for all files in this tree.
My thought is to get all the child directories then just have all those child directories(expected to have the yml files) execute $ kubectl apply
for my resources to be created.
This is an instance of the XY Problem. You want to apply all yamls which are somewhere within the directory structure of the current directory.
Just run:
kubectl apply -f . --recursive
If you want to filter the files based on certain conditions you can use a construct like
find . -type f | grep 'api.yml' | xargs -n 1 kubectl apply -f