การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS
ให้บริการข้อมูลผ่าน HTTPS ด้วยการกำหนดค่า TLS บน Ingress จัดเก็บใบรับรองเป็นข้อมูลลับ และทำให้การออกใบรับรองเป็นอัตโนมัติด้วย cert-manager
การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS เป็นบทเรียน Docker & Kubernetes for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Docker & Kubernetes for Developers และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why TLS at the Ingress
Terminating TLS at the Ingress lets one place handle HTTPS for many backend services, so internal apps can stay plain HTTP while users get encryption.
Certificates Live in Secrets
An Ingress references a TLS certificate stored in a Kubernetes Secret of type kubernetes.io/tls, holding a tls.crt and tls.key.
kubectl create secret tls my-tls \
--cert=tls.crt --key=tls.keyAdding a tls Block to Ingress
The spec.tls section maps hostnames to the secret that secures them.
spec:
tls:
- hosts:
- app.example.com
secretName: my-tls
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80How Termination Works
The Ingress controller decrypts incoming HTTPS, then forwards plain HTTP to the backend Service inside the cluster network.
The Certificate Renewal Problem
Certificates expire. Renewing and re-uploading them by hand is error prone, which is why automation tools exist.
Introducing cert-manager
cert-manager is an add-on that watches Ingress/Certificate resources and automatically obtains and renews certificates from issuers like Let us Encrypt.
Defining a ClusterIssuer
A ClusterIssuer tells cert-manager how to get certificates cluster-wide.
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: admin@example.com
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- http01:
ingress:
class: nginxAnnotating the Ingress
Add an annotation so cert-manager issues a cert and stores it in the named secret automatically.
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prodHTTP-01 vs DNS-01
HTTP-01 proves domain ownership by serving a token over HTTP; DNS-01 proves it via a DNS TXT record and supports wildcard certificates.
Forcing HTTPS Redirects
Most controllers redirect HTTP to HTTPS by default. With NGINX you can control it via an annotation.
metadata:
annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"Verifying the Certificate
Check the Certificate resource and inspect the served cert.
kubectl get certificate
openssl s_client -connect app.example.com:443Quick Check
Test what you have learned.
Recap
You learned to terminate TLS at the Ingress using a tls Secret, automate issuance and renewal with cert-manager and a ClusterIssuer, choose HTTP-01 vs DNS-01, and force HTTPS redirects.
เรียนรู้ Docker & Kubernetes for Developers ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Docker & Kubernetes for Developers ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS”
ให้บริการข้อมูลผ่าน HTTPS ด้วยการกำหนดค่า TLS บน Ingress จัดเก็บใบรับรองเป็นข้อมูลลับ และทำให้การออกใบรับรองเป็นอัตโนมัติด้วย cert-manager คุณปฏิบัติ Docker & Kubernetes for Developers ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Docker & Kubernetes for Developers หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Docker & Kubernetes for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Docker & Kubernetes for Developers นี้ได้ไหม
ได้ บทเรียน Docker & Kubernetes for Developers ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- Kubernetes Ingress และการกำหนดเส้นทาง
- การนำข้อกำหนดเครือข่ายไปใช้งาน
- การค้นหาบริการและ DNS ใน K8s
- การสิ้นสุด TLS และการรักษาความปลอดภัยให้ Ingress ด้วย HTTPS