Show Menu

Kubernetes Platform Cheat Sheet (DRAFT) by

work in progress

This is a draft cheat sheet. It is a work in progress and is not finished yet.

K8 : Pod

Get list of namespaces
kubectl get ns
Get list of pods in a namespace
kubectl get pod -n [names­pace]
To get all running pods
kubectl get pods --fiel­d-s­ele­cto­r=s­tat­us.p­ha­se=­Running
Get list of services in a namespace
kubectl get svc -n [names­pace]
Get list of deployment in a namespace
kubectl get deployment -n [names­pace]
Get list of stateful set in a namespace
kubectl get sts -n [names­pace]
Get list of all resources in a namespace
kubectl get all -n [names­pace]
Get daemon list in namespace
kubectl get ds -n [names­pace]
To exec into a pod
kubectl exec -it [pod] -n [names­pace] sh
To get pod logs
kubectl logs -f [pod] -n [names­pace]
To get cpu and memory utiliz­ation of pod
kubectl top pod -n [names­pace]
Kill a pod
kubectl delete pod [pod] -n [names­pace] --force --grac­e-p­eriod=0
Copy data from pod
kubectl cp [names­pac­e]/­[po­dna­me]­:[f­ile­path] .

K8 : Helm 2

Get list of deployed Helm
helm ls
Deploy a helm
helm install [folde­rpath] -n [helmname] --name­space [names­pace]
Update a helm
helm upgrade -f [patht­ova­lue­s.yaml] [helmname] .
Delete a helm
helm delete --purge [helmname]


Get version of docker
docker version
Get inform­ation on docker
docker info
Pull image from registry
docker pull [image]
Run an image
docker run [image]
Run image and login to pod
docker run -it [image] /bin/bash
List images
docker images
docker images -q
sudo docker run -p 8080:8080 -p 50000:­50000 jenkins
sudo docker rmi 7a86f8­ffcb25
sudo docker inspect jenkins
docker ps
docker ps -a
sudo docker history centos
sudo docker top 9f215e­d0b0d3
sudo docker stop 9f215e­d0b0d3
sudo docker rm 9f215e­d0b0d3
sudo docker attach 07b0b6­f434fe
sudo docker pause 07b0b6­f434fe
sudo docker kill 07b0b6­f434fe

Linux : Setup password less login b/w hosts

Create key in source server
ssh-keygen -t rsa
Copy public key to target server
ssh-co­py-id target
Alternate : Copy content to .ssh/a­uth­ori­zed­_keys. 700 to .ssh 640 to author­ize­d_keys


To install a package
yum install firefox or yum -y install firefox
Install a package from Specific Repository
yum --enab­ler­epo­=epel install phpmyadmin
To remove a package completely with their all depend­encies
yum remove firefox or yum -y remove firefox
To update a installed package
yum update mysql
List a Package using YUM
yum list openssh
Search for a package using YUM
yum search vsftpd
Get Inform­ation of a Package using YUM
yum info firefox
To list all the available packages in the Yum database
yum list | less
List all Installed Packages using YUM
yum list installed | less
To know the name of the package that has the /etc/h­ttp­d/c­onf­/ht­tpd.conf
yum provides /etc/h­ttp­d/c­onf­/ht­tpd.conf
To find how many of installed packages on your system have updates available.
yum check-­update
Install all latest patches and security updates to your system
yum update
List all available Group Packages
yum grouplist
Install a Group Packages
yum groupi­nstall 'MySQL Database'
Update a Group Packages
yum groupu­pdate 'DNS Name Server'
Remove a Group Packages
yum groupr­emove 'DNS Name Server'
To list all enabled Yum reposi­tories in your system
yum repolist
List all Enabled and Disabled Yum Reposi­tories
yum repolist all
Intera­ctive Yum Shell
yum shell
Clean Yum Cache
yum clean all
To view all the past transa­ctions of yum command
yum history

K8 : Node

Display addresses of the master and services
kubectl cluste­r-info
Get list of nodes in cluster
kubectl get nodes
Get all details of a node
kubectl describe node [nodename]
Get vital details of node
kubectl describe node apollo­com­p23­|grep 'Taint­s:­\|cp­u\|­slave\| Hostna­me:­\|m­emory'
Taint a node
kubectl taint node [nodename] temp=t­emp­:No­Sch­edule
Untaint a node
kubectl taint node [nodename] temp-
Make a node unsche­dulable
kubectl cordon [nodename]
Make a node schedu­lable
kubectl uncordon [nodename]
Drain a node
kubectl drain [nodename]
Dump cluster state to file
kubectl cluste­r-info dump --outp­ut-­dir­ect­ory­=/h­ome­/cl­ust­er-­state

K8 : Volume

Create secret in storage
maprlogin password
Convert secret (/any text) to base64
echo -n "­[mapr password conten­t]" | base64
Get list of secrets in a namespace
kubectl get secret -n [names­pace]
Get list of PVC in a namespace
kubecrl get pvc -n [names­pace]
To get details of PV
kubectl describe pv [pvname]
Edit a PV
kubectl edit pv [pvname]
Detail details of mount
maprcli volume info -name insite­_bharti -columns volume­nam­e,u­sed­,to­tal­use­d,q­uot­a,a­dvi­sor­yquota
Create secret & Mount details - To be executed in storage node

Linux : Service Management

Check status of service
systemctl status [service name]
Start a service
systemctl start [service name]
Stop a service
systemctl stop [service name]
enable a service and start now
systemctl enable [service name] --now
disable a service and stop now
systemctl disable [service name] --now
check service logs
journalctl -xe


Get version of git
git --version
Initialize local git repo in a folder
git init
Add files to index
git add file1 file2
Other add option
All: git add . All match: *.sh
Remove file from tracking
git rm --cached file1
Check status of working tree
git status
Commit the changes
git commit -m 'new change'
Set remote repo
Push to remote repo
git push -u origin master
Pull lates from repo
'git pull'
Clone a repo to local (with login)
git clone git@gi­thu­­k/r­obo­t-f­ram­ewo­rk-­doc­ker.git
clone a repo to local (without login)
git clone git@gi­thu­­k/r­obo­t-f­ram­ewo­rk-­doc­ker.git
Set user name
git config 'abcd'
Set user email
git config 'abc@d­'
Blacklist files
Create .gitignore file and add exeception list in it

Linux Commands

List directory including hidden file
ls -la
Size of each folder­/file in currect directory
du -d 1 -h
Create directory
mkdir [dirname]
Rename directory
mv [dirname] [newname]
Copy directory
cp -r [dirname] [newname]
Remove directory
rm -rf [dir1] [dir2]
Create a file
touch [filename]
Edit file
vi [filename]
Create 1 GB file unreadable content
dd if=/de­v/zero of=fil­e.txt count=1024 bs=1048576
Create 2 GB file readable content
dd if=/de­v/u­random of=fil­e2.txt bs=2048 count=­1000000