diff --git a/templates/cronjob.yaml b/templates/cronjob.yaml index f9497b7933a281ae078675f3bb70f602e29dbd03..8c6a07b82739d26ef58142bbbe947f939bab32e2 100644 --- a/templates/cronjob.yaml +++ b/templates/cronjob.yaml @@ -36,7 +36,7 @@ spec: spec: # Set a custom service account which has access to the WordPress # statefulset's state - serviceAccountName: {{ include "wordpress.fullname" . }}-account + serviceAccountName: {{ include "wordpress.fullname" . }}-cron restartPolicy: Never {{- if (default .Values.image.pullSecrets .Values.wordpress.mu_cron.cronjob.image.pullSecrets) }} imagePullSecrets: @@ -52,8 +52,14 @@ spec: args: - -c - | + set -o errexit # NOTE: we use "{{` ... `}}" to make sure the curly braces are not templated by Helm. Returns <#readyReplicas>,<#replicasWanted> equation=$(kubectl get statefulset {{ include "wordpress.fullname" . }} --template '{{ `{{.status.readyReplicas}},{{.status.replicas}}` }}') + # Make sure kubectl command did not fail + if [ $? -ne 0 ]; then + echo "Kubernetes command failed"; + exit 2; + fi # Check if part before comma and after comma are equal if [[ "${equation%,*}" == "${equation#*,}" ]]; then output=$(curl -s -w '%{http_code}' {{- if .Values.wordpress.mu_cron.cronjob.curlInsecure }} -k {{- end }} -L 'http://{{ include "wordpress.fullname" . }}:{{ .Values.service.port }}{{ .Values.wordpress.mu_cron.cronjob.path }}?doing_wp_cron&{{ .Values.wpSalts.WP_CRON_CONTROL_SECRET }}') diff --git a/templates/rbac.yaml b/templates/rbac.yaml index b69e4eb68d6b41de302404895c985a08ccfe3271..78467f25f3900348ba9dc14b8bc73bdbd5b7c92c 100644 --- a/templates/rbac.yaml +++ b/templates/rbac.yaml @@ -15,7 +15,7 @@ metadata: name: read-{{ include "wordpress.fullname" . }}-statefulset subjects: - kind: ServiceAccount - name: {{ include "wordpress.fullname" . }}-account + name: {{ include "wordpress.fullname" . }}-cron namespace: {{ .Release.Namespace }} roleRef: kind: Role @@ -25,5 +25,5 @@ roleRef: apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "wordpress.fullname" . }}-account + name: {{ include "wordpress.fullname" . }}-cron {{- end }}