diff --git a/haproxy-ingress/README.md b/haproxy-ingress/README.md index c8517fc..68b7d1e 100644 --- a/haproxy-ingress/README.md +++ b/haproxy-ingress/README.md @@ -202,6 +202,7 @@ Parameter | Description | Default `controller.service.httpPorts` | The http ports to open, that map to the Ingress' port 80. Each entry specifies a `port`, `targetPort` and an optional `nodePort`. | `[ port: 80, targetPort: http ]` `controller.service.httpsPorts` | The https ports to open, that map to the Ingress' port 443. Each entry specifies a `port`, `targetPort` and an optional `nodePort`. | `[ port: 443 , targetPort: https]` `controller.service.type` | type of controller service to create | `LoadBalancer` +`controller.extraServices` | The list of extra controller services. Each service accepts `controller.service` keys. | `[]` `controller.stats.enabled` | whether to enable exporting stats | `false` `controller.stats.port` | The port number used haproxy-ingress-controller for haproxy statistics | `1936` `controller.stats.hostPort` | The host port number used haproxy-ingress-controller for haproxy statistics | `~` diff --git a/haproxy-ingress/templates/controller-service.yaml b/haproxy-ingress/templates/controller-service.yaml index c103cb8..b1c5331 100644 --- a/haproxy-ingress/templates/controller-service.yaml +++ b/haproxy-ingress/templates/controller-service.yaml @@ -88,3 +88,95 @@ spec: selector: {{- include "haproxy-ingress.selectorLabels" . | nindent 4 }} type: "{{ .Values.controller.service.type }}" +{{- range $i, $svc := .Values.controller.extraServices }} +--- +kind: Service +metadata: +{{- if $svc.annotations }} + annotations: + {{- toYaml $svc.annotations | nindent 4 }} +{{- end }} + labels: + {{- include "haproxy-ingress.labels" $ | nindent 4 }} +{{- if $svc.labels }} + {{- toYaml $svc.labels | nindent 4 }} +{{- end }} + name: {{ include "haproxy-ingress.fullname" $ }}-extra-{{ $i }} + namespace: {{ $.Release.Namespace }} +spec: +{{- if $svc.clusterIP }} + clusterIP: "{{ $svc.clusterIP }}" +{{- end }} +{{- if $svc.clusterIPs }} + clusterIPs: + {{- toYaml $svc.clusterIPs | nindent 4 }} +{{- end }} +{{- if or $svc.externalTrafficPolicy $.Values.controller.service.externalTrafficPolicy }} +{{- if or (eq (default $.Values.controller.service.type $svc.type) "NodePort") (eq (default $.Values.controller.service.type $svc.type) "LoadBalancer") }} + externalTrafficPolicy: "{{ default $.Values.controller.service.externalTrafficPolicy $svc.externalTrafficPolicy }}" +{{- end }} +{{- end }} +{{- if $svc.externalIPs }} + externalIPs: + {{- toYaml $svc.externalIPs | nindent 4 }} +{{- end }} +{{- if $svc.ipFamilies }} + ipFamilies: + {{- toYaml $svc.ipFamilies | nindent 4 }} +{{- end }} +{{- if $svc.ipFamilyPolicy }} + ipFamilyPolicy: {{ $svc.ipFamilyPolicy | quote }} +{{- end }} +{{- if $svc.loadBalancerClass }} + loadBalancerClass: "{{ $svc.loadBalancerClass }}" +{{- end }} +{{- if $svc.loadBalancerIP }} + loadBalancerIP: "{{ $svc.loadBalancerIP }}" +{{- end }} +{{- if $svc.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- toYaml $svc.loadBalancerSourceRanges | nindent 4 }} +{{- end }} +{{- if ($svc.healthCheckNodePort) }} + healthCheckNodePort: {{ $svc.healthCheckNodePort }} +{{- end }} + ports: +{{- if $.Values.controller.enableStaticPorts }} + {{- range default $.Values.controller.service.httpPorts $svc.httpPorts }} + - name: "http-{{ .port }}" + port: {{ .port }} + protocol: TCP + targetPort: {{ .targetPort | default "http" }} + {{- if (not (empty .nodePort)) }} + nodePort: {{ .nodePort }} + {{- end }} + {{- end }} + {{- range default $.Values.controller.service.httpsPorts $svc.httpsPorts }} + - name: "https-{{ .port }}" + port: {{ .port }} + protocol: TCP + targetPort: {{ .targetPort | default "https" }} + {{- if (not (empty .nodePort)) }} + nodePort: {{ .nodePort }} + {{- end }} + {{- end }} +{{- end }} +{{- range $key, $value := $.Values.controller.tcp }} + - name: "{{ tpl $key $ }}-tcp" + port: {{ tpl $key $ }} + protocol: TCP + targetPort: "{{ tpl $key $ }}-tcp" +{{- end }} +{{- range $row := $svc.extraPorts }} + - name: "extra-port-{{ $row.port }}" + port: {{ $row.port }} + protocol: TCP + targetPort: {{ $row.targetPort }} + {{- if (not (empty $row.nodePort)) }} + nodePort: {{ $row.nodePort }} + {{- end }} +{{- end }} + selector: + {{- include "haproxy-ingress.selectorLabels" $ | nindent 4 }} + type: "{{ default $.Values.controller.service.type $svc.type }}" +{{- end }} diff --git a/haproxy-ingress/values.yaml b/haproxy-ingress/values.yaml index 46f6746..071c3ac 100644 --- a/haproxy-ingress/values.yaml +++ b/haproxy-ingress/values.yaml @@ -332,6 +332,10 @@ controller: type: LoadBalancer + ## Add extra services + ## Refer to controller.service for available keys + extraServices: [] + ## If controller.haproxy.enabled = true, an external haproxy instance ## is configured and managed as a sidecar container haproxy: