Just some random commands that may help a lot..
Create aliases to be faster
alias ll='ls -l’Curl:
- curl -k (allow insecure)
- curl -v (verbose)
grep recursively (usefull for troubleshooting):
grep -r "searchTerm" /path/to/directorygrep OR / AND:
grep -E “this|orThis”
grep "error" logfile.txt | grep "database"netstat: list active network connections and listening ports
sudo netstat -tulnSee permission of a file (numeric) :
stat -c "%a"Checksum
sha512sum file.txtSee extended information about pods:
kubectl get pods -o wideSee short name of a resource:
kubectl api-resourcesExplain a resource and its fields:
kubectl explain <resource>create a simple pod with a single container:
kubectl run mypod --image=nginxExec bash into a container:
kubectl exec -it mypod -- bashExec a command into a container:
kubectl exec -it POD_NAME_2 -- stress --cpu 1 &Note: & is used to run the command in the background, so you can continue using the terminal.
Create a pod to only execute a command and exit:
kubectl run mypod --rm -it --image=busybox:1 --restart=Never -- shSecret values must be base64 encoded when editing the Secret directly.
echo -n "db.internal" | base64Podman:
podman build -t registry.killer.sh:5000/image-verify:v2 .
podman run registry.killer.sh:5000/image-verify:v2 # to test your changes
podman push registry.killer.sh:5000/image-verify:v2
Check user RBAC
k auth can-i list secret --as giannaHow add a command into a pod:
command: ["/bin/sh", "-c", "echo aba997ac-1c89-4d64 > /mount/config && sleep infinity"](if there is one to remember, this is the one, it will cover the other cases)
command: ["sleep", "10"]command: ["echo"] # executed command
args: ["Hello, World"] # argumentscommand: ["/bin/sh", "-c"]
args: ["echo 'Nginx Started'; nginx -g 'daemon off;'"]grep all image used in a namespace / in a deployment
k get pods -n nato -o yaml | grep "image: "
k get deploy xym -o yaml | grep "image: "Get all field of a security context:
kubectl explain pod.spec.securityContext --recursiveCrictl: interacting with Container Runtime Interface (CRI)-compatible container runtimes
# show all containers, including stopped ones
crictl ps -a
crictl inspect <container id>add label to a pod during creation:
kubectl run mypod --image=nginx --labels="app=myapp,env=dev"
kubectl run mypod --image=nginx -l app=myapp,env=dev