apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: kubernetes.io/tls-acme: "true" nginx.ingress.kubernetes.io/permanent-redirect-code: "301" kubernetes.io/ingress.class: "nginx" ingress.kubernetes.io/ssl-redirect: "true" ingress.kubernetes.io/secure-backends: "true" ingress.kubernetes.io/force-ssl-redirect: "true" name: blog-ingress namespace: blog spec: ingressClassName: nginx rules: - host: blog.offends.cn http: paths: - pathType: Prefix backend: service: name: blog-gateway port: number: 80 path: / # 只有在启用 TLS 时才需要此部分 tls: - hosts: - blog.offends.cn secretName: blog-tls