curl http://169.254.169.254/latest/dynamic/instance-identity/document
Last active
November 5, 2023 23:40
-
-
Save thetillhoff/e19ffed34f4b441ed8b598087b74a7da to your computer and use it in GitHub Desktop.
devops cheat sheet
git tag <tag>
git push origin <tag> # single tag
git push --tags # all tags
# local tag only
git tag -d <tag>
# remote tag only
git push --delete origin <tag>
git fetch --prune # delete branches locally if they don't exist on remote
git fetch --prune-tags # delete tags locally if they don't exist on remote
git fetch --prune --prune-tags # delete branches and tags locally if they don't exist on remote
kubectl config view
kubectl api-resources
kubectl get all -A
kubectl get all,cm,secret,ing -A
kubectl get <resource> [<name>] -o wide # also shows ip of pods
kubectl describe <resource> [<name>] # also shows latest events like scaling
kubectl logs <podname>
kubectl exec <podname> -- <command> # non-interactive!
kubectl exec -ti <podname> -- <command> # interactive, -ti == --stdin --tty
kubectl top node <nodename> # Show metrics for a given node
kubectl get pods -l app=kubernetes-bootcamp
kubectl get services -l app=kubernetes-bootcamp
kubectl label pods <podname> version=v1
kubectl expose deployment/<name> --type="NodePort" --port 8080
kubectl delete service -l app=kubernetes-bootcamp
kubectl scale deployments/kubernetes-bootcamp --replicas=4
kubectl delete pods --field-selector status.phase=Failed -A
kubectl get service <service-name> --output='jsonpath="{.spec.ports[0].nodePort}"'
kubectl port-forward <container-id> <local-port>:<container-port>
kubectl exec <pod-name> -- ls /
kubectl exec <pod-name> -c <container-name> -- ls /
kubectl exec -it <pod-name> -- /bin/sh
kubectl top pod <pod-name> --sort-by=cpu
kubectl -n kube-system get secret
kubectl -n kube-system describe secret deployment-controller-token-*
kubectl rollout restart deployment/<deployment-name>
kubectl get node --selector='!node-role.kubernetes.io/master'
First get the resource that is blocking the deletetion
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <terminating-namespace>
kubectl get pod <pod-name> -o jsonpath="{.spec.containers[*].name}"
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found
(via k8s internal DNS, FQDN for that is kube-dns.kube-system.svc.cluster.local
)
servicename.namespace.svc.cluster.local
ping -c 4 <destination>
tags: storage, size, space
du -shx <path>/* 2>/dev/null
# sorted, top 5:
du -shx <path>/* 2>/dev/null | sort -rh | head -n 5
sync; echo 3 > /proc/sys/vm/drop_caches
lsblk
lsblk -a # all devices (rarely a difference)
lsblk -f # show filesystem for each device
(In human readable format)
df -h
(In human readable format)
free -h
The first column is the memory in percent
ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5
Choose command depending on your linux system
sudo systemd-resolve --flush-caches # ubuntu, debian
netstat -tulpn
find . -name abc.txt -maxdepth 5 # implicitly recursive
curl -fsSL <key-url> | gpg --dearmor --yes -o /usr/share/keyrings/<filename>.gpg
OR
wget -O- | gpg --dearmor > /usr/share/keyrings/<filename>.gpg
echo "<repo-url>" > /etc/apt/sources.list.d/<filename>.list
ssh-keygen -R <hostname>
(/tmp
is deleted on reboots, so this is most useful for servers that are rarely rebooted)
sudo find /tmp -type f -atime +10 -delete
${SOMEVARIABLE##*/}
lsblk
lsblk -f # this also prints the filesystems on the devices
truncate -s 0 /var/log/syslog
lsof | awk '{ print "- name: " $1 " pid: " $2; }' | uniq -c | sort -rn | head
nslookup <domain>
or
dig <domain> +short
or
dig <domain> <type> +short
or
dig <domain <type> +short
or
dig @<DNS server> <domain> +short
dig NS <domain>
cat /etc/passwd
<user>:x:<uid>:<gid>::<homedir>:<console>
tar -czf <filename>.tar.gz <path/to/folder>
tar -xf <filename>.tar.gz
apt install -y \
curl \
wget \
nano \
# for nslookup,dig:
dnsutils \
# for ping:
iputils-ping \
# for ifconfig:
net-tools \
# for ps,top:
procps
rsync -ah --info=progress2 <source> <destination>
rsync -ah --info=progress2 --delete <source> <destination>
# -a stands for archive and will preserve permissions, timestamps, ...
# -h stands for human readable values
# --info=progress2 will display progress over all files, instead of per file
cp ./{some/where.a,some/where/else.b,$variablelocation/c.d} ./destination/
# or simply
cp ./some/where.a ./some/where/else.b $variablelocation/c.d ./destination/
ipconfig /flushdns
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |Format-Table -AutoSize
Get-AppxPackage | Select-Object Name, PackageFullName, Version |Format-Table
-AutoSize
shutdown -s -t <seconds>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment