Skip to content

Commit

Permalink
Merge pull request #11 from mhyllander/new-features
Browse files Browse the repository at this point in the history
Additional features: extra volumes, expose controller metrics port
  • Loading branch information
jcmoraisjr authored Feb 17, 2021
2 parents e326b90 + 2932622 commit 7ab9ace
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 29 deletions.
7 changes: 5 additions & 2 deletions haproxy-ingress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Parameter | Description | Default
`controller.image.tag` | controller container image tag | `v0.12-beta.2`
`controller.image.pullPolicy` | controller container image pullPolicy | `IfNotPresent`
`controller.imagePullSecrets` | controller image pull secrets | `[]`
`controller.initContainers` | extra containers that can initialize the haproxy-ingress-controller | `[]`
`controller.extraArgs` | extra command line arguments for the haproxy-ingress-controller | `{}`
`controller.extraEnv` | extra environment variables for the haproxy-ingress-controller | `{}`
`controller.extraEnvs` | extra environment variables for the haproxy-ingress-controller | `[]`
`controller.extraVolumes` | extra volumes for the haproxy-ingress-controller | `[]`
`controller.extraVolumeMounts` | extra volume mounts for the haproxy-ingress-controller | `[]`
`controller.initContainers` | extra containers that can initialize the haproxy-ingress-controller | `[]`
`controller.template` | custom template for haproxy-ingress-controller | `{}`
`controller.defaultBackendService` | backend service to use if defaultBackend.enabled==false | `""`
`controller.ingressClass` | name of the ingress class to route through this controller | `haproxy`
Expand Down Expand Up @@ -156,6 +158,7 @@ Parameter | Description | Default
`controller.metrics.enabled` | If `controller.stats.enabled = true` and `controller.metrics.enabled = true`, Prometheus metrics will be exported | `false`
`controller.metrics.embedded` | defines if embedded haproxy's exporter should be used | `true`
`controller.metrics.port` | port number the exporter is listening to | `9101`
`controller.metrics.controllerPort` | port number the controller is exporting metrics on | `10254`
`controller.metrics.image.repository` | prometheus-exporter image repository when embedded is `false` | `quay.io/prometheus/haproxy-exporter`
`controller.metrics.image.tag` | prometheus-exporter image tag | `v0.11.0`
`controller.metrics.image.pullPolicy` | prometheus-exporter image pullPolicy | `IfNotPresent`
Expand Down
73 changes: 46 additions & 27 deletions haproxy-ingress/templates/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ spec:
- --{{ $key }}
{{- end }}
{{- end }}
{{- if or (not .Values.controller.haproxy.enabled) .Values.controller.metrics.enabled }}
ports:
{{- if not .Values.controller.haproxy.enabled }}
{{- include "haproxy-ingress.controller.ports" . | indent 8 }}
{{- end }}
{{- if .Values.controller.metrics.enabled }}
- name: controller-metrics
containerPort: {{ .Values.controller.metrics.controllerPort }}
protocol: TCP
{{- end }}
{{- end }}
{{- if not .Values.controller.haproxy.enabled }}
{{- include "haproxy-ingress.controller.ports" . | nindent 6 }}
{{- include "haproxy-ingress.controller.probes" . | nindent 6 }}
{{- include "haproxy-ingress.controller.probes" . | indent 6 }}
{{- end }}
env:
- name: POD_NAME
Expand All @@ -81,7 +91,7 @@ spec:
{{- if .Values.controller.extraEnvs }}
{{- toYaml .Values.controller.extraEnvs | nindent 8 }}
{{- end }}
{{- if or .Values.controller.haproxy.enabled .Values.controller.template }}
{{- if or .Values.controller.haproxy.enabled .Values.controller.template .Values.controller.extraVolumeMounts }}
volumeMounts:
{{- if .Values.controller.haproxy.enabled }}
- mountPath: /etc/haproxy
Expand All @@ -95,6 +105,9 @@ spec:
- name: haproxy-template
mountPath: /etc/templates/haproxy
{{- end }}
{{- if .Values.controller.extraVolumeMounts }}
{{- toYaml .Values.controller.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.controller.resources | nindent 8 }}
Expand All @@ -115,8 +128,9 @@ spec:
- --{{ $key }}
{{- end }}
{{- end }}
{{- include "haproxy-ingress.controller.ports" . | nindent 6 }}
{{- include "haproxy-ingress.controller.probes" . | nindent 6 }}
ports:
{{- include "haproxy-ingress.controller.ports" . | indent 8 }}
{{- include "haproxy-ingress.controller.probes" . | indent 6 }}
resources:
{{- toYaml .Values.controller.haproxy.resources | nindent 8 }}
volumeMounts:
Expand All @@ -126,6 +140,9 @@ spec:
name: lib
- mountPath: /var/run/haproxy
name: run
{{- if .Values.controller.extraVolumeMounts }}
{{- toYaml .Values.controller.extraVolumeMounts | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.controller.logs.enabled }}
- name: access-logs
Expand Down Expand Up @@ -167,7 +184,7 @@ spec:
imagePullSecrets:
{{- toYaml .Values.controller.imagePullSecrets | nindent 4 }}
{{- end }}
{{- if or .Values.controller.haproxy.enabled .Values.controller.template }}
{{- if or .Values.controller.haproxy.enabled .Values.controller.template .Values.controller.extraVolumes }}
volumes:
{{- if .Values.controller.haproxy.enabled }}
- name: etc
Expand All @@ -182,6 +199,9 @@ spec:
configMap:
name: {{ include "haproxy-ingress.fullname" . }}-template
{{- end }}
{{- if .Values.controller.extraVolumes }}
{{- toYaml .Values.controller.extraVolumes | nindent 4 }}
{{- end }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
dnsPolicy: {{ .Values.controller.dnsPolicy }}
Expand All @@ -207,47 +227,46 @@ spec:
{{- end }}
{{- end }}

{{- define "haproxy-ingress.controller.ports" -}}
ports:
{{- define "haproxy-ingress.controller.ports" }}
{{- if .Values.controller.enableStaticPorts }}
- name: http
containerPort: 80
- name: http
containerPort: 80
{{- if and (eq .Values.controller.kind "DaemonSet") .Values.controller.daemonset.useHostPort .Values.controller.daemonset.hostPorts.http }}
hostPort: {{ .Values.controller.daemonset.hostPorts.http }}
hostPort: {{ .Values.controller.daemonset.hostPorts.http }}
{{- end }}
- name: https
containerPort: 443
- name: https
containerPort: 443
{{- if and (eq .Values.controller.kind "DaemonSet") .Values.controller.daemonset.useHostPort .Values.controller.daemonset.hostPorts.https }}
hostPort: {{ .Values.controller.daemonset.hostPorts.https }}
hostPort: {{ .Values.controller.daemonset.hostPorts.https }}
{{- end }}
{{- end }}
{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.embedded }}
- name: metrics
containerPort: {{ .Values.controller.metrics.port }}
protocol: TCP
- name: metrics
containerPort: {{ .Values.controller.metrics.port }}
protocol: TCP
{{- end }}
{{- if .Values.controller.stats.enabled }}
- name: stats
containerPort: {{ .Values.controller.stats.port }}
protocol: TCP
- name: stats
containerPort: {{ .Values.controller.stats.port }}
protocol: TCP
{{- end }}
- name: healthz
containerPort: {{ .Values.controller.healthzPort }}
- name: healthz
containerPort: {{ .Values.controller.healthzPort }}
{{- range $key, $value := .Values.controller.tcp }}
- name: "{{ $key }}-tcp"
containerPort: {{ $key }}
protocol: TCP
- name: "{{ $key }}-tcp"
containerPort: {{ $key }}
protocol: TCP
{{- if and (eq $.Values.controller.kind "DaemonSet") $.Values.controller.daemonset.useHostPort }}
{{- range $p := $.Values.controller.daemonset.hostPorts.tcp }}
{{- if eq $key $p }}
hostPort: {{ $key }}
hostPort: {{ $key }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{- define "haproxy-ingress.controller.probes" -}}
{{- define "haproxy-ingress.controller.probes" }}
livenessProbe:
httpGet:
path: {{ .Values.controller.livenessProbe.path | quote }}
Expand Down
8 changes: 8 additions & 0 deletions haproxy-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ controller:
# key: FOO
# name: secret-resource

## Additional volumes and volume mounts
extraVolumes: []
extraVolumeMounts: []

## Additional containers that can initialize the pod.
initContainers: []

Expand Down Expand Up @@ -274,6 +278,10 @@ controller:
# Port number the exporter is listening to
port: 9101

# The port the controller exports metrics on.
# If you change it here, you must also change it using the controller.extraArgs.
controllerPort: 10254

# prometheus exporter for haproxy
# https://github.com/prometheus/haproxy_exporter
# (scrapes the stats port and exports metrics to prometheus)
Expand Down

0 comments on commit 7ab9ace

Please sign in to comment.