All Projects → rajatjindal → kubectl-evict-pod

rajatjindal / kubectl-evict-pod

Licence: Apache-2.0 license
This plugin evicts the given pod and is useful for testing pod disruption budget rules

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to kubectl-evict-pod

kube-lineage
A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.
Stars: ✭ 238 (+366.67%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-iexec
Kubectl plugin to interactively exec into a pod
Stars: ✭ 102 (+100%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-external-forward
kubectl plugin to connect to external host via Envoy Proxy in Kubernetes cluster
Stars: ✭ 37 (-27.45%)
Mutual labels:  kubectl, kubectl-plugins
Kubectl Tree
kubectl plugin to browse Kubernetes object hierarchies as a tree 🎄 (star the repo if you are using)
Stars: ✭ 1,962 (+3747.06%)
Mutual labels:  kubectl, kubectl-plugins
Kubectl Debug
Debug your pod by a new container with every troubleshooting tools pre-installed
Stars: ✭ 2,091 (+4000%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-janitor
List Kubernetes objects in a problematic state
Stars: ✭ 48 (-5.88%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-extras
A collection of mini plugins for kubectl.
Stars: ✭ 109 (+113.73%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-ctx
Simple kubectl plugin to display/switch contexts
Stars: ✭ 36 (-29.41%)
Mutual labels:  kubectl, kubectl-plugins
KuiClientTemplate
Use this template to make your own custom graphical terminal, via the Kui Grahpical CLI Framework
Stars: ✭ 26 (-49.02%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-view-serviceaccount-kubeconfig-plugin
A kubectl plugin that show a kubeconfig to access the apiserver with a specified serviceaccount.
Stars: ✭ 33 (-35.29%)
Mutual labels:  kubectl, kubectl-plugins
kubectlsafe
Safe operations in kubectl with plugin kubectlsafe
Stars: ✭ 36 (-29.41%)
Mutual labels:  kubectl, kubectl-plugins
Krew
📦 Find and install kubectl plugins
Stars: ✭ 4,354 (+8437.25%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-whoami
This plugin gets the subject name using the effective kubeconfig
Stars: ✭ 74 (+45.1%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-secretdata
A kubectl plugin for viewing decoded Secret data with search flags.
Stars: ✭ 37 (-27.45%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-ns
Simple kubectl plugin to display/switch namespaces
Stars: ✭ 20 (-60.78%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-skew
a simple kubectl plugin to make the "skew" visible
Stars: ✭ 18 (-64.71%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-tmux-logs
A kubectl plugin to display container logs within separate tmux panes
Stars: ✭ 19 (-62.75%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-plugin-ssh-jump
A kubectl plugin to access nodes or remote services using a SSH jump Pod
Stars: ✭ 117 (+129.41%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-images
🕸 Show container images used in the cluster.
Stars: ✭ 153 (+200%)
Mutual labels:  kubectl, kubectl-plugins
kubectl-gs
kubectl plugin helping with custom resources by Giant Swarm
Stars: ✭ 36 (-29.41%)
Mutual labels:  kubectl, kubectl-plugins

kubectl-evict-pod

This plugin evicts the given pod. useful for testing pod disruption budget rules

Usage

Pod evicted successfully scenario

# before running the evict-pod command
$ kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-fb8b8dccf-6wvj6            1/1     Running   0          10m
coredns-fb8b8dccf-826fh            1/1     Running   0          9m55s
etcd-minikube                      1/1     Running   3          27d
kube-addon-manager-minikube        1/1     Running   13         27d
kube-apiserver-minikube            1/1     Running   3          27d
kube-controller-manager-minikube   1/1     Running   0          9h
kube-proxy-cwwm8                   1/1     Running   3          27d
kube-scheduler-minikube            1/1     Running   5          27d
storage-provisioner                1/1     Running   6          27d

# now lets evict the coredns pod
$ ./kubectl-evict-pod coredns-fb8b8dccf-6wvj6 -n kube-system
INFO[0000] pod "coredns-fb8b8dccf-6wvj6" in namespace kube-system evicted successfully 

# observe that the pod has been evicted successfully
$ kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-fb8b8dccf-7ngmk            1/1     Running   0          42s
coredns-fb8b8dccf-826fh            1/1     Running   0          11m
etcd-minikube                      1/1     Running   3          27d
kube-addon-manager-minikube        1/1     Running   13         27d
kube-apiserver-minikube            1/1     Running   3          27d
kube-controller-manager-minikube   1/1     Running   0          9h
kube-proxy-cwwm8                   1/1     Running   3          27d
kube-scheduler-minikube            1/1     Running   5          27d
storage-provisioner                1/1     Running   6          27d

pod eviction prevented by pod disruption budget

  • create the pod disruption budget using following spec
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: coredns-pdb
spec:
  minAvailable: 2
  selector:
    matchLabels:
      k8s-app: kube-dns
  • apply the pod disruption budget to the cluster
# lets apply the pod disruption budget
$ kubectl apply -f pdb.yaml -n kube-system
poddisruptionbudget.policy/coredns-pdb created
  • Now lets try to evict the pods again
# get existing pods
$ kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-fb8b8dccf-7ngmk            1/1     Running   0          4m6s
coredns-fb8b8dccf-826fh            1/1     Running   0          14m
etcd-minikube                      1/1     Running   3          27d
kube-addon-manager-minikube        1/1     Running   13         27d
kube-apiserver-minikube            1/1     Running   3          27d
kube-controller-manager-minikube   1/1     Running   0          9h
kube-proxy-cwwm8                   1/1     Running   3          27d
kube-scheduler-minikube            1/1     Running   5          27d
storage-provisioner                1/1     Running   6          27d

# now lets try to evict the pod again
$ ./kubectl-evict-pod coredns-fb8b8dccf-826fh -n kube-system
Error: Cannot evict pod as it would violate the pod\'s disruption budget.
exit status 1

# observe pods continue to run
$ kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-fb8b8dccf-7ngmk            1/1     Running   0          10m
coredns-fb8b8dccf-826fh            1/1     Running   0          21m
etcd-minikube                      1/1     Running   3          27d
kube-addon-manager-minikube        1/1     Running   13         27d
kube-apiserver-minikube            1/1     Running   3          27d
kube-controller-manager-minikube   1/1     Running   0          9h
kube-proxy-cwwm8                   1/1     Running   3          27d
kube-scheduler-minikube            1/1     Running   5          27d
storage-provisioner                1/1     Running   6          27d
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].