Differences

This shows you the differences between two versions of the page.

Link to this comparison view

devops:laboratoare:05 [2021/07/28 15:46]
bogdan.croitoru
devops:laboratoare:05 [2021/07/28 16:54] (current)
bogdan.croitoru
Line 8: Line 8:
  
 <​note>​mkdir ~/.kube <​note>​mkdir ~/.kube
 +
 cp config ~/.kube cp config ~/.kube
  
-kubectl get nodes</​note>​+kubectl get nodes</​note>​
  
   * Observam contextul actual folosit   * Observam contextul actual folosit
Line 116: Line 117:
  
 <​note>​cd ../​Laborator2</​note>​ <​note>​cd ../​Laborator2</​note>​
 +
 +==== 5.2. Deployments,​ stateless/​stateful ====
 +
 +=== Deployments - de obicei folosit de aplicatii stateless ===
 +
 +  * Creeaza primul tau deployment folosind commanda urmatoare:
 +
 +<​note>​kubectl apply -f deploy-01.yaml</​note>​
 +
 +  * Observam detaliile deployment-ului
 +
 +<​note>​kubectl get deployments
 +
 +kubectl get pods
 +
 +kubectl get replicaset</​note>​
 +
 +  * Scalam deployment-ul in sus, crescand numarul de replici
 +<​note>​kubectl scale deployments/​nginx-deployment --replicas=4
 +
 +kubectl get pods -o wide # vom vedea 4 pod-uri</​note>​
 +  * Scalam deployment-ul in jos. Reducem numarul de pod-uri
 +<​note>​kubectl scale deployments/​nginx-deployment --replicas=2
 +
 +kubectl get pods -o wide</​note> ​
 +
 +  * Schimbam imaginea folosita in deployment utilizand comanda urmatoare:
 +
 +<​note>​kubectl set image  deployments/​nginx-deployment nginx=nginx:​1.9.1</​note>​
 +
 +  * Facem revert la deployment-ul anterior cu imaginea de docker anterioara
 +
 +<​note>​kubectl rollout undo deployments/​nginx-deployment
 +
 +kubectl rollout status deployments/​nginx-deployment ​
 +
 +kubectl describe deploy nginx-deployment
 +</​note>​
 +
 +  * Stergem deployment-ul
 +
 +<​note>​kubectl delete deployment nginx-deployment</​note>​
 +
 +=== Statefulset - aplicatii stateful ===
 +
 +  * Pe fiecare masina student exista instalat si configurat nfs server cu export-urile:​
 +
 +<​note>/​exports/​data-0001
 +/​exports/​data-0002</​note>​
 +
 +  * Verificam ca functioneaza mount-urile:​
 +
 +<​note>​sudo showmount -e localhost</​note>​
 +
 +  * Fiecare student va folosi propria adresa ip, mai departe in cadrul acestui laborator.
 +  * Adresa ip poate fi obtinuta folosind comanda de mai jos
 +
 +<​note>​ip -f inet addr show ens3</​note>​
 +
 +  * Editati fisierele nfs-0001.yaml si nfs-0002.yaml,​ adaugand adresa ip proprie in campul spec.nfs.server si actualizati campul metadata.name cu id-ul de student aferent.
 +
 +  * Cream volume persistente astfel:
 +
 +<​note>​kubectl apply -f nfs-0001.yaml
 +
 +kubectl apply -f nfs-0002.yaml</​note>​
 +
 +  * Observam volumele create
 +
 +<​note>​kubectl get pv | grep studentid
 +
 +kubectl describe pv <​pv_name></​note>​
 +
 +  * Cream un statefulset folosind comanda de mai jos:
 +
 +<​note>​kubectl apply -f statefulset-01.yaml</​note>​
 +
 +  * Observam statefulset-ul creat
 +
 +<​note>​kubectl get statefulset
 +
 +kubectl describe statefulset
 +
 +kubectl get pods</​note>​
 +
 +  * Verificam ca datele de pe disk sunt disponibile in container
 +
 +  * Scriem date in volumele de pe disk
 +
 +echo 'Hello World' ​ /​exports/​data-0001/​index.html
 +echo "Hello $USER" > /​exports/​data-0002/​index.html
 +
 +  * Verificam in pod-uri. Comenzile urmatoare ar trebui sa afiseze continutul fisierului index.html de pe disk
 +
 +<​note>​kubectl exec -it web-0 -- cat /​usr/​share/​nginx/​html/​index.html
 +
 +kubectl exec -it web-1 -- cat /​usr/​share/​nginx/​html/​index.html</​note>​
 +
 +  * Cream un serviciu care sa acceseze statefulset-ul
 +
 +<​note>​kubectl create -f service.yaml</​note>​
 +
 +  * Observam cum serviciul se conecteaza la backend (campul Endpoints:)
 +
 +<​note>​kubectl describe svc nginx</​note>​
 +
 +  * Curatam mediul
 +
 +<​note>​kubectl delete -f statefulset-01.yaml</​note>​
 +
 +  * Trecem la urmatorea parte din laborator
 +
 +<​note>​cd ../​Laborator3</​note>​
 +
 +==== 5.3. Daemonsets ====
 +
 +  * Daemonset-urile sunt resurse stateless, folosite pentru a putea rula, spre exemplu, un proces pe toate nodurile din cluster.
 +  * Daemonset-urile se asigura ca anumite nod-uri Kubernetes sau chiar toate ruleaza o copie a unui pod.
 +  * Editam continutul fisierului daemonset.yaml,​ actualizand "​student[id]"​ cu id-ul corespunzator
 +
 +<​note>​vi daemonset.yaml</​note>​
 +
 +  * Aplicam fisierul "​daemonset.yaml"​
 +
 +<​note>​kubectl apply -f daemonset.yaml</​note>​
 +
 +  * Verificam ca pod-urile au pornit. Vom vedea ca s-au creat 3 pod-uri, cate unul pe fiecare worker node.
 +
 +<​note>​kubectl get pods -owide
 +kubectl describe daemonset daemonset-studentid</​note>​
 +
 +  * Editam fisierul "​daemonset.yaml",​ decomentam liniile 16,17 si 18 .
 +
 +<​note>​vi daemonset.yaml</​note>​
 +
 +  * Aplicam din nou fisierul "​daemonset.yaml"​
 +
 +<​note>​kubectl apply -f daemonset.yaml</​note>​
 +
 +  * Unordered List ItemVerificam starea daemonset-ului si a pod-urilor. Observam ca s-a creat un pod si pe nodul master.
 +
 +<​note>​kubectl get daemonset
 +kubectl get pods -owide</​note>​
 +
 +  * Incercati sa stergeti un pod creat de daemonset.
 +
 +<​note>​kubectl delete pod daemonset-student[id]-xxxxx</​note>​
 +
 +  * Curatam mediul
 +
 +<​note>​kubectl delete daemonset daemonset-student[id]</​note>​
 +sau
 +<​note>​kubectl delete -f daemonset.yaml</​note>​
 +
devops/laboratoare/05.1627476412.txt.gz ยท Last modified: 2021/07/28 15:46 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0