DevOps Blog - Nicolas Paris

Execute Command on Each Pod of a Kubernetes Deployment


Another very quick trick.

In this case, I want to setup the maintenance mode from Laravel on each pod in a Kubernetes cluster.
The idea is to list pods from a particular label, and execute command on each one with the following one liner command.

kubectl get po -l -o name  | xargs -I{} kubectl exec {} -- php artisan down