diff --git a/helm-charts/vmpooler/Chart.yaml b/helm-charts/vmpooler/Chart.yaml index 6907109..8140f2a 100644 --- a/helm-charts/vmpooler/Chart.yaml +++ b/helm-charts/vmpooler/Chart.yaml @@ -3,7 +3,7 @@ name: vmpooler description: A Helm chart to deploy vmpooler type: application icon: https://github.com/puppetlabs/vmpooler/raw/master/lib/vmpooler/public/img/logo.png -version: 3.10.3 +version: 3.10.4 appVersion: pr177-9010ad15d1b63bae44be352e7288a477bf6f667d dependencies: - name: redis diff --git a/helm-charts/vmpooler/templates/deployment-api.yaml b/helm-charts/vmpooler/templates/deployment-api.yaml index f89bec8..f23926d 100644 --- a/helm-charts/vmpooler/templates/deployment-api.yaml +++ b/helm-charts/vmpooler/templates/deployment-api.yaml @@ -32,6 +32,29 @@ spec: serviceAccountName: {{ include "vmpooler.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.api.waitForRedis }} + initContainers: + - name: wait-for-redis + image: "{{ .Values.redis.image.registry }}/{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}" + imagePullPolicy: {{ .Values.redis.image.pullPolicy }} + command: + - /bin/sh + - -c + - | + until redis-cli -h redis-master -p 6379 -a "$REDIS_PASSWORD" ping | grep -q PONG; do + echo "Waiting for Redis to be ready..." + sleep 2 + done + echo "Redis is ready." + env: + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis + key: redis-password + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} containers: - name: {{ $fullName }}-api securityContext: diff --git a/helm-charts/vmpooler/templates/deployment-manager.yaml b/helm-charts/vmpooler/templates/deployment-manager.yaml index 63bda8f..e02e645 100644 --- a/helm-charts/vmpooler/templates/deployment-manager.yaml +++ b/helm-charts/vmpooler/templates/deployment-manager.yaml @@ -34,6 +34,29 @@ spec: serviceAccountName: {{ include "vmpooler.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.manager.waitForRedis }} + initContainers: + - name: wait-for-redis + image: "{{ .Values.redis.image.registry }}/{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}" + imagePullPolicy: {{ .Values.redis.image.pullPolicy }} + command: + - /bin/sh + - -c + - | + until redis-cli -h redis-master -p 6379 -a "$REDIS_PASSWORD" ping | grep -q PONG; do + echo "Waiting for Redis to be ready..." + sleep 2 + done + echo "Redis is ready." + env: + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis + key: redis-password + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- end }} containers: - name: {{ $fullName }}-manager securityContext: diff --git a/helm-charts/vmpooler/values.yaml b/helm-charts/vmpooler/values.yaml index e251dfa..6b7e31e 100644 --- a/helm-charts/vmpooler/values.yaml +++ b/helm-charts/vmpooler/values.yaml @@ -64,6 +64,10 @@ additionalConfigFiles: '/etc/vmpooler/config/pools.yaml' api: replicaCount: 1 + # Set to true to add an init container that waits for Redis to accept + # connections before the API container starts. Useful in environments + # where Redis starts slowly (low resources). + waitForRedis: false resources: requests: cpu: 1500m @@ -73,6 +77,10 @@ api: memory: 4Gi manager: + # Set to true to add an init container that waits for Redis to accept + # connections before the manager container starts. Useful in environments + # where Redis starts slowly (low resources). + waitForRedis: false resources: requests: cpu: 4000m