|
| 1 | +{{- if .Values.cluster.console.enabled }} |
| 2 | +apiVersion: apps/v1 |
| 3 | +kind: StatefulSet |
| 4 | +metadata: |
| 5 | + name: {{ include "cluster.fullname" $ }}-console |
| 6 | + namespace: {{ include "cluster.namespace" $ }} |
| 7 | + {{- with .Values.cluster.annotations }} |
| 8 | + annotations: |
| 9 | + {{- toYaml . | nindent 8 }} |
| 10 | + {{- end }} |
| 11 | + labels: |
| 12 | + {{- include "cluster.labels" . | nindent 4 }} |
| 13 | + {{- with .Values.cluster.additionalLabels }} |
| 14 | + {{- toYaml . | nindent 4 }} |
| 15 | + {{- end }} |
| 16 | + app.kubernetes.io/component: console |
| 17 | +spec: |
| 18 | + replicas: 1 |
| 19 | + selector: |
| 20 | + matchLabels: |
| 21 | + {{- include "cluster.selectorLabels" . | nindent 6 }} |
| 22 | + app.kubernetes.io/component: console |
| 23 | + serviceName: console |
| 24 | + volumeClaimTemplates: |
| 25 | + - metadata: |
| 26 | + name: console-home |
| 27 | + spec: |
| 28 | + accessModes: [ "ReadWriteOnce" ] |
| 29 | + resources: |
| 30 | + requests: |
| 31 | + storage: 1Gi |
| 32 | + template: |
| 33 | + metadata: |
| 34 | + {{- with .Values.cluster.annotations }} |
| 35 | + annotations: |
| 36 | + {{- toYaml . | nindent 8 }} |
| 37 | + {{- end }} |
| 38 | + labels: |
| 39 | + {{- include "cluster.labels" . | nindent 8 }} |
| 40 | + {{- with .Values.cluster.additionalLabels }} |
| 41 | + {{- toYaml . | nindent 8 }} |
| 42 | + {{- end }} |
| 43 | + app.kubernetes.io/component: console |
| 44 | + spec: |
| 45 | + terminationGracePeriodSeconds: 2 |
| 46 | + containers: |
| 47 | + - name: console |
| 48 | + image: ubuntu:latest |
| 49 | + command: [ "sh" ] |
| 50 | + args: |
| 51 | + - "-c" |
| 52 | + - | |
| 53 | + apt update |
| 54 | + apt install -y postgresql-client |
| 55 | + apt install -y screen curl wget jq unzip gzip nano vim util-linux less htop |
| 56 | + cat <<EOF > /root/.bashrc |
| 57 | + echo -e "\nHere are some examples for connecting and running queries on the cluster:" |
| 58 | + echo ' nohup psql \$DB_SUPERUSER_URI"/DB_NAME" -c "SELECT 1;" 2>&1 > command.log &' |
| 59 | + echo -e "\nTo check up on the command, use:" |
| 60 | + echo " tail -f command.log" |
| 61 | + echo -e "\nYou can also use 'screen' for an interactive session. See https://github.com/paradedb/charts/blob/dev/charts/paradedb/docs/long-running-tasks.md for examples." |
| 62 | + echo -e "\n" |
| 63 | + EOF |
| 64 | + sleep infinity |
| 65 | + env: |
| 66 | + - name: DB_APP_URI |
| 67 | + valueFrom: |
| 68 | + secretKeyRef: |
| 69 | + name: {{ include "cluster.fullname" $ }}-app |
| 70 | + key: uri |
| 71 | + - name: DB_SUPERUSER_HOST |
| 72 | + valueFrom: |
| 73 | + secretKeyRef: |
| 74 | + name: {{ include "cluster.fullname" $ }}-superuser |
| 75 | + key: host |
| 76 | + - name: DB_SUPERUSER_PORT |
| 77 | + valueFrom: |
| 78 | + secretKeyRef: |
| 79 | + name: {{ include "cluster.fullname" $ }}-superuser |
| 80 | + key: port |
| 81 | + - name: DB_SUPERUSER_USER |
| 82 | + valueFrom: |
| 83 | + secretKeyRef: |
| 84 | + name: {{ include "cluster.fullname" $ }}-superuser |
| 85 | + key: user |
| 86 | + - name: DB_SUPERUSER_PASSWORD |
| 87 | + valueFrom: |
| 88 | + secretKeyRef: |
| 89 | + name: {{ include "cluster.fullname" $ }}-superuser |
| 90 | + key: password |
| 91 | + - name: DB_SUPERUSER_URI |
| 92 | + value: "postgresql://$(DB_SUPERUSER_USER):$(DB_SUPERUSER_PASSWORD)@$(DB_SUPERUSER_HOST):$(DB_SUPERUSER_PORT)" |
| 93 | + volumeMounts: |
| 94 | + - name: console-home |
| 95 | + mountPath: /root |
| 96 | +{{- end }} |
0 commit comments