หมวดที่ 1: Container และ Orchestration
เครื่องมือสำหรับสร้าง, จัดการ, และควบคุม Container และ Cluster
Docker
เครื่องมือพื้นฐานสำหรับจัดการ Container Lifecycle
docker ps: แสดงรายการ Container ที่กำลังทำงานอยู่
docker ps -a: แสดง Container ทั้งหมด (รวมที่หยุดทำงานแล้ว)
docker images: แสดงรายการ Images ที่มีในเครื่อง
docker images -q: แสดงเฉพาะ Image IDs
docker run: สร้างและรัน Container ใหม่
docker run -it --rm ubuntu:latest /bin/bash: รัน Container แบบ interactive, ลบทิ้งเมื่อจบการทำงาน (--rm), และเข้าสู่ shell
docker exec: รันคำสั่งภายใน Container ที่กำลังทำงานอยู่
docker exec -it /bin/sh: เข้าไปใน shell ของ Container
docker logs: ดู Log ของ Container
docker logs -f --tail 100 : ติดตาม Log (-f) และแสดง 100 บรรทัดล่าสุด
docker build: สร้าง Image จาก Dockerfile
docker build -t my-app:v1 .: สร้าง Image พร้อมตั้งชื่อและแท็ก (-t)
docker stop/start: หยุดหรือเริ่มการทำงานของ Container
docker rm: ลบ Container
docker rm $(docker ps -aq): ลบ Container ทั้งหมด
docker rmi: ลบ Image
docker rmi -f : บังคับลบ Image (-f)
docker system prune: ล้างข้อมูลที่ไม่ใช้งาน (dangling images, stopped containers, networks)
docker system prune -a --volumes: ล้างทุกอย่างรวมถึง Images ที่ไม่ถูกใช้และ Volumes
docker inspect: แสดงข้อมูลรายละเอียดของ Object (Container, Image) ในรูปแบบ JSON
docker network: จัดการเครือข่ายของ Docker
docker volume: จัดการพื้นที่จัดเก็บข้อมูล (Volume)
docker push/pull: ส่ง/ดึง Image จาก Container Registry
docker-compose up/down: เริ่มหรือหยุดการทำงานของแอปพลิเคชันทั้งหมดที่นิยามใน docker-compose.yml
Kubernetes (kubectl)
เครื่องมือหลักสำหรับจัดการ Kubernetes Cluster
kubectl get: ดึงข้อมูลและแสดงรายการ Resources
kubectl get pods -n production -o wide: แสดง Pods ใน namespace production พร้อมข้อมูลเพิ่มเติม (-o wide)
kubectl describe: แสดงรายละเอียดเชิงลึกของ Resource
kubectl describe node : ดูสถานะและ Events ของ Node
kubectl apply: สร้างหรืออัปเดต Resource จากไฟล์ YAML
kubectl apply -f deployment.yaml --record: ใช้คอนฟิกจากไฟล์และบันทึกคำสั่งไว้ใน history ของ Resource
kubectl delete: ลบ Resource
kubectl delete pod --grace-period=0 --force: บังคับลบทันที
kubectl exec: รันคำสั่งภายใน Container ใน Pod
kubectl exec -it -c -- /bin/bash
kubectl logs: ดู Log ของ Container ใน Pod
kubectl logs -f -c
kubectl port-forward: สร้าง Tunnel จากเครื่องเราไปยัง Pod
kubectl port-forward svc/my-service 8080:80
kubectl config: จัดการไฟล์ kubeconfig
kubectl config use-context : สลับไปใช้ Cluster อื่น
kubectl rollout: จัดการการ deploy แอปพลิเคชัน
kubectl rollout status deployment/my-app: ดูสถานะการ deploy
kubectl rollout history deployment/my-app: ดูประวัติการ deploy
kubectl rollout undo deployment/my-app: ย้อนกลับไปเวอร์ชันก่อนหน้า
kubectl scale: เพิ่มหรือลดจำนวน Replicas
kubectl scale deployment/my-app --replicas=5
kubectl top: ดูการใช้ CPU/Memory
kubectl top pod -A: ดูการใช้งานของ Pods ทั้งหมดในทุก Namespace
kubectl cordon/uncordon: กำหนดให้ Node ไม่รับ Pod ใหม่ / รับ Pod ใหม่
kubectl drain: ย้าย Pods ทั้งหมดออกจาก Node อย่างปลอดภัยเพื่อซ่อมบำรุง
kubectl taint: กำหนด "Taint" ให้กับ Node เพื่อให้รับเฉพาะ Pod ที่มี "Toleration" ตรงกัน
kubectl label: เพิ่ม/ลบ Label ให้กับ Resource
เครื่องมือเสริมอื่นๆ
helm: Package Manager สำหรับ Kubernetes
k9s: Terminal UI สำหรับ Kubernetes ที่ช่วยให้จัดการ Cluster ได้ง่ายขึ้น
kustomize: เครื่องมือปรับแต่งไฟล์ YAML ของ Kubernetes โดยไม่ต้องใช้ Template
istioctl: CLI สำหรับจัดการ Istio Service Mesh
podman: Engine จัดการ Container ที่ทำงานแบบ Daemonless (เป็นทางเลือกของ Docker)
buildah: เครื่องมือสำหรับสร้าง OCI container images โดยเฉพาะ
skopeo: เครื่องมือสำหรับทำงานกับ Container Images และ Registries (copy, inspect, delete)
dive: เครื่องมือสำรวจ Docker image, layer contents, และหาทางลดขนาด image
trivy: สแกนหาช่องโหว่ใน Container Images และไฟล์คอนฟิก
kaniko: เครื่องมือสร้าง Container Image จาก Dockerfile ภายใน Container หรือ Kubernetes Cluster โดยไม่ต้องใช้ Docker daemon
หมวดที่ 2: Infrastructure as Code (IaC) และ Configuration Management
เครื่องมือสำหรับสร้างและตั้งค่าระบบต่างๆ ผ่านโค้ด
Terraform
เครื่องมือสร้างและจัดการ Infrastructure บน Cloud
terraform init: เตรียมความพร้อมให้โปรเจกต์ (ดาวน์โหลด provider plugins)
terraform plan: แสดงแผนการเปลี่ยนแปลงที่จะเกิดขึ้น
terraform plan -out=tfplan: บันทึกแผนลงไฟล์
terraform apply: นำแผนไปสร้าง/เปลี่ยนแปลง Infrastructure จริง
terraform apply "tfplan": ใช้แผนที่บันทึกไว้
terraform apply -auto-approve: สร้างโดยไม่ต้องถามยืนยัน
terraform destroy: ทำลาย Infrastructure ทั้งหมดที่สร้างโดย Terraform
terraform validate: ตรวจสอบความถูกต้องของ синтаксисไฟล์ .tf
terraform fmt: จัดรูปแบบโค้ดให้อ่านง่ายตามมาตรฐาน
terraform workspace: จัดการสภาพแวดล้อมที่แตกต่างกัน (เช่น dev, staging, prod)
terraform state: จัดการไฟล์ state (เช่น list, mv, rm)
terraform import: นำ Infrastructure ที่มีอยู่แล้วเข้ามาจัดการใน Terraform
terraform output: แสดงค่า output ที่กำหนดไว้ในโค้ด
Ansible
เครื่องมือ Configuration Management แบบ Agentless
ansible-playbook: รันชุดคำสั่งที่เขียนไว้ใน Playbook
ansible-playbook setup.yml -i hosts --limit webservers
ansible (Ad-hoc): รันคำสั่งเดียวบนหลายเครื่องพร้อมกัน
ansible all -i hosts -m ping: ทดสอบการเชื่อมต่อกับทุกเครื่อง
ansible-galaxy: จัดการ Roles (ชุด Playbook ที่ใช้ซ้ำได้)
ansible-galaxy install geerlingguy.nginx
ansible-vault: เข้ารหัส/ถอดรหัสไฟล์ที่มีข้อมูลสำคัญ
ansible-vault create secrets.yml: สร้างไฟล์ที่เข้ารหัส
ansible-vault edit secrets.yml: แก้ไขไฟล์ที่เข้ารหัส
ansible-inventory: แสดงข้อมูล Inventory
ansible-doc: ดูเอกสารประกอบของ Module ต่างๆ
เครื่องมือ IaC และ Config Mgmt อื่นๆ
packer: สร้าง Machine Image (เช่น AMI, Docker Image) จากคอนฟิกเดียว
pulumi: เครื่องมือ IaC ที่ใช้ภาษาโปรแกรมมิ่งทั่วไป (Python, Go, JS)
chef-client: รัน Chef cookbook บน node
puppet apply: ใช้ Puppet manifest กับ node โดยตรง
หมวดที่ 3: CI/CD และ Version Control
เครื่องมือสำหรับกระบวนการผสานและส่งมอบซอฟต์แวร์อัตโนมัติ
Git
ระบบ Version Control ที่เป็นหัวใจของ DevOps
git clone: คัดลอก Repository จากระยะไกลมายังเครื่อง
git status: ตรวจสอบสถานะของไฟล์ในโปรเจกต์
git add: เพิ่มไฟล์เข้าสู่ Staging Area เพื่อเตรียม commit
git add -p: เพิ่มทีละส่วน (interactive)
git commit: บันทึกการเปลี่ยนแปลงลงในประวัติของโปรเจกต์
git commit -m "Your message": commit พร้อมข้อความ
git commit --amend: แก้ไข commit ล่าสุด
git push: ส่ง commit จากเครื่องเราไปยัง Remote Repository
git push origin my-feature --force-with-lease: บังคับ push อย่างปลอดภัย
git pull: ดึงการเปลี่ยนแปลงจาก Remote Repository มารวมกับ Branch ปัจจุบัน
git pull --rebase: ดึงและจัดเรียงประวัติ commit ใหม่
git fetch: ดึงข้อมูลล่าสุดจาก Remote แต่ยังไม่รวม (merge)
git branch: จัดการ Branch
git branch -a: ดู Branch ทั้งหมด (local และ remote)
git checkout: สลับ Branch หรือย้อนกลับไป commit เก่า
git checkout -b new-feature: สร้างและสลับไป Branch ใหม่
git merge: รวมประวัติจาก Branch อื่นเข้ามาใน Branch ปัจจุบัน
git rebase: จัดเรียงประวัติ commit ใหม่ (มักใช้เพื่อทำให้ประวัติสวยงาม)
git log: ดูประวัติการ commit
git log --oneline --graph --decorate: แสดงผลแบบกราฟ กระชับ และสวยงาม
git diff: ดูความแตกต่างระหว่างไฟล์
git stash: เก็บการเปลี่ยนแปลงที่ยังไม่ commit ไว้ชั่วคราว
git tag: สร้าง Tag (มักใช้ระบุเวอร์ชัน)
git cherry-pick: นำ commit ที่ต้องการจาก Branch อื่นมาใช้ใน Branch ปัจจุบัน
git reset: ย้อนสถานะของโปรเจกต์ (มีหลายโหมด: --soft, --mixed, --hard)
git revert: สร้าง commit ใหม่เพื่อยกเลิกการเปลี่ยนแปลงของ commit เก่า
git remote: จัดการ Remote Repositories
git blame: แสดงว่าใครแก้ไขโค้ดบรรทัดไหนล่าสุด
เครื่องมือ CI/CD CLI
gh: GitHub CLI สำหรับจัดการ Issues, PRs, Actions จาก Terminal
glab: GitLab CLI
argocd: CLI สำหรับจัดการ Argo CD (เครื่องมือ GitOps)
jenkins-cli.jar: CLI สำหรับจัดการ Jenkins
make: เครื่องมือ Build Automation สุดคลาสสิก ใช้กำหนดขั้นตอนผ่าน Makefile
Top comments (0)