Running kubectl commands on multiple clusters
?? Managing multiple Kubernetes clusters can be a real headache. I know firsthand how frustrating it can be to juggle multiple contexts, keep deployments consistent, and maintain stability across different environments.
so I found this awesome repo : https://github.com/ahmetb/kubectl-foreach
Run a kubectl command in one or more contexts (clusters) in parallel (similar to GNU parallel/xargs).
Usage
kubectl foreach [OPTIONS] [PATTERN]... -- [KUBECTL_ARGS...]
and created a small helper function to use it It's a simple way to run kubectl commands across multiple clusters in one go, making life a bit easier.
Here's the function you can add to your bashrc or zshconfig
function kfe() { eval "kubectl foreach -q dc1 dc2 dc3 -- $*"}
Just use kfe followed by your kubectl command, for example :
kfe get pods
and it will execute across dc1, dc2, and dc3 without any hassle. No more repetitive tasks or constant context switching – just a smoother workflow.
I hope this helps lighten the load for anyone dealing with the complexities of Kubernetes. We're all in this together, and sharing little tools like this can make a big difference.
#Kubernetes #DevOps #Automation #TechSupport #CloudComputing
Creator of tellspin.app | L2 Rotations in Slack | Principal Software Engineer at Jump
3 个月Oh neat! I'm always playing around with chatgpt and xargs trying to do something similar, this looks easier ??
Senior HRBP at Tarya Fintech
3 个月How great are you ??
DevOps Engineer at Granulate
3 个月Nice though risky ??
Great tip!
Senior DevOps at Seemplicity
3 个月Looks cool, thanks for sharing! #sharingIsCaring