Skip to content

Commit

Permalink
Use a sysadmin API token to trigger sending of email notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mbocevski committed Dec 22, 2020
1 parent b5c1275 commit a48a5a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 5000:5000
echo "Visit http://127.0.0.1:5000 to use CKAN"
{{- end }}
2. Generate an API Token for the sysadmin user using the CKAN UI, replace it in your values file and replace the secret with the new value at runtime
kubectl -n {namespace} create secret generic ckansysadminapitoken --from-literal=sysadminApiToken={insert_generated_api_token_here} --dry-run -o yaml | kubectl apply -f -
7 changes: 7 additions & 0 deletions templates/ckansysadminapitoken.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: ckansysadminapitoken
type: Opaque
stringData:
sysadminApiToken: {{ .Values.ckan.sysadminApiToken }}
17 changes: 12 additions & 5 deletions templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ spec:
{{- toYaml .Values.securityContext | nindent 14 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["ckan"]
command: ["curl"]
args:
- -c
- /srv/app/production.ini
- post
- /api/action/send_email_notifications
- -s
- -H
- "Authorization: $(CKAN_SYSADMIN_API_TOKEN)"
- -d
- "{}"
- "http://ckan/api/action/send_email_notifications"
env:
{{- if .Values.ckan.extraEnv }}
{{ toYaml .Values.ckan.extraEnv | indent 12 }}
Expand All @@ -36,6 +38,11 @@ spec:
value: {{ .Values.ckan.ckanPlugins }}
- name: CKAN__STORAGE_PATH
value: {{ .Values.ckan.storagePath }}
- name: CKAN_SYSADMIN_API_TOKEN
valueFrom:
secretKeyRef:
name: ckansysadminapitoken
key: sysadminApiToken
- name: CKAN_SQLALCHEMY_URL
valueFrom:
secretKeyRef:
Expand Down
3 changes: 3 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ ckan:
sysadminName: "ckan_admin"
# ckan.sysadminPassword -- CKAN system admin password
sysadminPassword: "PasswordHere"
# ckan.sysadminApiToken -- CKAN system admin API token
# Needs to be generated via the CKAN UI and replaced after initial deployment
sysadminApiToken: "replace_this_with_generated_api_token_for_sysadmin"
# ckan.sysadminEmail -- CKAN system admin email
sysadminEmail: "[email protected]"
# ckan.siteTitle -- Site title for the instance
Expand Down

0 comments on commit a48a5a2

Please sign in to comment.