1. cluster
- a set of nodes
- one master node and many worker nodes
2. ingress/svc/pod
- ingress: route external traffic into cluster, rule based
- svc: like a load balancer
- pod by default is internal within cluster, need to expose as svc to outside
- kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4
- kubectl expose deployment hello-node --type=LoadBalancer --port=8080
3. deployment: blueprint to create pod
- cluster contains nodes (worker) and control plane
- node contains pods
4. kubectl
- similar to aws cli
5. context
- a context contains a cluster, a user and a namespace
- all kubectl cmd runs against current context/cluster
6. manifest yaml/helm/helm charts
- manifest yaml is used to create/modify/delete pod/deployment/svc/ingress
- helm is package manager for k8, can install package like yum/apt/brew
7. kubectl commands
- kubectl config view //show all clusters and contexts
- kubectl config get-contexts //use this instead of above
- kubectl config use-context <context-name> //switch context
- kubectl config current-context
- kubectl config set-context --current --namespace=<namespace> //switch namespace
- kubectl config view --minify | grep namespace //get current namespace
- kubectl config unset users.user1 //delete user from config
- kubectl config unset contexts.context1 //delete context from config
- kubectl config unset clusters.cluster1 //delete cluster
- kubectl get pods
- kubectl describe pod xxx
- kubectl logs pod_name //display std log of pod
- kubectl exec pod_name -- env //exec env cmd on pod
- kubectl exec -ti pod_name -- bash
- kubectl get svc
- kubectl describe svc xxx
- kubectl get nodes -o wide //all nodes in cluster
- kubectl get deployments
- kubectl describe deployment xxx
8. kubectx/kubens tool
- kubectx //show all contexts
- kubectx ctx1 //switch context
- kubens //show all ns
- kubens ns1 //switch ns
reference