Kubernetes Workshop1 : Step7 : การจัดการ Deployment

สร้าง Deployment ด้วย command

เราสามารถสร้าง deployment ด้วย command

kubectl create deployment httpd-frontend –image=httpd:2.4-alpine –replicas=3

kubernetes จะทำการสร้าง deployment, replicaset และ pod ที่เกี่ยวข้อง

สร้าง…


This content originally appeared on DEV Community and was authored by Tossapol Ritcharoenwattu

สร้าง Deployment ด้วย command

เราสามารถสร้าง deployment ด้วย command

kubectl create deployment httpd-frontend --image=httpd:2.4-alpine --replicas=3

kubernetes จะทำการสร้าง deployment, replicaset และ pod ที่เกี่ยวข้อง

สร้าง Deployment ด้วยไฟล์ yaml

เรามาลองสร้างไฟล์ deployment.yaml กัน โดยไฟล์ที่สร้างนี้เป็นแบบ basic มีหน้าตาเหมือกับ replicaset ในบทความก่อน โดย แตกต่างกันเพียงแค่ kind = Deployment เท่านั้น

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
  labels:
    app: myapp
    type: front-end
spec:
  replicas: 3
  selector:
    matchLabels:
      type: front-end
  template:
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    spec:
      containers:
        - name: nginx-container
          image: nginx

ก่อนจะสร้าง deployment เรามาเช็คดูก่อนว่าใน cluster มีอะไรบ้าง (ใน lab นี้ ได้ทำการลบทุกอย่างออกหมดแล้ว จึงพบว่าไม่มีอะไร)

สร้าง deployment จาก yaml

kubectl apply -f deployment.yaml


หลังจากสร้าง deployment เรามาเช็คดูว่าใน cluster มีอะไรถูกสร้างขึ้นมาบ้าง

kubetcl get all


จะเห็นได้ว่า deployment จะทำการสร้าง replicaset และ pods ให้เอง

ดูว่าใน cluster มี deployment อะไรบ้าง

kubectl get deployment


`

ดูรายละเอียดของ deployment ที่ต้องการ

kubectl describe deploymeny myapp-deployment

ลบ deployment

kubectl delete deployment myapp-deployment


ลองเช็คดูว่าใน cluster มีอะไรบ้างหลังจากลบ deployment

เมื่อสั่งลบ deployment แล้ว จะเห็นว่า kubernetes จะทำการลบ repicaset และ pod ที่เกี่ยวข้องกับ deployment ออกไปพร้อมกัน


This content originally appeared on DEV Community and was authored by Tossapol Ritcharoenwattu


Print Share Comment Cite Upload Translate Updates
APA

Tossapol Ritcharoenwattu | Sciencx (2025-07-12T15:06:33+00:00) Kubernetes Workshop1 : Step7 : การจัดการ Deployment. Retrieved from https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/

MLA
" » Kubernetes Workshop1 : Step7 : การจัดการ Deployment." Tossapol Ritcharoenwattu | Sciencx - Saturday July 12, 2025, https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/
HARVARD
Tossapol Ritcharoenwattu | Sciencx Saturday July 12, 2025 » Kubernetes Workshop1 : Step7 : การจัดการ Deployment., viewed ,<https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/>
VANCOUVER
Tossapol Ritcharoenwattu | Sciencx - » Kubernetes Workshop1 : Step7 : การจัดการ Deployment. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/
CHICAGO
" » Kubernetes Workshop1 : Step7 : การจัดการ Deployment." Tossapol Ritcharoenwattu | Sciencx - Accessed . https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/
IEEE
" » Kubernetes Workshop1 : Step7 : การจัดการ Deployment." Tossapol Ritcharoenwattu | Sciencx [Online]. Available: https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/. [Accessed: ]
rf:citation
» Kubernetes Workshop1 : Step7 : การจัดการ Deployment | Tossapol Ritcharoenwattu | Sciencx | https://www.scien.cx/2025/07/12/kubernetes-workshop1-step7-%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b8%88%e0%b8%b1%e0%b8%94%e0%b8%81%e0%b8%b2%e0%b8%a3-deployment/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.