This is a draft cheat sheet. It is a work in progress and is not finished yet.
K8 : Pod
Get list of namespaces |
|
Get list of pods in a namespace |
kubectl get pod -n [namespace]
|
To get all running pods |
kubectl get pods --field-selector=status.phase=Running
|
Get list of services in a namespace |
kubectl get svc -n [namespace]
|
Get list of deployment in a namespace |
kubectl get deployment -n [namespace]
|
Get list of stateful set in a namespace |
kubectl get sts -n [namespace]
|
Get list of all resources in a namespace |
kubectl get all -n [namespace]
|
Get daemon list in namespace |
kubectl get ds -n [namespace]
|
To exec into a pod |
kubectl exec -it [pod] -n [namespace] sh
|
To get pod logs |
kubectl logs -f [pod] -n [namespace]
|
To get cpu and memory utilization of pod |
kubectl top pod -n [namespace]
|
Kill a pod |
kubectl delete pod [pod] -n [namespace] --force --grace-period=0
|
Copy data from pod |
kubectl cp [namespace]/[podname]:[filepath] .
|
--show-labels
--all-namespaces
--sort-by=.spec.capacity
K8 : Helm 2
Get list of deployed Helm |
|
Deploy a helm |
helm install [folderpath] -n [helmname] --namespace [namespace]
|
Update a helm |
helm upgrade -f [pathtovalues.yaml] [helmname] .
|
Delete a helm |
helm delete --purge [helmname]
|
Docker
Get version of docker |
|
Get information on docker |
|
Pull image from registry |
|
Run an image |
|
Run image and login to pod |
docker run -it [image] /bin/bash
|
List images |
|
|
|
sudo docker run -p 8080:8080 -p 50000:50000 jenkins
sudo docker rmi 7a86f8ffcb25
sudo docker inspect jenkins
docker ps
docker ps -a
sudo docker history centos
sudo docker top 9f215ed0b0d3
sudo docker stop 9f215ed0b0d3
sudo docker rm 9f215ed0b0d3
sudo docker attach 07b0b6f434fe
sudo docker pause 07b0b6f434fe
sudo docker kill 07b0b6f434fe
Linux : Setup password less login b/w hosts
Create key in source server |
|
Copy public key to target server |
|
Alternate : Copy id_rsa.pub content to .ssh/authorized_keys. 700 to .ssh 640 to authorized_keys
LINUX : YUM
To install a package |
yum install firefox
or yum -y install firefox
|
Install a package from Specific Repository |
yum --enablerepo=epel install phpmyadmin
|
To remove a package completely with their all dependencies |
yum remove firefox
or yum -y remove firefox
|
To update a installed package |
|
List a Package using YUM |
|
Search for a package using YUM |
|
Get Information of a Package using YUM |
|
To list all the available packages in the Yum database |
|
List all Installed Packages using YUM |
yum list installed | less
|
To know the name of the package that has the /etc/httpd/conf/httpd.conf |
yum provides /etc/httpd/conf/httpd.conf
|
To find how many of installed packages on your system have updates available. |
|
Install all latest patches and security updates to your system |
|
List all available Group Packages |
|
Install a Group Packages |
yum groupinstall 'MySQL Database'
|
Update a Group Packages |
yum groupupdate 'DNS Name Server'
|
Remove a Group Packages |
yum groupremove 'DNS Name Server'
|
To list all enabled Yum repositories in your system |
|
List all Enabled and Disabled Yum Repositories |
|
Interactive Yum Shell |
|
Clean Yum Cache |
|
To view all the past transactions of yum command |
|
|
|
K8 : Node
Display addresses of the master and services |
|
Get list of nodes in cluster |
|
Get all details of a node |
kubectl describe node [nodename]
|
Get vital details of node |
kubectl describe node apollocomp23|grep 'Taints:\|cpu\|slave\| Hostname:\|memory'
|
Taint a node |
kubectl taint node [nodename] temp=temp:NoSchedule
|
Untaint a node |
kubectl taint node [nodename] temp-
|
Make a node unschedulable |
kubectl cordon [nodename]
|
Make a node schedulable |
kubectl uncordon [nodename]
|
Drain a node |
|
Dump cluster state to file |
kubectl cluster-info dump --output-directory=/home/cluster-state
|
Display node type |
kubectl get nodes -o json|jq -Cjr '.items[] | .metadata.name," ",.metadata.labels."beta.kubernetes.io/instance-type"," ",.metadata.labels."beta.kubernetes.io/arch", "\n"'|sort -k3 -r
|
K8 : Volume
Create secret in storage |
|
Convert secret (/any text) to base64 |
echo -n "[mapr password content]" | base64
|
Get list of secrets in a namespace |
kubectl get secret -n [namespace]
|
Get list of PVC in a namespace |
kubecrl get pvc -n [namespace]
|
To get details of PV |
kubectl describe pv [pvname]
|
Edit a PV |
|
Detail details of mount |
maprcli volume info -name insite_bharti -columns volumename,used,totalused,quota,advisoryquota
|
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 |
|
GIT
Get version of git |
|
Initialize local git repo in a folder |
|
Add files to index |
|
Other add option |
All: git add .
All match: *.sh
|
Remove file from tracking |
|
Check status of working tree |
|
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) |
|
clone a repo to local (without login) |
|
Set user name |
git config user.name 'abcd'
|
Set user email |
git config user.email 'abc@def.com'
|
Blacklist files |
Create .gitignore
file and add exeception list in it |
Linux Commands
List directory including hidden file |
|
Size of each folder/file in currect directory |
|
Create directory |
|
Rename directory |
|
Copy directory |
cp -r [dirname] [newname]
|
Remove directory |
|
Create a file |
|
Edit file |
|
Create 1 GB file unreadable content |
dd if=/dev/zero of=file.txt count=1024 bs=1048576
|
Create 2 GB file readable content |
dd if=/dev/urandom of=file2.txt bs=2048 count=1000000
|
|