I am quite new to Bash and working on multiple kubernetes cluster. I wanted some kind of utility wherein I can set my KUBECONFIG variable dynamically as I work on multiple clusters. My kubeconfig file lies in multiple folders. What I want is to find all the kubeconfig files , get the paths and concatenate the paths with colon , set it to KUBECONFIG variable and export it in bashrc file.
I know pieces of command but not able to frame full code.
find /Users/anandabhishe/gitlab/ -name kubeconfig.yaml -exec echo {} \;
I want to concatenate the output of find command and set my KUBECONFIG. like this "
export KUBECONFIG=/Users/anandabhishe/gitlab/work2/kubeconfigs/scdc1-staging-hrwork-dev/kubeconfig.yaml:/Users/anandabhishe/gitlab/work2/kubeconfigs/scdc2-prod-hrwork-uat/kubeconfig.yaml:/Users/anandabhishe/gitlab/work2/kubeconfigs/scdc2-prod-hrwork/kubeconfig.yaml "
You can try something like that:
export KUBECONFIG=$(for i in $(find /Users/anandabhishe/gitlab/ -iname 'kubeconfig.yaml') ; do echo -n ":$i"; done | cut -c 2-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With