การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น
ใช้โพรบของ Kubernetes เพื่อตรวจจับคอนเทนเนอร์ที่ไม่ทำงานตามปกติ ระงับการส่งข้อมูลจนกว่าแอปจะพร้อม และให้เวลาแอปที่เริ่มต้นช้าในการบูต
การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น เป็นบทเรียน Docker & Kubernetes for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Docker & Kubernetes for Developers และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Probes Matter
Kubernetes cannot know your app is healthy just because the process is running. Probes let you tell the kubelet how to check real application health.
The Three Probe Types
There are three: liveness (restart if broken), readiness (gate traffic), and startup (protect slow boots).
Liveness Probe
If the liveness probe fails, the kubelet restarts the container. Use it to recover from deadlocks the process cannot detect itself.
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 10Readiness Probe
If readiness fails, the Pod is removed from Service endpoints but NOT restarted. This stops traffic to a Pod that is temporarily unable to serve.
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5Liveness vs Readiness
Liveness answers should I restart this; readiness answers should I send traffic. Using readiness as liveness causes needless restarts; the opposite causes failed requests.
Startup Probe
A startup probe disables liveness and readiness until the app finishes booting, perfect for slow-starting legacy apps.
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 10Probe Mechanisms
Probes can use httpGet, a raw tcpSocket connection, or run a command with exec, succeeding when the command exits 0.
livenessProbe:
exec:
command: ["cat", "/tmp/healthy"]Tuning Timing
Key knobs: initialDelaySeconds, periodSeconds, timeoutSeconds, failureThreshold, and successThreshold let you balance speed of detection against false positives.
Probes and Rollouts
Readiness probes make rolling updates safe: new Pods only receive traffic once ready, so a broken release does not serve users.
Debugging Failing Probes
Probe failures show up in events. Describe the Pod to see why it restarts or never becomes ready.
kubectl describe pod my-podCommon Mistakes
Avoid heavy health endpoints that themselves cause timeouts, and avoid too-short initialDelaySeconds that restart Pods before they finish booting.
Quick Check
Test what you have learned.
Recap
You learned the three probe types: liveness restarts, readiness gates traffic, startup protects slow boots, the http/tcp/exec mechanisms, timing knobs, and how readiness keeps rollouts safe.
เรียนรู้ Docker & Kubernetes for Developers ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Docker & Kubernetes for Developers ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น”
ใช้โพรบของ Kubernetes เพื่อตรวจจับคอนเทนเนอร์ที่ไม่ทำงานตามปกติ ระงับการส่งข้อมูลจนกว่าแอปจะพร้อม และให้เวลาแอปที่เริ่มต้นช้าในการบูต คุณปฏิบัติ Docker & Kubernetes for Developers ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Docker & Kubernetes for Developers หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Docker & Kubernetes for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Docker & Kubernetes for Developers นี้ได้ไหม
ได้ บทเรียน Docker & Kubernetes for Developers ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- กลยุทธ์การบันทึกล็อกใน Kubernetes
- การเฝ้าติดตามด้วย Prometheus และ Grafana
- การแก้ไขปัญหา K8s ที่พบบ่อย
- การตรวจสอบสถานะ: โพรบการทำงาน ความพร้อมใช้งาน และการเริ่มต้น