1. Some Script to do easy KUBERNETES administration
top_pods.sh
#!/bin/bash
#
#Pod List in the ENV
echo "#################################"
echo "#PODs List that you can select #"
echo "#################################"
kubectl get pods | awk '{print $1}'
#Select the pod to check
echo "#######################"
echo "#Select Pods to check #"
echo "#######################"
echo "Input PodName: "
read podname
echo "##############################"
echo "#CPU and Memory information #"
echo "##############################"
# Screen validation for consuming CPU and Memory
kubectl top pod $podname --sort-by=cpu
oomskill_check.sh
#!/bin/bash
#
#Pod List in the ENV
echo "#################################"
echo "#PODs List that you can select #"
echo "#################################"
kubectl get pods | awk '{print $1}'
#Select the pod to check
echo "#######################"
echo "#Select Pods to check #"
echo "#######################"
echo "Input PodName: "
read podname
echo "#######################"
echo "#OMMKill information #"
echo "#######################"
# Screen validation OOMkill
kubectl describe pod $podname
pod_shell_connection.sh
#!/bin/bash
#
#Pod List in the ENV
echo "#################################"
echo "#PODs List that you can select #"
echo "#################################"
echo ""
kubectl get pods | awk '{print $1}'
#Select the pod to check
echo "##########################"
echo "#Select POD to connect #"
echo "##########################"
echo "Input PodName: "
read podname
echo ""
echo "Select shell to work"
echo "###############################"
echo "# /bin/bash or /bin/sh #"
echo "###############################"
echo "Input Shell: "
read shell
echo ""
echo "###############################"
echo "#Connecting to Pod .... #"
echo "###############################"
# Pod shell connection
kubectl exec -ti $podname -- $shell
Consume_cpu_memory
#/bin/bash
echo "####### APPLICATION NAME ##########"
echo "Creating Pods List podsappname.txt"
echo ""
kubectl get pods | grep <pods_app> | awk '{print $1}' > /home/podsappname.txt
echo "Validate how many pods are available"
echo ""
kubectl get pods | grep <pods_app> | awk '{print $1}' | wc -l
echo "Currently Consume by CPU and Memory"
echo ""
for i in `/usr/bin/cat /home/ppodsappname.txt`; do kubectl top pod $i --sort-by=cpu; done
echo ""
echo "Deleting Pods podsappname.txt file list created podsappname.txt"
rm /home/podsappname.txt
Comments