Docker & Kubernetes for Developers · Lezione

Terminazione TLS e protezione dell'Ingress con HTTPS

Serva il traffico tramite HTTPS configurando TLS sull'Ingress, memorizzando i certificati come Secrets e automatizzandone il rilascio con cert-manager.

Lezione 4 di 413 passaggi

Terminazione TLS e protezione dell'Ingress con HTTPS è una lezione Docker & Kubernetes for Developers gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Docker & Kubernetes for Developers, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Docker & Kubernetes for Developers include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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.key

Adding 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: 80

How 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: nginx

Annotating 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-prod

HTTP-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:443

Quick 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.

Gratis per iniziare

Impara Docker & Kubernetes for Developers con un tutor IA — gratis

Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.

Corsi
12
Lezioni
48

Domande Frequenti

La lezione «Terminazione TLS e protezione dell'Ingress con HTTPS» è gratuita?

Sì — il testo completo di «Terminazione TLS e protezione dell'Ingress con HTTPS» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Docker & Kubernetes for Developers, passa a CoddyKit PRO. Il corso Docker & Kubernetes for Developers include 4 lezioni in totale.

Cosa imparerò in «Terminazione TLS e protezione dell'Ingress con HTTPS»?

Serva il traffico tramite HTTPS configurando TLS sull'Ingress, memorizzando i certificati come Secrets e automatizzandone il rilascio con cert-manager. Eserciti Docker & Kubernetes for Developers con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Docker & Kubernetes for Developers?

Non è richiesta alcuna esperienza precedente. Docker & Kubernetes for Developers su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Terminazione TLS e protezione dell'Ingress con HTTPS»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Docker & Kubernetes for Developers?

Sì. Ogni lezione Docker & Kubernetes for Developers include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Ingress e routing in Kubernetes
  2. Implementazione delle Network Policy
  3. Service discovery e DNS in K8s
  4. Terminazione TLS e protezione dell'Ingress con HTTPS
← Torna a Docker & Kubernetes for Developers