Helm Chart ServicePort 和 Ingress with Https

sem*_*ral 3 kubernetes-helm kubernetes-ingress

在设置 Ingress 以及与 Helm 3 中的部署和服务资源映射期间使用 https 的 Web 应用程序的配置应该是什么。

我应该在 Service.ports 下定义 https 端口和名称还是只更改 Service.Port 名称和端口?或者使用 TLS 已经涵盖了这一点?

   ports:
      port: {{ .Values.service.port }}
      targetPort: 80
      protocol: TCP
      name: http

      name:https
      port:443
Run Code Online (Sandbox Code Playgroud)

服务.yaml

  spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: 80
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: {{ include "road-dashboard.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
Run Code Online (Sandbox Code Playgroud)

Ingress.yaml

  ingress:
  enabled: false
  annotations: 
    kubernetes.io/ingress.class: traefik
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths: []
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local



    kubectl get ingress

    NAME                        HOSTS   ADDRESS   PORTS   AGE
    ingress-traefik-dashboard   *                 80      42h
Run Code Online (Sandbox Code Playgroud)

小智 6

Tls 设置是通过 ingress 完成的。所以你需要你的入口重定向到你的服务。您不需要在服务中创建 https 端口,入口的工作就是处理该端口。

你的配置将是这样的:

入口:

rules:
 - host: example.com
   http:
    paths:
    - path: /api($|/)(.*)
      backend:
        serviceName: "{{ .Release.Name }}-api-service"
        servicePort: {{ .Values.service.port }}
Run Code Online (Sandbox Code Playgroud)

服务:

metadata:
  name: "{{ .Release.Name }}-api-service"
spec:
  ports:
    - port: {{ .Values.service.port }}
      targetPort: 80
      name: http
  type: {{ .Values.service.type }}
Run Code Online (Sandbox Code Playgroud)

Ingress 和 Service 并不完整,它只强调了重要的部分。