ingress.yaml


Overview

The ingress.yaml file is a Kubernetes manifest template configured using Helm templating syntax. Its primary purpose is to define an Ingress resource for a Kubernetes cluster that routes external HTTP(S) traffic to internal services. This file enables dynamic configuration of ingress rules, TLS settings, annotations, and ingress class based on Helm chart values, allowing flexible and customizable exposure of services.

In summary, this file facilitates:


Detailed Explanation

Template Conditional

{{- if .Values.ingress.enabled -}}
...
{{- end }}

API Version and Kind

apiVersion: networking.k8s.io/v1
kind: Ingress

Metadata Section

metadata:
  name: {{ include "ragflow.fullname" . }}
  labels:
    {{- include "ragflow.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}

Spec Section

spec:
  {{- with .Values.ingress.className }}
  ingressClassName: {{ . }}
  {{- end }}
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ .path }}
            {{- with .pathType }}
            pathType: {{ . }}
            {{- end }}
            backend:
              service:
                name: {{ $.Release.Name }}
                port:
                  name: http
          {{- end }}
    {{- end }}

ingressClassName

TLS Configuration

Rules


Parameters and Values

This file relies heavily on Helm values defined in the values.yaml file (not included here). Key parameters include:

Parameter

Type

Description

Required

Default

ingress.enabled

boolean

Enables or disables creation of the Ingress resource

Yes

false

ingress.annotations

map[string]string

Custom annotations to add to the Ingress metadata

No

ingress.className

string

Name of the IngressClass to use

No

ingress.tls

list

List of TLS configurations, each with hosts and secret name

No

ingress.hosts

list

List of host configurations, each with host and paths

Yes

Example snippet of values.yaml for ingress:

ingress:
  enabled: true
  className: "nginx"
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
  tls:
    - hosts:
        - example.com
      secretName: example-tls
  hosts:
    - host: example.com
      paths:
        - path: /
          pathType: Prefix

Usage Examples

Enabling Ingress with TLS and Multiple Hosts

In your Helm values.yaml:

ingress:
  enabled: true
  className: "nginx"
  annotations:
    kubernetes.io/ingress.class: "nginx"
  tls:
    - hosts:
        - "app.example.com"
      secretName: app-tls-secret
  hosts:
    - host: "app.example.com"
      paths:
        - path: /
          pathType: Prefix

Then install or upgrade the Helm chart:

helm install ragflow ./chart --values values.yaml

This will generate an Ingress resource exposing the service under app.example.com with TLS termination.


Implementation Details and Algorithms


Interaction with Other System Components


Visual Diagram

flowchart TD
    A[Start: Check ingress.enabled] -->|enabled=true| B[Ingress Resource Creation]
    A -->|enabled=false| Z[No Ingress Created]

    B --> C[Set metadata.name using ragflow.fullname]
    B --> D[Set metadata.labels using ragflow.labels]
    B --> E{Annotations?}
    E -->|Yes| F[Add annotations]
    E -->|No| G[Skip annotations]

    B --> H{ingress.className?}
    H -->|Yes| I[Set ingressClassName]
    H -->|No| J[Skip ingressClassName]

    B --> K{TLS configuration?}
    K -->|Yes| L[Add TLS hosts and secretNames]
    K -->|No| M[Skip TLS]

    B --> N[Configure rules for each host]
    N --> O[For each host: define host and http.paths]
    O --> P[For each path: set path, pathType, backend service and port]

    P --> Q[Ingress Resource Complete]

Summary

This ingress.yaml Helm template dynamically generates a Kubernetes Ingress resource based on user-defined values. It supports flexible configuration of ingress class, annotations, TLS certificates, and multiple host/path rules, allowing robust routing of external traffic to internal services. Its tight integration with Helm values and helper templates ensures reusable, environment-specific deployments within Kubernetes clusters.