พื้นฐานเครือข่าย Kubernetes
เรียนรู้วิธีที่พ็อด บริการ และอินเกรสสื่อสารกันภายในคลัสเตอร์ Kubernetes รวมถึงแนวคิดพื้นฐานของ CNI
พื้นฐานเครือข่าย Kubernetes เป็นบทเรียน Linux Networking & TCP/IP for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Linux Networking & TCP/IP for Developers และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Linux Networking & TCP/IP for Developers มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
K8s Networking Essentials
Welcome! Kubernetes networking can seem complex, but it's designed to make distributed applications work seamlessly.
In this lesson, we'll explore how different parts of a Kubernetes cluster communicate. You'll learn about Pods, Services, and Ingress.
Pods Get Their Own IPs
In Kubernetes, a Pod is the smallest deployable unit. Each Pod gets its own unique IP address within the cluster.
Containers inside the same Pod share this network namespace, meaning they can communicate with each other using localhost.
Pods Talk Directly
A core principle of Kubernetes networking is that all Pods can communicate with each other directly, without NAT (Network Address Translation).
This communication works even if Pods are on different worker nodes. It's like they're all on one flat network, making application design simpler.
The CNI Standard
How does Kubernetes achieve this "flat network" for Pods? It uses the Container Network Interface (CNI) standard.
CNI provides a specification for network plugins to configure network interfaces for containers. Examples include Calico, Flannel, and Cilium.
- CNI Plugin: Implements the CNI specification.
- kubelet: Uses the CNI plugin to assign IP addresses and configure networking for Pods.
Services for Stable Access
Pods are designed to be ephemeral. They can be created, destroyed, or rescheduled at any time, changing their IP addresses.
This makes direct access to a Pod's IP unreliable. This is where Services come in. Services provide a stable network endpoint for a group of Pods.
Internal ClusterIP Service
The most common Service type is ClusterIP. It exposes the Service on an internal IP address within the cluster.
This IP is only reachable from within the cluster. It's perfect for backend services that only need to be accessed by other applications inside Kubernetes.
NodePort for External Access
To expose a Service to the outside world, you can use a NodePort Service.
This type opens a specific port on *every* Node in your cluster. External traffic can reach your Service by hitting NodeIP:NodePort.
- Pros: Simple external access.
- Cons: Fixed port on all nodes, often in a high range (e.g., 30000-32767).
LoadBalancer for Cloud
For cloud providers (like AWS, GCP, Azure), the LoadBalancer Service type is ideal.
It provisions an external cloud load balancer, which then routes traffic to your Service. This gives you a dedicated, public IP address for your application.
- Managed: Cloud provider handles the load balancer.
- Public IP: Easy external access with a well-known IP.
Ingress for HTTP Routing
While Services handle basic network exposure, Ingress provides more advanced HTTP and HTTPS routing.
Ingress lets you define rules for incoming traffic based on hostname or URL path, directing it to different Services. Think of it as a smart router for web traffic.
K8s Network Concepts
Time for a quick check on what we've learned!
K8s Networking Summary
Great job! You've covered the essentials of Kubernetes networking.
- Pods: Get unique IPs, communicate directly.
- CNI: Enables Pod networking.
- Services: Provide stable endpoints for ephemeral Pods (ClusterIP, NodePort, LoadBalancer).
- Ingress: Manages external HTTP/HTTPS routing to Services.
These components work together to provide robust and flexible networking for your containerized applications.
คำถามที่พบบ่อย
บทเรียน “พื้นฐานเครือข่าย Kubernetes” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “พื้นฐานเครือข่าย Kubernetes” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Linux Networking & TCP/IP for Developers ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Linux Networking & TCP/IP for Developers มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “พื้นฐานเครือข่าย Kubernetes”
เรียนรู้วิธีที่พ็อด บริการ และอินเกรสสื่อสารกันภายในคลัสเตอร์ Kubernetes รวมถึงแนวคิดพื้นฐานของ CNI คุณปฏิบัติ Linux Networking & TCP/IP for Developers ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Linux Networking & TCP/IP for Developers หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Linux Networking & TCP/IP for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “พื้นฐานเครือข่าย Kubernetes” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Linux Networking & TCP/IP for Developers นี้ได้ไหม
ได้ บทเรียน Linux Networking & TCP/IP for Developers ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- โหมดเครือข่ายของ Docker
- พื้นฐานเครือข่าย Kubernetes
- นโยบายเครือข่ายในคอนเทนเนอร์
- การค้นหาบริการและ DNS ใน Kubernetes