Skip to content

Commit

Permalink
feat: added security context (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojixcoder authored Jan 12, 2024
1 parent 516835e commit c343792
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: redis-cluster
description: A redis-cluster helm chart
type: application
version: 0.1.0
appVersion: "0.1.0"
version: 0.2.0
appVersion: "0.2.0"
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ This repository contains Redis cluster helm charts that can survive pod restarts
|--|--|--|
`nameOverride` | String to override `redis-cluster.name` template | `redis-cluster`
`fullnameOverride` | String to override `redis-cluster.fullname` `template` | `redis-cluster`
`redis.image` | Redis docker image | `redis:7.2.3`
`securityContext.enabled` | Whether to enable pod's container security context or not | `false`
`securityContext` | Pod's security context | `{}`
`redis.image` | Redis docker image | `redis:7.2.4`
`redis.port` | Redis server port | `6379`
`redis.bus` | Redis cluster bus port | `16379`
`redis.securityContext.enabled` | Whether to enable the Redis container security context or not | `false`
`redis.securityContext` | Redis container security context | `{}`
`redis.resources` | The resources of the redis container | `{}`
`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`
`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`
`cluster.master` | Number of master nodes | `3`
`cluster.replicas` | Number of replicas of each master | `1`
`metrics.enabled` | Turn on/off Redis exporter | `true`
`metrics.image` | Docker image of Redis exporter | `oliver006/redis_exporter:v1.55.0`
`metrics.image` | Docker image of Redis exporter | `oliver006/redis_exporter:v1.56.0`
`metrics.securityContext.enabled` | Whether to enable metrics container security context | `false`
`metrics.securityContext` | Metric's container security context | `{}`
`metrics.resources` | Resources of metrics container | `{}`
`metrics.serviceMonitor.enabled` | Create a service monitor if `metrics` is enabled | `true`
`metrics.serviceMonitor.interval` | Metrics scraping interval | `30s`
Expand Down
9 changes: 9 additions & 0 deletions templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
metadata:
labels: {{ include "redis-cluster.labels" . | nindent 8 }}
spec:
{{- if and .Values.securityContext .Values.securityContext.enabled }}
securityContext: {{ omit .Values.securityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
- name: fix-outdated-ips
image: ubuntu:24.04
Expand All @@ -35,6 +38,9 @@ spec:
containers:
- name: redis
image: {{ .Values.redis.image }}
{{- if and .Values.redis.securityContext .Values.redis.securityContext.enabled }}
securityContext: {{ omit .Values.redis.securityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.redis.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end}}
Expand All @@ -57,6 +63,9 @@ spec:
{{- if .enabled }}
- name: metrics
image: {{ .image }}
{{- if and .securityContext .securityContext.enabled }}
securityContext: {{ omit .securityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- with .resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end}}
Expand Down
11 changes: 9 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@ nameOverride: ""
fullnameOverride: ""

redis:
image: redis:7.2.3
image: redis:7.2.4
port: 6379
bus: 16379
minReadySeconds: 0
securityContext:
enabled: false

cluster:
init: true
master: 3
replicas: 1

securityContext:
enabled: false

metrics:
enabled: true
image: oliver006/redis_exporter:v1.55.0
image: oliver006/redis_exporter:v1.56.0
serviceMonitor:
enabled: true
interval: "30s"
securityContext:
enabled: false

service:
enabled: true
Expand Down

0 comments on commit c343792

Please sign in to comment.