Helm Chart ServicePort and Ingress with Https

1/16/2020

What should be the configuration for web application using https during setup Ingress and mapping with the Deployment and Service resources in Helm 3.

Should I define https port and name below Service.ports or just change Service.Port name and port? Or using TLS already cover this?

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

      name:https
      port:443

Service.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 }}

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
-- semural
kubernetes-helm
kubernetes-ingress

1 Answer

1/17/2020

Tls setup is done through ingress. So you need your ingress to redirect to your service. You don't need to create an https port in your service, it's the job of the ingress to deal with that.

Your configuration will be something like that:

Ingress:

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

Service:

metadata:
  name: "{{ .Release.Name }}-api-service"
spec:
  ports:
    - port: {{ .Values.service.port }}
      targetPort: 80
      name: http
  type: {{ .Values.service.type }}

Ingress and Service are not complete, it underlines only the important parts.

-- NoƩ
Source: StackOverflow