Advertisement
thesuhu

Kubernetes Commands

Feb 4th, 2020 (edited)
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.54 KB | None | 0 0
  1. # Delete deployment
  2. kubectl delete deployment appname
  3.  
  4. # deploy pod menggunakan yaml file
  5. kubectl apply -f ws-app.yaml
  6.  
  7. # get service
  8. kubectl get svc
  9. kubectl get service -o wide
  10.  
  11. # delete service, proses ini otimatis delete endpoints jika ada
  12. kubectl delete svc mysql
  13.  
  14. # delete node/worker safely
  15. kubectl drain <<node>>
  16.  
  17. # undo drain
  18. kubectl uncordon <node-name>
  19.  
  20. # melihat resoruce nodes, jika pod pending disebabkan karena Insufficient resources
  21. kubectl get nodes -o yaml | egrep '\sname:|cpu:|memory:'
  22.  
  23. # menghapus pod status terminating
  24. kubectl delete pods <pod> --grace-period=0 --force
  25.  
  26. # langkah update pods dengan image baru
  27. # 1. build docker dengan nama dan versi baru (di server worker)
  28. docker build -t web-app:1.0.1 .
  29. # 2. sesuaikan file yaml dengan image yang baru (di server master) kemudian deploy
  30. kubectl apply -f deploy.yaml
  31. # jika get pods maka akan tampak versi lama terminated, diganti dengan versi yang baru
  32. # cek history revisi
  33. kubectl rollout history backend/web-app
  34.  
  35. # exec terminal dalam container
  36. kubectl exec -it backend-85966f7b9f-nbx5w -- /bin/bash
  37. # atay simple way
  38. kubectl exec -it backend-84dfbf96d4-sr8tt bash
  39.  
  40. # restart semua pods by deployment
  41. kubectl -n service rollout restart deployment backend
  42.  
  43. # PENTING
  44. # untuk akses service database eksternal, pastikan di server worker port outgoing sudah di allow di firewall-cmd
  45. # sampai saat ini masih belum berhasil, jika dimatikan firewallnya dapat tersambung ke server luar
  46.  
  47. # cek port digunakan
  48. sudo lsof -i -P -n
  49. sudo lsof -i -P -n | grep LISTEN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement