Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INSTALLING HA KUBERNETES CLUSTER
- ### AS ROOT
- 1 yum install -y git vim
- 2 ip a
- 3 ping nu.nl
- 4 ping 8.8.8.8
- 5 ip route show
- 6 ping nu.nl
- 7 vim /etc/hosts
- 8 yum install -y git vim
- 9 vim /etc/hosts
- 10 scp /etc/hosts control2:/etc/hosts
- 11 scp /etc/hosts control3:/etc/hosts
- 12 git clone https://github.com/sandervanvugt/cka
- 13 cd cka
- 14 ls *sh
- 15 ./setup-container.sh
- 16 ./setup-kubetools.sh
- 17 grep '4.100' *
- 18 vim check_apiserver.sh
- 19 vim keepalived.conf
- 20 ./setup-lb.sh
- 21 kubeadm init --control-plane-endpoint "192.168.29.100:8443" --upload-certs
- 22 vim /etc/hosts
- 23 scp /etc/hosts control3:/etc/hosts
- 24 scp /etc/hosts control2:/etc/hosts
- 25 vim /tmp/hatodo.txt
- 26 cat /tmp/hatodo.txt
- 27 history
- 28 cat /tmp/hatodo.txt
- 29 su - student
- 30 history
- ### as non-root
- 1 mkdir .kube
- 2 cp -i /etc/kubernetes/admin.conf .kube/config
- 3 sudo cp -i /etc/kubernetes/admin.conf .kube/config
- 4 cat /tmp/hatodo.txt
- 5 sudo chown student:student .kube/config
- 6 ls -l .kube/config
- 7 kubectl get all
- 8 kubectl apply -f https://docs.projectcalico.org/latest/manifests/calico.yaml
- 9 cat /tmp/hatodo.txt
- 10 kubectl get nodes
- 11 sudo -i
- 12 exit
- 13 history
- 1 mkdir .kube
- 2 cp -i /etc/kubernetes/admin.conf .kube/config
- 3 sudo cp -i /etc/kubernetes/admin.conf .kube/config
- 4 cat /tmp/hatodo.txt
- 5 sudo chown student:student .kube/config
- 6 ls -l .kube/config
- 7 kubectl get all
- 8 kubectl apply -f https://docs.projectcalico.org/latest/manifests/calico.yaml
- 9 cat /tmp/hatodo.txt
- 10 kubectl get nodes
- 11 sudo -i
- 12 exit
- 13 history
- 14 kubectl -h | less
- 15 kubectl top -h
- 16 kubectl top pod
- 17 kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases
- 18 vim components.yaml
- 19 kubectl create -f components.yaml
- 20 kubectl -n kube-system get pods
- 21 source <(kubectl completion bash)
- 22 sudo yum install -y bash-completion
- 23 source <(kubectl completion bash)
- 24 exit
- 25 kubectl get pods -n kube-system
- 26 kubectl logs metrics-server-6c49cf6978-8g6hr
- 27 kubectl logs metrics-server-6c49cf6978-8g6hr -n kube-system
- 28 kubectl -n kube-system edit deploy metrics-server
- 29 kubectl get pods -n kube-system
- 30 kubectl -n kube-system edit deploy metrics-server
- 31 kubectl top pods -A
- 32 history
- 33 ls
- 34 git clone https://github.com/sandervanvugt/cka
- 35 cka/counter.sh 13
- 36 kubectl get nodes
- 37 kube edit node control1.example.com
- 38 kubectl edit node control1.example.com
- 39 kubectl create myweb --image=nginx --replicas=3
- 40 kubectl create deploy myweb --image=nginx --replicas=3
- 41 kubectl get pods -o wide
- 42 kubectl edit node control2.example.com
- 43 kubectl edit node control3.example.com
- 44 cat /etc/redhat-release
- 45 history
- 46 ip a
- 47 kubectl get pods -n kube-system
- 48 cd cka
- 49 kubectl apply -f nwpolicy-complete-example.yaml
- 50 kubectl expose pod nginx --port-80
- 51 kubectl expose pod nginx --port=80
- 52 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
- 53 kubectl get nwp -o yaml
- 54 kubectl get networkpolicy -o yaml
- 55 kubectl get pods --show-labels
- 56 kubectl label pod busybox access=true
- 57 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
- 58 kubectl create ns nwp-namespace
- 59 vim nwp-lab11-1.yaml
- 60 kubectl create -f nwp-lab11-1.yaml
- 61 kubectl expose pod nwp-nginx --port=80
- 62 kubectl exec -it newp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
- 63 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
- 64 kubectl exec -it nwp-busybox -n nwp-namespace -- nsloolup nwp-nginx
- 65 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
- 66 vim nwp-lab11-1.yaml
- 67 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
- 68 vim nwp-lab11-2.yaml
- 69 kubectl create -f nwp-lab11-2.yaml
- 70 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
- 71 kubectl create deploy busybox --image=busybox -- sleep 3600
- 72 kubectl get pods
- 73 kubectl exec -it busybox-669745485f-h8r88 -- wget --spider --timeout=1 nwp-nginx
- 74 history
- ##### on the 3 node cluster
- student@control:~$ history
- 1 cat /etc/hosts
- 2 ip a
- 3 sudo apt install -y git vim
- 4 kubectl get pods -h | less
- 5 kubectl get pods -o wide --sort-by-.spec.nodeName
- 6 kubectl get pods -o wide --sort-by=.spec.nodeName
- 7 git clone https://github.com/sandervanvugt/cka
- 8 cd cka
- 9 ls *sh
- 10 vim setup-container.sh
- 11 ./setup-container.sh
- 12 ./setup-kubetools.sh
- 13 sudo ./setup-kubetools.sh
- 14 sudo vim /etc/fstab
- 15 sudo swapoff -a
- 16 free -m
- 17 sudo vim /etc/hosts
- 18 sudo -i
- 19 vim /tmp/todo.txt
- 20 top
- 21 cat /tmp/todo.txt
- 22 cd
- 23 mkdir -p .kube
- 24 sudo cp -i /etc/kubernetes/admin.conf .kube/config
- 25 sudo chown student:student .kube/config
- 26 kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
- 27 kubectl get all
- 28 kubectl get all -A
- 29 cat /tmp/todo.txt
- 30 kubectl get nodes
- 31 history
- 32 kubectl get nodes
- 33 history
- 34 cat /tmp/todo.txt
- 35 sudo kubeadm -h | less
- 36 history
- 37 cd cka
- 38 ls
- 39 history
- 40 kubectl get nodes
- 41 ./counter.sh 3
- 42 kubectl create ns mynamespace
- 43 kubectl run myalp --image=alpine -- sleep 3600 > myalp.yaml
- 44 vim myalp.yaml
- 45 kubectl run myalp --image=alpine -- sleep 3600 --dry-run=client -o yaml > myalp.yaml
- 46 kubectl delete pod myalp
- 47 kubectl run myalp --image=alpine --dry-run=client -o yaml -- sleep 3600
- 48 ./counter.sh 6
- 49 vim wk3.yaml
- 50 kubectl create -f wk3.yaml
- 51 kubectl get pods
- 52 kubectl describe pod exercise3
- 53 ./counter.sh 17
- 54 vim oinit.yaml
- 55 kubectl create -f oinit.yaml
- 56 kubectl get pods
- 57 kubectl describe pod init-demo
- 58 kubectl get pods -o wide
- 59 ./counter.sh 5
- 60 kubectl get nodes
- 61 kubectl edit node control
- 62 kubectl create deploy nginx --image=nginx --replicas=3
- 63 kubectl get pods -o wide
- 64 kubectl edit node control
- 65 kubectl get pods -o wide
- 66 kubectl completion -h
- 67 source <(kubectl completion bash)
- 68 kubectl scale deployment nginx --replicas=6
- 69 kubectl get pods -o wide
- 70 ./counter.sh 7
- 71 kubectl run nginx --dry-run=client -o yaml > static.yaml
- 72 kubectl run nginx --dry-run=client --image=nginx -o yaml > static.yaml
- 73 cat static.yaml
- 74 kubectl get pods
- 75 ./counter.sh 23
- 76 vim wg8.yaml
- 77 kubectl create -f wg8.yaml
- 78 kubectl describe pod pv-pod
- 79 kubectl describe pod pv-pod -n myvol
- 80 kubectl exec -it pv-pod -n myvol -- sh
- 81 kubectl get pvc
- 82 kubectl get pvc -n myvol
- 83 kubectl get pv
- 84 kubectl describe pv task-pv-volume
- 85 kubectl explain pv.spec | less
- 86 kubectl api-resources | less
- 87 kubectl create quota --help | less
- 88 kubectl set resources -h | less
- 89 history
- 90 ./counter.sh 8
- 91 #kubectl create quota qtest --hard pods=3,cpu=100,memory=500Mi --namespace limited
- 92 kubectl create ns limited
- 93 kubectl create quota qtest --hard pods=3,cpu=100,memory=500Mi --namespace limited
- 94 kubectl create deploy nginx --image=nginx --replicas=3 -n limited
- 95 kubectl get all -n limited
- 96 kubectl describe -n limited replicasets.apps nginx-85b98978db
- 97 kubectl describe ns limited
- 98 kubectl set resources deploy nginx --requests cpu=100m,memory=5Mi --limites cpu=200m,memory=20Mi -n limited
- 99 kubectl set resources deploy nginx --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi -n limited
- 100 kubectl get pods -n limited
- 101 kubectl create deploy lmitbox --image=busybox --replicas=3 -- sleep 3000
- 102 kubectl get pods -n limited
- 103 kubectl get all -n limited
- 104 kubectl create deploy lmitbox --image=busybox --replicas=3 -n limited -- sleep 3000
- 105 kubectl get all -n limited
- 106 kubectl describe -n limited replicasets.apps lmitbox-6fdd4d7884
- 107 history
- 108 ./counter.sh 12
- 109 vim sr8.yaml
- 110 kubectl explain limitrange
- 111 kubectl explain quota
- 112 vim sr8.yaml
- 113 ./counter.sh 5
- 114 kubectl create app1 --image=nginx --replicas=3
- 115 kubectl create deploy app1 --image=nginx --replicas=3
- 116 kubectl create deploy app3 --image=nginx --replicas=3
- 117 kubectl label deployments.apps app1 app=working
- 118 kubectl label deployments.apps app1 type=working
- 119 kubectl label deployments.apps app3 type=working
- 120 kubectl get pods --selector type=working
- 121 kubectl get pods --show-labels
- 122 kubectl get pods --selector app=nginx
- 123 kubectl get pod -h | less
- 124 kubectl get pod exercise3 -o json | less
- 125 kubectl get pod -h | less
- 126 kubectl get pods --selector app=nginx -o wide
- 127 kubectl get pods --selector app=nginx -o wide --sort-by=.spec.nodeName
- 128 kubectl get pods --selector app=nginx -o wide --sort-by=.spec.nodeName > /tmp/sortlist.txt
- 129 cat /tmp/sortlist.txt
- 130 kubectl get pods -l app=nginx -o wide --sort-by=.spec.nodeName
- 131 ./counter.sh 5
- 132 vim df10.yaml
- 133 kubectl create deploy daemonploy --image=nginx --dry-run=client -o yaml > daemonploy.yaml
- 134 vim daemonploy.yaml
- 135 kubectl api-resources
- 136 kubectl create -f daemonploy.yaml
- 137 kubectl get ds,pods -o wide
- 138 kubectl get ds -A
- 139 history
- 140 sudo -i
- 141 cd cka
- 142 ./counter.sh 15
- 143 ip a
- 144 ip a | less
- 145 kubectl get all
- 146 cd cka
- 147 ./counter.sh 10
- 148 sudo -i
- 149 kubectl cordon -h
- 150 kubectl drain -h
- 151 kubectl drain -h | less
- 152 kubectl drain worker2
- 153 kubectl drain worker2 --force
- 154 kubectl drain worker2 --force --ignore-daemonsets
- 155 kubectl get pods -o wide
- 156 kubectl uncordon worker2
- 157 kubectl get nodes
- 158 kubectl get pods -o wide
- 159 kubectl get nodes
- 160 kubectl get nodes\
- 161 kubectl get nodes
- 162 kubectl describe node worker2 | less
- 163 kubectl get nodes
- 164 kubectl labe nodes worker2.example.com disktype=ssd
- 165 kubectl label nodes worker2.example.com disktype=ssd
- 166 kubectl get nodes
- 167 kubectl label nodes worker2 disktype=ssd
- 168 kubectl get nodes -l
- 169 kubectl get nodes --show-labels
- 170 vim selector-pod.yaml
- 171 kubectl create -f selector-pod.yaml
- 172 kubectl get pods -o wide
- 173 source <(kubectl completion bash)
- 174 kubectl describe pod nginx
- 175 kubectl get pods
- 176 kubectl delete pod nginx
- 177 vim selector-pod.yaml
- 178 kubectl create -f selector-pod.yaml
- 179 kubectl get pods
- 180 kubectl get nodes -o wide
- 181 kubectl taint nodes worker1 example-key=value1:NoSchedule
- 182 kubectl describe nodes worker1 | less
- 183 kubectl create deploy nginx-taint --image=nginx --replicas=3
- 184 kubectl get pods -o wide
- 185 vim taint-toleration.yaml
- 186 kubectl create -f taint-toleration.yaml
- 187 kubectl get pods nginx-toleration
- 188 kubectl get pods nginx-toleration -o wide
- 189 ./counter.sh 16
- 190 vim df20.yaml
- 191 kubectl create -f df20.yaml
- 192 kubectl get pods
- 193 kubectl get pods -o yaml
- 194 vim df20.yaml
- 195 kubectl get nodes --show-labels
- 196 kubectl delete -f df20.yaml
- 197 vim df20.yaml
- 198 kubectl create -f df20.yaml
- 199 kubectl get pods affinitypod
- 200 vim sanderfinity.yaml
- 201 kubectl get nodes -o wide
- 202 kubectl edit nodes worker1
- 203 kubectl create -f sanderfinity.yaml
- 204 kubectl get pods sanderx
- 205 kubectl delete -f df20.yaml
- 206 kubectl create -f df20.yaml
- 207 kubectl get pods affinitypod
- 208 vim df20.yaml
- 209 kubectl delete -f df20.yaml
- 210 vim df20.yaml
- 211 kubectl create -f df20.yaml
- 212 kubectl get pods affinitypod
- 213 kubectl config view
- 214 sudo less /etc/kubernetes/admin.conf
- 215 kubectl api-resources | less
- 216 sudo useradd -G adm anna
- 217 sudo passwd anna
- 218 su - anna
- 219 sudo userdel -rf anna
- 220 sudo useradd -G adm -m anna
- 221 sudo passwd anna
- 222 su - anna
- 223 id
- 224 sudo usermod -aG sudo anna
- 225 su - anna
- 226 kubectl get CertificateSigningRequest -A
- 227 kubectl api-resources | grep ertifi
- 228 kubectl api-resources | grep certificates.k8s
- 229 kubectl api-resources | grep -i certificates.k8s
- 230 vim podaccessrole.yaml
- 231 kubectl create -f podaccessrole.yaml
- 232 vim rolebinding.yaml
- 233 kubectl create -f rolebinding.yaml
- 234 vim rolebinding.yaml
- 235 kubectl create -f rolebinding.yaml
- 236 vim rolebinding.yaml
- 237 kubectl run rolepod --image=nginx
- 238 kubectl get pods
- 239 su - anna
- 240 kubectl auth can-i get pods --as anna
- 241 su - anna
- 242 ./counter.sh 20
- 243 ./counter.sh 10
- 244 kubectl get all -n kube-system
- 245 kubectl delete ds weave-net kube-system
- 246 kubectl delete ds weave-net -n kube-system
- 247 kubectl apply -f https://docs.projectcalico.org/latest/manifests/calico.yaml
- 248 kubectl get pods -n kube-system
- 249 kubectl get pods -n kube-system -o wide
- 250 kubectl get ds -n kube-system
- 251 vim nwpolicy-complete-example.yaml
- 252 kubectl create -f nwpolicy-complete-example.yaml
- 253 kubectl delete -f nwpolicy-complete-example.yaml
- 254 kubectl delete pods nginx
- 255 kubectl create -f nwpolicy-complete-example.yaml
- 256 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
- 257 kubectl exec -it busybox -- nslookup nginx
- 258 kubectl expose pod nginx --port=80
- 259 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
- 260 kubectl get all -n kube-system
- 261 kubectl logs calico-node-wqvvr
- 262 kubectl logs calico-node-wqvvr -n kube-system
- 263 sudo reboot
- 264 kubectl get pods -n kube-system
- 265 history
Add Comment
Please, Sign In to add comment