ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ
ลงมือใช้งาน kubectl ซึ่งเป็นเครื่องมือบรรทัดคำสั่งสำหรับตรวจสอบ สร้าง และจัดการทรัพยากรทุกชนิดในคลัสเตอร์ Kubernetes
ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ เป็นบทเรียน Docker & Kubernetes for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Docker & Kubernetes for Developers และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
What Is kubectl
kubectl is the official CLI that talks to the Kubernetes API server. Nearly every cluster operation, creating, reading, updating, deleting resources, goes through it.
Configuring Cluster Access
kubectl reads a kubeconfig file (default ~/.kube/config) that holds cluster endpoints, users, and credentials grouped into contexts.
kubectl config get-contexts
kubectl config use-context my-clusterListing Resources with get
kubectl get lists resources. Add -o wide for more columns or -A for all namespaces.
kubectl get pods
kubectl get pods -o wide
kubectl get nodes -AInspecting with describe
kubectl describe shows detailed, human-readable status plus an events section that is invaluable for debugging.
kubectl describe pod my-podCreating Resources
Apply a manifest file with kubectl apply -f. This is declarative: you describe the desired state and Kubernetes reconciles to it.
kubectl apply -f deployment.yamlImperative Quick Creates
For quick experiments you can create resources imperatively.
kubectl create deployment web --image=nginx
kubectl run tmp --image=busybox --restart=Never -- sleep 3600Viewing Logs
Stream container output with kubectl logs. Use -f to follow and --previous to see a crashed container.
kubectl logs my-pod -f
kubectl logs my-pod --previousExecuting Into a Pod
Open a shell inside a running container to debug interactively.
kubectl exec -it my-pod -- /bin/shEditing and Deleting
Edit live resources or remove them. Prefer editing manifests in git over edit for production.
kubectl edit deployment web
kubectl delete pod my-podNamespaces and Scoping
Most commands accept -n namespace. Set a default namespace to avoid repeating it.
kubectl get pods -n kube-system
kubectl config set-context --current --namespace=devOutput Formats
Use -o yaml or -o json to see the full object, and -o jsonpath to extract a single field.
kubectl get pod my-pod -o yaml
kubectl get pod my-pod -o jsonpath="{.status.phase}"Quick Check
Test what you have learned.
Recap
You practiced the core kubectl verbs: get, describe, apply, logs, exec, delete, plus contexts, namespaces, and output formats to control and debug your cluster.
คำถามที่พบบ่อย
บทเรียน “ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Docker & Kubernetes for Developers ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ”
ลงมือใช้งาน kubectl ซึ่งเป็นเครื่องมือบรรทัดคำสั่งสำหรับตรวจสอบ สร้าง และจัดการทรัพยากรทุกชนิดในคลัสเตอร์ Kubernetes คุณปฏิบัติ Docker & Kubernetes for Developers ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Docker & Kubernetes for Developers หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Docker & Kubernetes for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Docker & Kubernetes for Developers นี้ได้ไหม
ได้ บทเรียน Docker & Kubernetes for Developers ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- บทนำสู่ Kubernetes และความสำคัญของ Kubernetes
- สถาปัตยกรรมและองค์ประกอบของ Kubernetes
- การนำพ็อดแรกไปใช้งาน
- ทำงานกับ kubectl: เครื่องมือควบคุมคลัสเตอร์ของคุณ