Skip to content

Commit

Permalink
🩺 Making chart more stable to suitable
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
  • Loading branch information
mhkarimi1383 committed Jan 24, 2025
1 parent 1916c51 commit f9029f7
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion charts/haproxy-redis-sentinel/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions charts/haproxy-redis-sentinel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img width="33%" src="https://raw.githubusercontent.com/ParminCloud/haproxy-redis-sentinel/master/docs/icon.png">
</p>

![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

Expand All @@ -30,19 +30,25 @@ 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 |
| haproxy.stats.enabled | bool | `true` | Enables HAProxy Stats |
| 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 |

----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions charts/haproxy-redis-sentinel/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}

{{/*
Expand All @@ -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 }}
Expand Down
26 changes: 24 additions & 2 deletions charts/haproxy-redis-sentinel/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
30 changes: 23 additions & 7 deletions charts/haproxy-redis-sentinel/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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/
Expand Down
18 changes: 15 additions & 3 deletions charts/haproxy-redis-sentinel/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +39,8 @@ haproxy:
port: 6379
# -- HAProxy stats port (if enabled)
statsPort: 8404
# -- HAProxy resources
resources: {}

haproxyRedisSentinel:
image:
Expand All @@ -45,4 +56,5 @@ haproxyRedisSentinel:
host: ""
port: ""
masterName: "mymaster"

# -- haproxy-redis-sentinel resources
resources: {}

0 comments on commit f9029f7

Please sign in to comment.