Skip to content

Commit c343792

Browse files
authored
feat: added security context (#1)
1 parent 516835e commit c343792

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: redis-cluster
33
description: A redis-cluster helm chart
44
type: application
5-
version: 0.1.0
6-
appVersion: "0.1.0"
5+
version: 0.2.0
6+
appVersion: "0.2.0"

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@ This repository contains Redis cluster helm charts that can survive pod restarts
1111
|--|--|--|
1212
`nameOverride` | String to override `redis-cluster.name` template | `redis-cluster`
1313
`fullnameOverride` | String to override `redis-cluster.fullname` `template` | `redis-cluster`
14-
`redis.image` | Redis docker image | `redis:7.2.3`
14+
`securityContext.enabled` | Whether to enable pod's container security context or not | `false`
15+
`securityContext` | Pod's security context | `{}`
16+
`redis.image` | Redis docker image | `redis:7.2.4`
1517
`redis.port` | Redis server port | `6379`
1618
`redis.bus` | Redis cluster bus port | `16379`
19+
`redis.securityContext.enabled` | Whether to enable the Redis container security context or not | `false`
20+
`redis.securityContext` | Redis container security context | `{}`
1721
`redis.resources` | The resources of the redis container | `{}`
1822
`redis.minReadySeconds` | minimum number of seconds for which a newly created Pod should be running and ready without any of its containers crashing, for it to be considered available | `10`
1923
`cluster.init` | A boolean to specify whether the cluster should be initialized. (Can be false when cluster is already created and maybe you just want to change the resources of the cluster) | `true`
2024
`cluster.master` | Number of master nodes | `3`
2125
`cluster.replicas` | Number of replicas of each master | `1`
2226
`metrics.enabled` | Turn on/off Redis exporter | `true`
23-
`metrics.image` | Docker image of Redis exporter | `oliver006/redis_exporter:v1.55.0`
27+
`metrics.image` | Docker image of Redis exporter | `oliver006/redis_exporter:v1.56.0`
28+
`metrics.securityContext.enabled` | Whether to enable metrics container security context | `false`
29+
`metrics.securityContext` | Metric's container security context | `{}`
2430
`metrics.resources` | Resources of metrics container | `{}`
2531
`metrics.serviceMonitor.enabled` | Create a service monitor if `metrics` is enabled | `true`
2632
`metrics.serviceMonitor.interval` | Metrics scraping interval | `30s`

templates/statefulset.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ spec:
1616
metadata:
1717
labels: {{ include "redis-cluster.labels" . | nindent 8 }}
1818
spec:
19+
{{- if and .Values.securityContext .Values.securityContext.enabled }}
20+
securityContext: {{ omit .Values.securityContext "enabled" | toYaml | nindent 8 }}
21+
{{- end }}
1922
initContainers:
2023
- name: fix-outdated-ips
2124
image: ubuntu:24.04
@@ -35,6 +38,9 @@ spec:
3538
containers:
3639
- name: redis
3740
image: {{ .Values.redis.image }}
41+
{{- if and .Values.redis.securityContext .Values.redis.securityContext.enabled }}
42+
securityContext: {{ omit .Values.redis.securityContext "enabled" | toYaml | nindent 12 }}
43+
{{- end }}
3844
{{- with .Values.redis.resources }}
3945
resources: {{ toYaml . | nindent 12 }}
4046
{{- end}}
@@ -57,6 +63,9 @@ spec:
5763
{{- if .enabled }}
5864
- name: metrics
5965
image: {{ .image }}
66+
{{- if and .securityContext .securityContext.enabled }}
67+
securityContext: {{ omit .securityContext "enabled" | toYaml | nindent 12 }}
68+
{{- end }}
6069
{{- with .resources }}
6170
resources: {{ toYaml . | nindent 12 }}
6271
{{- end}}

values.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@ nameOverride: ""
22
fullnameOverride: ""
33

44
redis:
5-
image: redis:7.2.3
5+
image: redis:7.2.4
66
port: 6379
77
bus: 16379
88
minReadySeconds: 0
9+
securityContext:
10+
enabled: false
911

1012
cluster:
1113
init: true
1214
master: 3
1315
replicas: 1
1416

17+
securityContext:
18+
enabled: false
19+
1520
metrics:
1621
enabled: true
17-
image: oliver006/redis_exporter:v1.55.0
22+
image: oliver006/redis_exporter:v1.56.0
1823
serviceMonitor:
1924
enabled: true
2025
interval: "30s"
26+
securityContext:
27+
enabled: false
2128

2229
service:
2330
enabled: true

0 commit comments

Comments
 (0)