Manuel Santi
Manuel Santi

Reputation: 1132

Kubernetes replicate pod modification to other pods

I have a k8s cluster with 3 nodes. With kubectl command i enter in a pod shell and make some file editing:

kubectl exec --stdin --tty <pod-name> -- /bin/bash

at this point i have one pod wit correct editing and other 2 replicas with old file. My question is: There is a kubectl commend for, starting from a specific pod, overwrite current replicas in cluster for create n equals pods?

Hope to be clear

So many thanks in advance Manuel

Upvotes: 0

Views: 157

Answers (1)

matt_j
matt_j

Reputation: 4614

You can use a kubectl plugin called: kubectl-tmux-exec.
All information on how to install and use this plugin can be found on GitHub: predatorray/kubectl-tmux-exec.

As described in the How to Install Dependencies documentation.

The plugin needs the following programs:

  • gnu-getopt(1)
  • tmux(1)

I've created a simple example to illustrate you how it works.

Suppose I have a web Deployment and want to create a sample-file file inside all (3) replicas.

$ kubectl get deployment,pods --show-labels
NAME                  READY   UP-TO-DATE   AVAILABLE   AGE   LABELS
deployment.apps/web   3/3     3            3           19m   app=web

NAME                      READY   STATUS    RESTARTS   AGE   LABELS
pod/web-96d5df5c8-5gn8x   1/1     Running   0          19m   app=web,pod-template-hash=96d5df5c8
pod/web-96d5df5c8-95r4c   1/1     Running   0          19m   app=web,pod-template-hash=96d5df5c8
pod/web-96d5df5c8-wc9k5   1/1     Running   0          19m   app=web,pod-template-hash=96d5df5c8

I have the kubectl-tmux_exec plugin installed, so I can use it:

$ kubectl plugin list
The following compatible plugins are available:

/usr/local/bin/kubectl-tmux_exec


$ kubectl tmux-exec -l app=web bash

After running the above command, Tmux will be opened and we can modify multiple Pods simultaneously:

enter image description here

Upvotes: 1

Related Questions