diff --git a/README.md b/README.md index f6f05e7..1da50ff 100644 --- a/README.md +++ b/README.md @@ -105,4 +105,4 @@ With the help of Redis Pub/Sub we are able to understand master changes live tha ## TODO * [x] Add error handling for HAProxy commands -* [ ] Add probes and resources to K8s Chart +* [x] Add probes and resources to K8s Chart diff --git a/charts/haproxy-redis-sentinel/Chart.yaml b/charts/haproxy-redis-sentinel/Chart.yaml index 0be1bf1..e9bbbd8 100644 --- a/charts/haproxy-redis-sentinel/Chart.yaml +++ b/charts/haproxy-redis-sentinel/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: haproxy-redis-sentinel description: A Helm chart for HAProxy with Redis Sentinel version: 0.0.21 -appVersion: "0.0.10" +appVersion: "0.1.0" icon: https://raw.githubusercontent.com/ParminCloud/haproxy-redis-sentinel/master/docs/icon.png sources: - https://github.com/ParminCloud/haproxy-redis-sentinel diff --git a/charts/haproxy-redis-sentinel/README.md b/charts/haproxy-redis-sentinel/README.md index 4deb2bb..37bcf64 100644 --- a/charts/haproxy-redis-sentinel/README.md +++ b/charts/haproxy-redis-sentinel/README.md @@ -4,7 +4,7 @@

