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

Dan Willoughby

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 ??

Liat Azar Liav

Senior HRBP at Tarya Fintech

3 个月

How great are you ??

回复
Roi Koren

DevOps Engineer at Granulate

3 个月

Nice though risky ??

回复
Joe Tavin

Senior DevOps at Seemplicity

3 个月

Looks cool, thanks for sharing! #sharingIsCaring

要查看或添加评论,请登录

社区洞察

其他会员也浏览了