Add support for external Redis configuration in helm chart

This commit adds "external" part in redis configuration in helm chart, by this way users can use the existing external Redis rather than using the internal one
This commit is contained in:
Wenkai Yin 2018-07-23 17:42:23 +08:00
parent bb380e6dbc
commit f22121dd03
3 changed files with 64 additions and 5 deletions

View File

@ -141,3 +141,54 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
{{- define "harbor.database.notarySigner" -}}
postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.database.rawPassword" . }}@{{ template "harbor.database.host" . }}:{{ template "harbor.database.port" . }}/{{ template "harbor.database.notarySignerDatabase" . }}?sslmode=disable
{{- end -}}
{{- define "harbor.redis.host" -}}
{{- if .Values.redis.external.enabled -}}
{{- .Values.redis.external.host -}}
{{- else -}}
{{- .Release.Name }}-redis-master
{{- end -}}
{{- end -}}
{{- define "harbor.redis.port" -}}
{{- if .Values.redis.external.enabled -}}
{{- .Values.redis.external.port -}}
{{- else -}}
{{- .Values.redis.master.port }}
{{- end -}}
{{- end -}}
{{- define "harbor.redis.databaseIndex" -}}
{{- if .Values.redis.external.enabled -}}
{{- .Values.redis.external.databaseIndex -}}
{{- else -}}
{{- printf "%s" "0" }}
{{- end -}}
{{- end -}}
{{- define "harbor.redis.password" -}}
{{- if and .Values.redis.external.enabled .Values.redis.external.usePassword -}}
{{- .Values.redis.external.password -}}
{{- else if and (not .Values.redis.external.enabled) .Values.redis.usePassword -}}
{{- .Values.redis.password -}}
{{- end -}}
{{- end -}}
{{/*the username redis is used for a placeholder as no username needed in redis*/}}
{{- define "harbor.redisForJobservice" -}}
{{- if and .Values.redis.external.enabled .Values.redis.external.usePassword -}}
redis:{{ template "harbor.redis.password" . }}@{{ template "harbor.redis.host" . }}:{{ template "harbor.redis.port" . }}/{{ template "harbor.redis.databaseIndex" }}
{{- else if and (not .Values.redis.external.enabled) .Values.redis.usePassword -}}
redis:{{ template "harbor.redis.password" . }}@{{ template "harbor.redis.host" . }}:{{ template "harbor.redis.port" . }}/{{ template "harbor.redis.databaseIndex" }}
{{- else }}
{{- template "harbor.redis.host" . }}:{{ template "harbor.redis.port" . }}/{{ template "harbor.redis.databaseIndex" }}
{{- end -}}
{{- end -}}
{{/*
host:port,pool_size,password
100 is the default value of pool size
*/}}
{{- define "harbor.redisForUI" -}}
{{- template "harbor.redis.host" . }}:{{ template "harbor.redis.port" . }},100,{{ template "harbor.redis.password" . }}
{{- end -}}

View File

@ -12,7 +12,7 @@ data:
workers: {{ .Values.jobservice.maxWorkers }}
backend: "redis"
redis_pool:
redis_url: "{{ .Release.Name }}-redis-master:{{ .Values.redis.master.port }}"
redis_url: "{{ template "harbor.redisForJobservice" . }}"
namespace: "harbor_job_service_namespace"
logger:
path: "/var/log/jobs"

View File

@ -149,6 +149,7 @@ ui:
tolerations: []
affinity: {}
# TODO: change the style to be same with redis
database:
# if external database is used, set "type" to "external"
# and fill the connection informations in "external" section
@ -271,12 +272,12 @@ clair:
tolerations: []
affinity: {}
## Settings for redis dependency.
## see https://github.com/kubernetes/charts/tree/master/stable/redis
## for further configurables.
redis:
# Update needed in the cm that defines redis_url if usePassword is set to true.
# if external Redis is used, set "external.enabled" to "true"
# and fill the connection informations in "external" section.
# or the internal Redis will be used
usePassword: false
password: "changeit"
cluster:
enabled: false
master:
@ -284,6 +285,13 @@ redis:
# TODO: There is a perm issue: Can't open the append-only file: Permission denied
# TODO: Setting it to false is a temp workaround. Will re-visit this problem.
enabled: false
external:
enabled: false
host: "192.168.0.2"
port: "6379"
databaseIndex: "0"
usePassword: false
password: "changeit"
notary:
enabled: true