-![Version: 0.0.20](https://img.shields.io/badge/Version-0.0.20-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.10](https://img.shields.io/badge/AppVersion-0.0.10-informational?style=flat-square) +![Version: 0.0.21](https://img.shields.io/badge/Version-0.0.21-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) A Helm chart for HAProxy with Redis Sentinel @@ -30,7 +30,9 @@ This chart can be used alongside every chart that provides access to Redis Senti | Key | Type | Default | Description | |-----|------|---------|-------------| | fullnameOverride | string | `""` | overrides name of the components entirely | -| haproxy.image | object | `{"pullPolicy":"IfNotPresent","repository":"docker.io/library/haproxy","tag":"bookworm"}` | HAProxy Image | +| haproxy.image | object | `{"pullPolicy":"IfNotPresent","repository":"docker.io/library/haproxy","tag":"3.1-bookworm"}` | HAProxy Image | +| haproxy.maxConn | string | `nil` | Sets MaxConnections on HAProxy | +| haproxy.resources | object | `{}` | HAProxy resources | | haproxy.service.port | int | `6379` | Redis Master connection service port | | haproxy.service.statsPort | int | `8404` | HAProxy stats port (if enabled) | | haproxy.service.type | string | `"ClusterIP"` | Service Type | @@ -38,11 +40,15 @@ This chart can be used alongside every chart that provides access to Redis Senti | haproxy.stats.metrics.enabled | bool | `true` | Enables stats metrics for HAProxy | | haproxy.stats.metrics.serviceMonitor.enabled | bool | `false` | Enables Prometheus operator serviceMonitor to point to stats metrics | | haproxy.stats.refresh | int | `10` | Stats refresh interval | +| haproxy.timeouts.client | string | `"330s"` | HAProxy Client timeout | +| haproxy.timeouts.connect | string | `"4s"` | HAProxy Connect timeout | +| haproxy.timeouts.server | string | `"330s"` | HAProxy Server timeout | | haproxyRedisSentinel.image.pullPolicy | string | `"IfNotPresent"` | haproxy-redis-sentinel image pullPolicy (set to Always if you want to use branched tags) | | haproxyRedisSentinel.image.repository | string | `"ghcr.io/parmincloud/haproxy-redis-sentinel"` | haproxy-redis-sentinel image repository | | haproxyRedisSentinel.image.tag | string | `""` | haproxy-redis-sentinel image tag (defaults to appVersion of chart) | +| haproxyRedisSentinel.resources | object | `{}` | haproxy-redis-sentinel resources | | haproxyRedisSentinel.sentinel | object | `{"host":"","masterName":"mymaster","password":"","port":""}` | Redis Sentinel information | -| nameOverride | string | `""` | overrides name of the chart | +| nameOverride | string | `""` | overrides name of the suffix used for resources (defaults to `haproxy`) | | replicaCount | int | `1` | number of replicas for deployment | ---------------------------------------------- diff --git a/charts/haproxy-redis-sentinel/templates/_helpers.tpl b/charts/haproxy-redis-sentinel/templates/_helpers.tpl index 0c7bf73..fe0824f 100644 --- a/charts/haproxy-redis-sentinel/templates/_helpers.tpl +++ b/charts/haproxy-redis-sentinel/templates/_helpers.tpl @@ -1,5 +1,5 @@ {{- define "haproxy-redis-sentinel.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- default "haproxy" .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} {{/* @@ -11,7 +11,7 @@ If release name contains chart name it will be used as a full name. {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} +{{- $name := default "haproxy" .Values.nameOverride }} {{- if contains $name .Release.Name }} {{- .Release.Name | trunc 63 | trimSuffix "-" }} {{- else }} diff --git a/charts/haproxy-redis-sentinel/templates/configmap.yaml b/charts/haproxy-redis-sentinel/templates/configmap.yaml index afa753d..ee3cd49 100644 --- a/charts/haproxy-redis-sentinel/templates/configmap.yaml +++ b/charts/haproxy-redis-sentinel/templates/configmap.yaml @@ -10,6 +10,28 @@ data: stats socket /var/run/haproxy/haproxy.sock user haproxy group haproxy mode 660 level admin stats timeout 2m + defaults + mode tcp + timeout connect {{ .Values.haproxy.timeouts.connect }} + timeout server {{ .Values.haproxy.timeouts.server }} + timeout client {{ .Values.haproxy.timeouts.client }} + {{- if .Values.haproxy.maxConn | kindIs "int" }} + maxconn {{ .Values.haproxy.maxConn }} + {{- end }} + + frontend livez + bind *:8888 + mode http + monitor-uri /livez + option dontlognull + + frontend readyz + bind *:8889 + mode http + monitor-uri /readyz + monitor fail if { nbsrv(redis_master_server) eq 0 } + option dontlognull + {{ if .Values.haproxy.stats.enabled -}} frontend stats bind *:8404 @@ -24,9 +46,9 @@ data: frontend redis_master bind *:6379 - default_backend redis_master + default_backend redis_master_server - backend redis_master + backend redis_master_server balance source hash-type consistent diff --git a/charts/haproxy-redis-sentinel/templates/deployment.yaml b/charts/haproxy-redis-sentinel/templates/deployment.yaml index bafb577..7012604 100644 --- a/charts/haproxy-redis-sentinel/templates/deployment.yaml +++ b/charts/haproxy-redis-sentinel/templates/deployment.yaml @@ -16,6 +16,8 @@ spec: spec: containers: - name: haproxy + resources: +{{ toYaml .Values.haproxy.resources | default "{}" | indent 11 }} image: {{ .Values.haproxy.image.repository }}:{{ .Values.haproxy.image.tag }} imagePullPolicy: {{ .Values.haproxy.image.pullPolicy }} volumeMounts: @@ -33,18 +35,30 @@ spec: - name: redis containerPort: 6379 protocol: TCP - livenessProbe: - failureThreshold: 3 - tcpSocket: - port: 6379 + - name: readyz + containerPort: 8889 + protocol: TCP + - name: livez + containerPort: 8888 + protocol: TCP + readinessProbe: + httpGet: + port: readyz + path: /readyz initialDelaySeconds: 5 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 + periodSeconds: 3 + livenessProbe: + httpGet: + port: livez + path: /livez + initialDelaySeconds: 10 + periodSeconds: 3 securityContext: runAsUser: 0 - name: haproxy-redis-sentinel + resources: +{{ toYaml .Values.haproxyRedisSentinel.resources | default "{}" | indent 11 }} image: {{ .Values.haproxyRedisSentinel.image.repository }}:{{ .Values.haproxyRedisSentinel.image.tag | default .Chart.AppVersion }} imagePullPolicy: {{ .Values.haproxyRedisSentinel.image.pullPolicy }} env: @@ -56,6 +70,8 @@ spec: value: {{ .Values.haproxyRedisSentinel.sentinel.port | quote }} - name: MASTER_NAME value: {{ .Values.haproxyRedisSentinel.sentinel.masterName }} + - name: HAPROXY_BACKEND + value: redis_master_server volumeMounts: - name: haproxy-socket mountPath: /var/run/haproxy/ diff --git a/charts/haproxy-redis-sentinel/values.yaml b/charts/haproxy-redis-sentinel/values.yaml index 9bcb588..c0da67c 100644 --- a/charts/haproxy-redis-sentinel/values.yaml +++ b/charts/haproxy-redis-sentinel/values.yaml @@ -3,15 +3,24 @@ replicaCount: 1 # -- overrides name of the components entirely fullnameOverride: "" -# -- overrides name of the chart +# -- overrides name of the suffix used for resources (defaults to `haproxy`) nameOverride: "" haproxy: # -- HAProxy Image image: repository: docker.io/library/haproxy - tag: bookworm + tag: 3.1-bookworm pullPolicy: "IfNotPresent" + timeouts: + # -- HAProxy Connect timeout + connect: 4s + # -- HAProxy Server timeout + server: 330s + # -- HAProxy Client timeout + client: 330s + # -- Sets MaxConnections on HAProxy + maxConn: null stats: # -- Enables HAProxy Stats enabled: true @@ -30,6 +39,8 @@ haproxy: port: 6379 # -- HAProxy stats port (if enabled) statsPort: 8404 + # -- HAProxy resources + resources: {} haproxyRedisSentinel: image: @@ -45,4 +56,5 @@ haproxyRedisSentinel: host: "" port: "" masterName: "mymaster" - + # -- haproxy-redis-sentinel resources + resources: {}