Skip to content

Commit

Permalink
Support redis as sidecar of Symphony API pod (#269)
Browse files Browse the repository at this point in the history
* Support redis as sidecar

* use string type for redis port

* Enable redis to change port

* fix type issue
  • Loading branch information
RemindD authored May 23, 2024
1 parent 034b25f commit 4cf2e69
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/helm/symphony/files/symphony-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"type": "providers.pubsub.redis",
"config": {
"name": "redis",
"host": "symphony-redis:6379",
"host": "{{ include "symphony.redisHost" . }}",
"requireTLS": false,
"password": "",
"numberOfWorkers": 1
Expand Down
9 changes: 9 additions & 0 deletions packages/helm/symphony/templates/redis-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config-map
data:
redis.conf: |
protected-mode {{ include "symphony.protectedMode" . }}
port {{ .Values.redis.port }}
21 changes: 16 additions & 5 deletions packages/helm/symphony/templates/redis.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.redis.enabled }}
{{- if and .Values.redis.enabled (not .Values.redis.asSidecar)}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -16,10 +16,21 @@ spec:
app: {{ include "symphony.name" . }}-redis
spec:
containers:
- name: redis
image: {{ .Values.redis.image }}
ports:
- containerPort: {{ .Values.redis.port }}
- name: redis
image: {{ .Values.redis.image }}
ports:
- containerPort: {{ .Values.redis.port }}
command: ["redis-server", "/usr/var/redis/redis.conf"]
volumeMounts:
- name: redis-config
mountPath: /usr/var/redis
volumes:
- name: redis-config
configMap:
name: redis-config-map
items:
- key: redis.conf
path: redis.conf
---
apiVersion: v1
kind: Service
Expand Down
18 changes: 18 additions & 0 deletions packages/helm/symphony/templates/symphony-core/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,22 @@ Symphony full url Endpoint
{{/* Symphony Env Config Name */}}
{{- define "symphony.envConfigName" -}}
{{- printf "%s-env-config" (include "symphony.fullname" .) }}
{{- end }}

{{/* Symphony Redis host*/}}
{{- define "symphony.redisHost" -}}
{{- if .Values.redis.asSidecar }}
{{- printf "localhost:%d" (.Values.redis.port | int) }}
{{- else }}
{{- printf "%s-redis:%d" (include "symphony.name" .) (.Values.redis.port | int)}}
{{- end }}
{{- end }}

{{/* Symphony Redis protected-mode*/}}
{{- define "symphony.protectedMode" -}}
{{- if .Values.redis.asSidecar}}
{{- printf "yes" }}
{{- else }}
{{- printf "no" }}
{{- end }}
{{- end }}
19 changes: 18 additions & 1 deletion packages/helm/symphony/templates/symphony-core/symphony-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ spec:
subPath: proxy-cert.crt
name: proxy-certstore
{{- end }}

{{- if and .Values.redis.enabled .Values.redis.asSidecar }}
- name: redis
image: {{ .Values.redis.image }}
command: ["redis-server", "/usr/var/redis/redis.conf"]
ports:
- containerPort: {{ .Values.redis.port }}
volumeMounts:
- name: redis-config
mountPath: /usr/var/redis
{{- end}}
{{- if .Values.global.azure.identity.mSIAdapterYaml }}
- name: msi-adapter
env:
Expand Down Expand Up @@ -108,3 +117,11 @@ spec:
- name: ssl-certs
emptyDir: {}
{{ end }}
{{- if and .Values.redis.enabled .Values.redis.asSidecar }}
- name: redis-config
configMap:
name: redis-config-map
items:
- key: redis.conf
path: redis.conf
{{- end }}
1 change: 1 addition & 0 deletions packages/helm/symphony/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cert-manager:
flavor: oss
redis:
enabled: true
asSidecar: false
image: redis/redis-stack-server:latest
port: 6379
parent:
Expand Down

0 comments on commit 4cf2e69

Please sign in to comment.