This is a draft cheat sheet. It is a work in progress and is not finished yet.
K8 : PodGet list of namespaces | kubectl get ns
| 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 2Get list of deployed Helm | helm ls
| 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]
|
DockerGet version of docker | docker version
| Get information 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 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 hostsCreate key in source server | ssh-keygen -t rsa
| Copy public key to target server | ssh-copy-id target
|
Alternate : Copy id_rsa.pub content to .ssh/authorized_keys. 700 to .ssh 640 to authorized_keys
LINUX : YUMTo 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 | yum update mysql
| List a Package using YUM | yum list openssh
| Search for a package using YUM | yum search vsftpd
| Get Information 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/httpd/conf/httpd.conf | yum provides /etc/httpd/conf/httpd.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 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 | yum repolist
| List all Enabled and Disabled Yum Repositories | yum repolist all
| Interactive Yum Shell | yum shell
| Clean Yum Cache | yum clean all
| To view all the past transactions of yum command | yum history
|
| | K8 : NodeDisplay addresses of the master and services | kubectl cluster-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 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 | kubectl drain [nodename]
| Dump cluster state to file | kubectl cluster-info dump --output-directory=/home/cluster-state
|
K8 : VolumeCreate secret in storage | maprlogin password
| 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 | kubectl edit pv [pvname]
| 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 ManagementCheck 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
|
GITGet 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) | | 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 CommandsList 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=/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
|
|