Amazon Ad

Featured Post

Friday, June 21, 2019

Kubernetes Cheatsheet - Most Useful Commands in One Place


Overview

The following is the most concise Kubernetes/K3S/K8S commands list.

General

kubectl create secret generic --from-literal=password=test123
kubectl get secrets

Pods & Nodes

kubectl get nodes
kubectl describe nodes
kubectl apply -f yml
kubectl get deploy
kubectl get pods -o wide
kubectl exec -it node bash
kubectl get svc —watch

kubectl version -o yaml
kubectl get rs
kubectl rollout status
Kubectl rollout History
kubectl apply —record=true

Install inside nodes for basic networking stuff:


apt-get install iputils-ping curl dnsutils iproute2 -y

Docker related

docker image build -t name something/something:0.1
docker image ls
docker login
docker image push image name

Storage related

kubectl get sc
kubectl describe sc
kubectl get pvc
kubectl get pv
kubectl describe pv


Scaling

kubectl get hpa
kubectl get clusterrolebindings
kubectl get ns

Certificates

openssl genrsa -out mia.key 2048
openssl req -new -key Mia.key -out Mia.csr -subj “/CN=Mia/O=orgname”
convert to .crt
OpenSSL x509 -req -in Mia.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out Mia.crt -days 365
kubectl config set-credentials mia —client-certificate=mia.crt —client-key=mia.key

Logins:

kubectl config set-context mia —cluster=clustername —namespace=ns1 —user=mia

kubectl use-context mia
kubectl config current-context

No comments: