diff --git a/charts/redis/Chart.yaml b/charts/redis/Chart.yaml index 4574c215fb815ffafeda8c32aa12d5718cfbbe00..ac73d522d2926cd4f1637822c8a2a225ffb11114 100644 --- a/charts/redis/Chart.yaml +++ b/charts/redis/Chart.yaml @@ -8,7 +8,7 @@ maintainers: - name: groundhog2k # This is the chart version -version: "0.6.11" +version: "0.6.12" # This is the version number of the application being deployed. appVersion: "7.0.11" diff --git a/charts/redis/README.md b/charts/redis/README.md index bd462b973bcee80f66a9f3ca0d0e8987a023a85c..c106544e0eb952b745ba9d9733cb9accafcf2a90 100644 --- a/charts/redis/README.md +++ b/charts/redis/README.md @@ -1,6 +1,6 @@ # Redis -   +   ## Changelog @@ -122,6 +122,42 @@ helm uninstall my-release | podDisruptionBudget.minAvailable | int | `nil` | Minimum number of pods that must be available after eviction | | podDisruptionBudget.maxUnavailable | int | `nil` | Maximum number of pods that can be unavailable after eviction | +## Metrics support parameters + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| metrics.enabled | bool | `false` | Enable metrics support | +| metrics.exporter.image.pullPolicy | string | `"IfNotPresent"` | Image pull policy | +| metrics.exporter.image.registry | string | `"docker.io"` | Image registry | +| metrics.exporter.image.repository | string | `"oliver006/redis_exporter"` | Image name | +| metrics.exporter.image.tag | string | `"v1.50.0"` | Image tag | +| metrics.exporter.resources | object | `{}` | Resource limits and requests | +| metrics.exporter.livenessProbe | object | `see values.yaml` | Liveness probe configuration | +| metrics.exporter.startupProbe | object | `see values.yaml` | Startup probe configuration | +| metrics.exporter.readinessProbe | object | `see values.yaml` | Readiness probe configuration | +| metrics.exporter.customLivenessProbe | object | `{}` | Custom liveness probe (overwrites default liveness probe configuration) | +| metrics.exporter.customStartupProbe | object | `{}` | Custom startup probe (overwrites default startup probe configuration) | +| metrics.exporter.customReadinessProbe | object | `{}` | Custom readiness probe (overwrites default readiness probe configuration) | +| metrics.exporter.env | list | `[]` | Additional container environmment variables (Exporter only) | +| metrics.exporter.args | list | `[]` | Additional container command arguments (Exporter only) | +| metrics.exporter.extraExporterEnvSecrets | list | `[]` | A list of existing secrets that will be mounted into the exporter container as environment variables | +| metrics.exporter.extraExporterSecrets | list | `[]` | A list of additional existing secrets that will be mounted into the exporter container | +| metrics.exporter.extraExporterSecrets[].name | string | `nil` | Name of the existing K8s secret | +| metrics.exporter.extraExporterSecrets[].mountPath | string | `nil` | Mount path where the secret should be mounted into the container (f.e. /mysecretfolder) | +| metrics.service.type | string | `"ClusterIP"` | Service type (not available when haMode is enabled) | +| metrics.service.servicePort | int | `9121` | Redis metrics exporter service port | +| metrics.service.containerPort | int | `9121` | Redis metrics exporter container port | +| metrics.service.nodePort | int | `nil` | The node port (only relevant for type LoadBalancer or NodePort - not available when haMode is enabled) | +| metrics.service.clusterIP | string | `nil` | The cluster ip address (only relevant for type LoadBalancer or NodePort) | +| metrics.service.loadBalancerIP | string | `nil` | The load balancer ip address (only relevant for type LoadBalancer - not available when haMode is enabled) | +| metrics.service.annotations | object | `{}` | Additional service annotations | +| metrics.serviceMonitor.additionalLabels | object | `{}` | Additional labels for the service monitor object | +| metrics.serviceMonitor.annotations | object | `{}` | Annotations for the service monitor object | +| metrics.serviceMonitor.interval | Duration | `nil` | Scrape interval for prometheus | +| metrics.serviceMonitor.scrapeTimeout | Duration | `nil` | Scrape timeout value | +| metrics.serviceMonitor.extraEndpointParameters | object | `nil` | Extra parameters rendered to the [service monitor endpoint](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#endpoint) | +| metrics.serviceMonitor.extraParameters | object | `nil` | Extra parameters rendered to the [service monitor object](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitorspec) | + ## Service parameters | Key | Type | Default | Description | diff --git a/charts/redis/RELEASENOTES.md b/charts/redis/RELEASENOTES.md index e026cadf5d7d7b05f0313fe53f2c18d442314052..672c7c9302f1f00a8129cba343e0207e8576af73 100644 --- a/charts/redis/RELEASENOTES.md +++ b/charts/redis/RELEASENOTES.md @@ -32,4 +32,5 @@ | 0.6.9 | 7.0.10 | Updated default security context | | 0.6.10 | 7.0.11 | Upgraded to Redis 7.0.11 | | 0.6.11 | 7.0.11 | Fixed split brain bug - thx @tim-hanssen @tomswinkels | +| 0.6.12 | 7.0.11 | Added metrics and service monitor support | | | | | diff --git a/charts/redis/templates/service.yaml b/charts/redis/templates/service.yaml deleted file mode 100644 index ba83bc3c24dd71d0533f9862731a6d73a2ddc845..0000000000000000000000000000000000000000 --- a/charts/redis/templates/service.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "redis.fullname" . }} - labels: - {{- include "redis.labels" . | nindent 4 }} - {{- with .Values.service.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - ports: -{{- if .Values.haMode.enabled }} - - port: {{ .Values.service.sentinelPort }} - targetPort: sentinel - protocol: TCP - name: sentinel - type: ClusterIP -{{- else }} - - port: {{ .Values.service.serverPort }} - targetPort: redis - protocol: TCP - name: redis - {{- if and ( or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") ) (.Values.service.nodePort) }} - nodePort: {{ .Values.service.nodePort }} - {{- end }} - {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.loadBalancerIP) }} - loadBalancerIP: {{ .Values.service.loadBalancerIP }} - {{- end }} - type: {{ .Values.service.type }} -{{- end }} - {{- if .Values.service.clusterIP }} - clusterIP: {{ .Values.service.clusterIP }} - {{- end }} - selector: - {{- include "redis.selectorLabels" . | nindent 4 }} diff --git a/charts/redis/templates/servicemonitor.yaml b/charts/redis/templates/servicemonitor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..48fa0b4f4e9a2d18535ddd492ad809737fdb5a88 --- /dev/null +++ b/charts/redis/templates/servicemonitor.yaml @@ -0,0 +1,36 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "redis.fullname" . }} + labels: + {{- include "redis.labels" . | nindent 4 }} + {{- with .Values.metrics.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: "exporter" + path: {{ .Values.metrics.serviceMonitor.path }} + scheme: {{ .Values.metrics.serviceMonitor.scheme }} + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.extraEndpointParameters }} + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.extraParameters }} + {{- toYaml . | nindent 2 }} + {{- end }} + selector: + matchLabels: + {{- include "redis.selectorLabels" . | nindent 6 }} + redis/metrics-service: {{ include "redis.fullname" . }}-metrics +{{- end }} \ No newline at end of file diff --git a/charts/redis/templates/services.yaml b/charts/redis/templates/services.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5b51dcde777d0a9f8ed43bf73a1bf68b2bbd54e6 --- /dev/null +++ b/charts/redis/templates/services.yaml @@ -0,0 +1,68 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "redis.fullname" . }} + labels: + {{- include "redis.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ports: +{{- if .Values.haMode.enabled }} + - port: {{ .Values.service.sentinelPort }} + targetPort: sentinel + protocol: TCP + name: sentinel + type: ClusterIP +{{- else }} + - port: {{ .Values.service.serverPort }} + targetPort: redis + protocol: TCP + name: redis + {{- if and ( or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") ) (.Values.service.nodePort) }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.loadBalancerIP) }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} + {{- end }} + type: {{ .Values.service.type }} +{{- end }} + {{- if .Values.service.clusterIP }} + clusterIP: {{ .Values.service.clusterIP }} + {{- end }} + selector: + {{- include "redis.selectorLabels" . | nindent 4 }} +{{- if and .Values.metrics.enabled .Values.metrics.service.enabled }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "redis.fullname" . }}-metrics + labels: + {{- include "redis.labels" . | nindent 4 }} + redis/metrics-service: {{ include "redis.fullname" . }}-metrics + {{- with .Values.metrics.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ports: + - port: {{ .Values.metrics.service.servicePort }} + targetPort: exporter + protocol: TCP + name: exporter + {{- if and ( or (eq .Values.metrics.service.type "LoadBalancer") (eq .Values.metrics.service.type "NodePort") ) (.Values.metrics.service.nodePort) }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + type: {{ .Values.metrics.service.type }} + {{- if and (eq .Values.metrics.service.type "LoadBalancer") (.Values.metrics.service.loadBalancerIP) }} + loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }} + {{- end }} + {{- if .Values.metrics.service.clusterIP }} + clusterIP: {{ .Values.metrics.service.clusterIP }} + {{- end }} + selector: + {{- include "redis.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/charts/redis/templates/statefulset.yaml b/charts/redis/templates/statefulset.yaml index f089aaf247562e4b9db56c8d336715063cc72b5c..2130408b05a064c6f280c9e9f77f9b5e14612a78 100644 --- a/charts/redis/templates/statefulset.yaml +++ b/charts/redis/templates/statefulset.yaml @@ -187,7 +187,7 @@ spec: - name: {{ .Values.storage.volumeName }} mountPath: /data {{- range $secret := .Values.extraRedisSecrets }} - - name: {{ $secret.name }} + - name: {{ $secret.name }}-redis mountPath: {{ $secret.mountPath }} {{- end }} {{- if .Values.haMode.enabled }} @@ -266,10 +266,104 @@ spec: - name: {{ .Values.storage.volumeName }} mountPath: /data {{- range $secret := .Values.extraSentinelSecrets }} - - name: {{ $secret.name }} + - name: {{ $secret.name }}-sentinel mountPath: {{ $secret.mountPath }} {{- end }} {{- end }} + + {{- if .Values.metrics.enabled }} + {{- with .Values.metrics }} + - name: {{ $.Chart.Name }}-exporter + {{- with .exporter.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .exporter.image.registry }}/{{ .exporter.image.repository }}:{{ .exporter.image.tag }}" + imagePullPolicy: {{ .exporter.image.pullPolicy }} + ports: + - name: exporter + containerPort: {{ .service.containerPort }} + protocol: TCP + {{- with .exporter.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .exporter.args }} + args: + {{- range . }} + - {{ . }} + {{- end }} + {{- end }} + {{- with .exporter.env }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} + envFrom: + {{- range .exporter.extraExporterEnvSecrets }} + - secretRef: + name: {{ . }} + {{- end }} + {{- if .exporter.customStartupProbe }} + startupProbe: + {{- toYaml .exporter.customStartupProbe | nindent 12 }} + {{- else }} + {{- if .exporter.startupProbe.enabled }} + startupProbe: + httpGet: + path: / + port: exporter + {{- with .exporter.startupProbe }} + initialDelaySeconds: {{ .initialDelaySeconds }} + timeoutSeconds: {{ .timeoutSeconds }} + failureThreshold: {{ .failureThreshold }} + successThreshold: {{ .successThreshold }} + periodSeconds: {{ .periodSeconds }} + {{- end }} + {{- end }} + {{- end }} + {{- if .exporter.customLivenessProbe }} + livenessProbe: + {{- toYaml .exporter.customLivenessProbe | nindent 12 }} + {{- else }} + {{- if .exporter.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: / + port: exporter + {{- with .exporter.livenessProbe }} + initialDelaySeconds: {{ .initialDelaySeconds }} + timeoutSeconds: {{ .timeoutSeconds }} + failureThreshold: {{ .failureThreshold }} + successThreshold: {{ .successThreshold }} + periodSeconds: {{ .periodSeconds }} + {{- end }} + {{- end }} + {{- end }} + {{- if .exporter.customReadinessProbe }} + readinessProbe: + {{- toYaml .exporter.customReadinessProbe | nindent 12 }} + {{- else }} + {{- if .exporter.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: / + port: exporter + {{- with .exporter.readinessProbe }} + initialDelaySeconds: {{ .initialDelaySeconds }} + timeoutSeconds: {{ .timeoutSeconds }} + failureThreshold: {{ .failureThreshold }} + successThreshold: {{ .successThreshold }} + periodSeconds: {{ .periodSeconds }} + {{- end }} + {{- end }} + {{- end }} + volumeMounts: + {{- range $secret := .exporter.extraExporterSecrets }} + - name: {{ $secret.name }}-exporter + mountPath: {{ $secret.mountPath }} + {{- end }} + {{- end }} + {{- end }} {{- with .Values.extraContainers }} {{- toYaml . | nindent 8 }} {{- end }} @@ -296,17 +390,25 @@ spec: name: {{ $fullname }} {{- end }} {{- range $secret := .Values.extraRedisSecrets }} - - name: {{ $secret.name }} + - name: {{ $secret.name }}-redis secret: secretName: {{ $secret.name }} defaultMode: 0440 {{- end }} {{- range $secret := .Values.extraSentinelSecrets }} - - name: {{ $secret.name }} + - name: {{ $secret.name }}-sentinel secret: secretName: {{ $secret.name }} defaultMode: 0440 {{- end }} + {{- if .Values.metrics.enabled }} + {{- range $secret := .Values.metrics.exporter.extraExporterSecrets }} + - name: {{ $secret.name }}-exporter + secret: + secretName: {{ $secret.name }} + defaultMode: 0440 + {{- end }} + {{- end }} {{- if .Values.extraSecretRedisConfigs }} - name: extraredisconfigs-volume secret: diff --git a/charts/redis/values.yaml b/charts/redis/values.yaml index 44158f4424bdfb3faca1bcb243a93403a63f8cbc..054a80ae6867fd0c9a6985010605aa22aef3f318 100644 --- a/charts/redis/values.yaml +++ b/charts/redis/values.yaml @@ -53,6 +53,126 @@ securityContext: drop: - ALL +## Prometheus metrics and service monitor configuration +metrics: + ## Enable metrics export + enabled: false + ## Metrics exporter configuration + exporter: + ## Redis exporter image + image: + registry: "docker.io" + repository: "oliver006/redis_exporter" + pullPolicy: IfNotPresent + tag: "v1.50.0" + ## Default security options to run Exporter as non-root, read only container without privilege escalation + securityContext: + allowPrivilegeEscalation: false + privileged: false + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 999 + runAsGroup: 999 + capabilities: + drop: + - ALL + ## Resource limits and requests + resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + ## Custom startup probe (overwrites default startup probe) + customStartupProbe: {} + + ## Default startup probe + startupProbe: + enabled: true + initialDelaySeconds: 10 + timeoutSeconds: 5 + failureThreshold: 5 + successThreshold: 1 + periodSeconds: 10 + + ## Custom liveness probe (overwrites default liveness probe) + customLivenessProbe: {} + + ## Default liveness probe + livenessProbe: + enabled: true + initialDelaySeconds: 15 + timeoutSeconds: 5 + failureThreshold: 3 + successThreshold: 1 + periodSeconds: 10 + + ## Custom readiness probe (overwrites default readiness probe) + customReadinessProbe: {} + + ## Default readiness probe + readinessProbe: + enabled: true + initialDelaySeconds: 15 + timeoutSeconds: 5 + failureThreshold: 3 + successThreshold: 1 + periodSeconds: 10 + + ## Arguments for the container entrypoint process (exporter only) + args: [] + ## Additional environment variables (exporter only) + env: [] + ## A list of existing secrets that will be mounted into the exporter container as environment variables (see: https://github.com/oliver006/redis_exporter#command-line-flags) + extraExporterEnvSecrets: [] + ## A list of additional existing secrets that will be mounted into the exporter container + ## The mounted files of the secrets can be used for custom configuration options (see: https://github.com/oliver006/redis_exporter#command-line-flags) + extraExporterSecrets: [] + ## Name of the existing K8s secret + # - name: + ## Mount path where the secret should be mounted into the container (f.e. /mysecretfolder) + # mountPath: + ## Exporter service configuration + service: + ## Enable metrics service + enabled: true + ## Type of service (not available when haMode is enabled) + type: ClusterIP + ## Redis exporter service port + servicePort: 9121 + ## Redis exporter container port + containerPort: 9121 + ## The node port (only relevant for type LoadBalancer or NodePort - not available when haMode is enabled) + nodePort: + ## The cluster ip address (only relevant for type LoadBalancer or NodePort) + clusterIP: + ## The loadbalancer ip address (only relevant for type LoadBalancer - not available when haMode is enabled) + loadBalancerIP: + # Annotations to add to the service + annotations: {} + ## Prometheus service monitor configuration + serviceMonitor: + ## Enable service monitor + enabled: true + ## Additional labels for the service monitor object + additionalLabels: {} + ## Annotations for the service monitor object + annotations: {} + ## The scrape interval for prometheus + # interval: + ## The scrape timeout value + # scrapeTimeout: + ## Extra parameters rendered to the service monitor endpoint + extraEndpointParameters: {} + ## Extra parameters rendered to the service monitor + extraParameters: {} + ## Path to metrics + path: "/metrics" + ## Scheme to use for metrics endpoint + scheme: http + ## Default redis service port (default Redis server port 6379, defaul Redis sentinel port 26379) service: ## Type of service (not available when haMode is enabled)