|
1 | 1 |
|
| 2 | +--- |
| 3 | +apiVersion: v1 |
| 4 | +kind: ConfigMap |
| 5 | +metadata: |
| 6 | + name: {{ include "nts-pool.fullname" . }}-config-updater |
| 7 | + namespace: {{ default .Release.Namespace .Values.namespaceOverride }} |
| 8 | + labels: |
| 9 | + {{- include "nts-pool.labels" . | nindent 4 }} |
| 10 | +data: |
| 11 | + config-updater.sh: | |
| 12 | + #!/bin/sh |
| 13 | + curl --fail -H "Authentication: Bearer ${AUTHTOKEN}" "${CONFIGURL}" | |
| 14 | + jq '{"op": "replace", "path": "/data/servers.json", "value": "\(.)"}' | |
| 15 | + curl --fail --cacert "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" \ |
| 16 | + --binary-data @- -X PATCH -H "Content-Type: application/json-patch+json" \ |
| 17 | + -H "Authentication: Bearer $(cat /var/run/secrets/kubernets.io/serviceaccount/token)" \ |
| 18 | + "https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT_HTTPS}/api/v1/namespaces/${NAMESPACE}/configmaps/${CONFIGMAP}" |
2 | 19 | --- |
3 | 20 | apiVersion: batch/v1 |
4 | 21 | kind: CronJob |
5 | 22 | metadata: |
6 | | - name: {{ include "nts-pool.fullname" . }}-ke-config-updater |
| 23 | + name: {{ include "nts-pool.fullname" . }}-ke-server-list-updater |
7 | 24 | namespace: {{ default .Release.Namespace .Values.namespaceOverride }} |
8 | 25 | labels: |
9 | 26 | {{- include "nts-pool.labels" . | nindent 4 }} |
|
15 | 32 | spec: |
16 | 33 | serviceAccountName: {{ include "nts-pool.fullname" . }}-ke-config-updater |
17 | 34 | restartPolicy: Never |
| 35 | + volumes: |
| 36 | + - name: config-updater-script |
| 37 | + configMap: |
| 38 | + name: {{ include "nts-pool.fullname" . }}-config-updater |
| 39 | + items: |
| 40 | + - key: "config-updater.sh" |
| 41 | + path: "config-updater.sh" |
| 42 | + mode: 0755 |
18 | 43 | containers: |
19 | 44 | - name: ke-config-updater |
20 | 45 | imagePullPolicy: "{{ default .Values.image.pullPolicy .Values.ke.image.pullPolicy }}" |
|
23 | 48 | {{- toYaml . | nindent 16 }} |
24 | 49 | {{- end }} |
25 | 50 | image: "{{ default .Values.image.repository .Values.ke.image.repository }}:{{ default .Values.image.tag .Values.ke.image.tag }}" |
| 51 | + volumeMounts: |
| 52 | + - name: config-updater-script |
| 53 | + mountPath: "/opt/scripts/" |
| 54 | + readonly: true |
26 | 55 | command: |
27 | | - - /bin/sh |
28 | | - - -c |
29 | | - - echo 'Hello from Kubernetes CronJob!' |
| 56 | + - /opt/scripts/config-updater.sh |
| 57 | + env: |
| 58 | + - name: AUTHTOKEN |
| 59 | + valueFrom: |
| 60 | + secretKeyRef: |
| 61 | + {{- toYaml .Values.management.configUpdaterSecretRef | nindent 22 }} |
| 62 | + - name: CONFIGURL |
| 63 | + value: "http://{{ include "nts-pool.fullname" . }}-management.{{ default .Release.Namespace .Values.namespaceOverride }}.svc.{{ .Values.clusterDomain }}:3000/poolke_servers" |
| 64 | + - name: NAMESPACE |
| 65 | + value: "{{ default .Release.Namespace .Values.namespaceOverride }}" |
| 66 | + - name: CONFIGMAP |
| 67 | + value: "{{ include "nts-pool.fullname" . }}-servers-config" |
0 commit comments