semural
semural

Reputation: 4611

Helm Chart ServicePort and Ingress with Https

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

Upvotes: 3

Views: 8608

Answers (1)

Noé
Noé

Reputation: 508

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.

Upvotes: 6

Related Questions