Problem with ingress and custom helm chart

Hello.

I created my own helm chart that I deploy on Rancher 2 using a custom catalog, but I experience some problems (i used wordpress chart as example).

When I try to deploy I see this as result:

Failed to install app ezp-legacy-xxnps. Error: release ezp-legacy-xxnps failed: Ingress.extensions "ezp-legacy-xxnps" is invalid: spec.rules[0].host: Invalid value: "map[name:xip.io]": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

It is interesting that xip.io or whatever i set as domain doesn’t work. It always complains with the error above.

I hope that someone can give me some idea how to solve this problem.

Thanks and regards,
Ali

Ingress.yaml:

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "ezp-legacy.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "{{- printf "%s-%s" .name $.Release.Name | trunc 63 | trimSuffix "-" -}}"
  labels:
    app.kubernetes.io/name: {{ include "ezp-legacy.name" . }}
    helm.sh/chart: {{ include "ezp-legacy.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . | quote }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  {{- range .Values.ingress.hosts }}
    - host: {{ . | quote }}
      http:
        paths:
          - path: {{ $ingressPath }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: http
  {{- end }}
{{- end }}


Values.yaml

## Configure the ingress resource that allows you to access the
## ezPublish installation. Set up the URL
## ref: http://kubernetes.io/docs/user-guide/ingress/
##
ingress:
  ## Set to true to enable ingress record generation
  enabled: false
  
  ## Set this to true in order to add the corresponding annotations for cert-manager
  certManager: false

  ## The list of hostnames to be covered with this ingress record.
  ## Most likely this will be just one host, but in the event more hosts are needed, this is an array
  ## Please make sure to change the name and tlsSecret to your own settings
  hosts:
  - name: domain.tld

    ## Set this to true in order to enable TLS on the ingress record
    ## A side effect of this will be that the backend wordpress service will be connected at port 443
    tls: false

    ## Ingress annotations done as key:value pairs
    ## For a full list of possible ingress annotations, please see
    ## ref: https://github.com/kubernetes/ingress-nginx/blob/master/docs/annotations.md
    ##
    ## If tls is set to true, annotation ingress.kubernetes.io/secure-backends: "true" will automatically be set
    ## If certManager is set to true, annotation kubernetes.io/tls-acme: "true" will automatically be set
    annotations:
      #  kubernetes.io/ingress.class: nginx
      #  kubernetes.io/tls-acme: true

Questions.yaml:

- variable: ingress.enabled
  default: false
  description: "Expose app using Layer 7 Load Balancer - ingress"
  type: boolean
  label: Expose app using Layer 7 Load Balancer
  show_subquestion_if: true
  group: "Services and Load Balancing"
  subquestions:
  - variable: ingress.hosts[0].name
    default: "domain.tld"
    description: "Hostname to your ezPublish installation"
    type: hostname
    required: true
    label: Hostname

Hosts is an array of maps but you’re treating it like it were an array of strings when you range over it (both times). So when you try to use the first host as a string, it gets turned into one, “map[…contents…]”, which is an invalid hostname regardless of what the contents are.

Thank you very much for explanation.

I am still new with helm and all the config. I would like to support entering multiple hosts in Rancher fields, how should I change the config in this case?

From what I understand I have it wrong in questions file. I changed
variable: ingress.hosts[0].name
to
variable: ingress.hosts[0]

And it seems like working, but correct me if I am wrong :slight_smile:

I still need to learn how to define and pass multiple hostnames. Can you give me some advice for this?