My K8S Kubernetes playground 🚀
$ yum update -y Download yum repo file of the Rancher Desktop:
$ curl https://download.opensuse.org/repositories/isv:/Rancher:/stable/rpm/isv:Rancher:stable.repo -o /etc/yum.repos.d/_rancher-desktop.repo Install Fedora virtualizations drivers:
$ dnf install @virtualization -y
$ dnf group install --with-optional virtualization
$ systemctl start libvirtd
$ systemctl enable libvirtdUpdate yum cache
$ yum makecacheInstall rancher-desktop
$ yum install rancher-desktopList contexts
kubectl kubecconfig get-contextsChange context
kubectx <context-name>Get nodes
kubectl get nodesGet more information
kubectl get nodes -o json -o wideGet value with JSONPath sytax
kubectl get nodes minikube -o jsonpath --template={.spec.podCIDR} Resource hot edit
kubectl edit <resource> <object-name>Resources label
kubectl label pods bar color=red
kubectl label pods bar color=blue --overwrite
kubectl label pods bar color-List containers in POD
kubectl get pods <pod-name> -o jsonpath='{.spec.containers[*].name}'View container log in POD
kubectl logs <pod-name> -c <container-name> -fExec command in containers
kubectl exec -it <pod-name> -- bashFollow main process in POD (like logs, but with stdin available)
kubectl attach -it <pod-name>Copy files to and from pod
kubectl <pod-name>:/var/local/xtpo /home/user/Expose POD ports
kubectl port-forward <pod-name> 8080:80 Expose SERVICE ports
kubectl port-forward services/<service-name> Get ReplicaSet details
kubectl describe rs kuardCheck POD owner references
kubectl get pods <pod> -o yaml | grep -A 10 ownerReferencesScale Replicas (imperative way)
kubectl scale replicaset <replicaset> --replicas=4 Enable Autoscale (HPA), 2..5 replicas by 80% cpu usage
kubectl autoscale rs kuard --min=2 --max=5 --cpu-percent=80Get deployment labels
kubectl get deployments kuard -o jsonpath --template {.spec.selector.matchLabels}Filter Replica Set by label
kubectl get replicasets -l run=kuardBackup deployment
kubectl get deployment <deployment-name> -o yaml > bkp-deploy.yaml
kubectl replace -f <deployment-file .yml> --save-configGet rollout history
kubectl rollout history deployment kuard To add change cause, add value to
spec.template.metadata.annotations.kubernetes.io/change-cause
Get rollout informations of the specific version
kubectl rollout history deployment kuard --revision=2Undo rollout
kubectl rollout undo deployments kuardRollout to specific version
kubectl rollout undo deployment kuard --to-revision=3