echo -e ‘\nsource <(kubectl completion bash)\n’ >> ~/.bashrc
sudo kubeadm init —pod-network-cidr=10.244.0.0/16
sudo kubeadm join 172.31.4.94:6443 —token s99adr.q3wjstujf1rjceun \
kubectl get all -A
kubectl get node
kubectl get namespace # or kubectl get ns
kubectl get pod -n kube-system
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubectl get pod -n kube-system kubectl get node
kubectl describe nodes ip-master kubectl describe nodes ip-node1 kubectl describe nodes ip-node2
kubectl get pod -n kube-system -o wide kubectl logs -n kube-system <pod>
kubectl get roles.rbac.authorization.k8s.io -A
kubectl get clusterrole -A kubectl describe clusterrole admin
kubectl get serviceaccount kubectl describe serviceaccounts default kubectl create serviceaccount -o yaml —dry-run
Produce an yaml:
kubectl run myfirstpod --image=nginx:1.19 --dry-run -o yaml > myfirst.yaml
Trim yaml:
~/myfirstpod
apiVersion: v1
kind: Pod
metadata:
labels:
run: myfirstpod
name: myfirstpod
spec:
containers:
- image: nginx:1.19
name: myfirstpod
kubectl apply -f myfirstpod.yaml
kubectl run myfirstpod —image=nginx:1.19
kubectl describe pod myfirstpod
kubectl describe pod # all pods in default
ns
kubectl get pod myfirstpod -o yaml
kubectl delete pod myfirstpod
kubectl exec -it myfirstpod — bash
sample: lab/01b-two-container.yaml …
kubectl create service clusterip <name> <port>:<targetPort> —dry-runner then edit & apply
kubectl get endpoints
apiVersion: v1
kind: Service
metadata: name: svc-frontend
spec: ports: - name: 80-80
port: 80
protocol: TCP
targetPort: 80
selector:
app: svc-frontend
type: ClusterIP
file: 11a-ngnix-…
kubectl rollout status deployment nginx
kubectl rollout history deployment nginx
kubectl rollout history deployment --revision=3
kubectl rollout undo deployment nginx --to-revision 1
file: 11b-ngnix-…
kubectl apply -f 11b-nginx-deploy-service.yaml
kubectl get pod --show-labels
kubectl get service
kubectl describe service servicenginx
file: 10-quota.yaml prometheus.io
statefulset
(not deployment
)
Rendering context...