From 74c39ada869be466fb4a7192c958913e0429038b Mon Sep 17 00:00:00 2001 From: soru23 Date: Mon, 17 Jul 2023 00:18:58 +0200 Subject: [PATCH 1/2] added deployment template --- helm/prenet-values.yaml | 51 +++++++++++++++ helm/templates/deployments.yaml | 108 ++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 helm/templates/deployments.yaml diff --git a/helm/prenet-values.yaml b/helm/prenet-values.yaml index 541a92e5..37f6b5c7 100644 --- a/helm/prenet-values.yaml +++ b/helm/prenet-values.yaml @@ -46,3 +46,54 @@ extraEnvVars: value: "/dns/polybase-rust-0.polybase-rust-headless.polybase.svc.cluster.local/tcp/5001,/dns/polybase-rust-1.polybase-rust-headless.polybase.svc.cluster.local/tcp/5001,/dns/polybase-rust-2.polybase-rust-headless.polybase.svc.cluster.local/tcp/5001" - name: MIGRATION_BATCH_SIZE value: "2000" + +deployments: +- name: gateway + labels: + app: polybase + replicaCount: 4 + command: run + imagePullPolicy: Always + podSecurityContext: false + livenessProbe: + enabled: false + readinessProbe: + enabled: false + startupProbe: + enabled: false + containerPorts: + public_api: 80 + p2p: 8080 +- name: indexer + labels: + app: polybase + replicaCount: 16 + command: run + imagePullPolicy: Always + podSecurityContext: false + livenessProbe: + enabled: false + readinessProbe: + enabled: false + startupProbe: + enabled: false + containerPorts: + public_api: 80 + p2p: 8080 +- name: prover + labels: + app: polybase + replicaCount: 5 + command: run + imagePullPolicy: Always + podSecurityContext: false + livenessProbe: + enabled: false + readinessProbe: + enabled: false + startupProbe: + enabled: false + containerPorts: + public_api: 80 + p2p: 8080 + diff --git a/helm/templates/deployments.yaml b/helm/templates/deployments.yaml new file mode 100644 index 00000000..4ce00dde --- /dev/null +++ b/helm/templates/deployments.yaml @@ -0,0 +1,108 @@ +{{- range .Values.deployments }} + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .name }} + namespace: {{ $.Release.Namespace | quote }} + labels: + {{- if .labels }} + {{- toYaml .labels | nindent 4}} + {{- end }} + {{- if .commonAnnotations }} + annotations: {{- include "polybase.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + app: polybase + replicas: {{ .replicaCount }} + template: + metadata: + labels: + app: polybase + {{- if .podLabels }} + {{- toYaml .podLabels | nindent 8 }} + {{- end }} + {{- if or .podAnnotations }} + annotations: + {{- if .podAnnotations }} + {{- toYaml .podAnnotations | nindent 8 }} + {{- end }} + {{- end }} + spec: + {{- if .nodeSelector }} + nodeSelector: {{- include "polybase.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }} + {{- end }} + {{- if .tolerations }} + tolerations: {{- include "polybase.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }} + {{- end }} + containers: + - name: {{ .name }} + command: {{ .command }} + {{- if .args }} + args: {{ .args }} + {{- end }} + image: {{ include "polybase.main_image" $ }} + imagePullPolicy: {{ .imagePullPolicy | quote }} + env: + FOO: BAR + {{- if .extraEnvVars }} + {{- include "polybase.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 10 }} + {{- end }} + {{- if .customLivenessProbe }} + livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} + {{- else if .livenessProbe.enabled }} + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: {{ .livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .livenessProbe.periodSeconds }} + timeoutSeconds: {{ .livenessProbe.timeoutSeconds }} + successThreshold: {{ .livenessProbe.successThreshold }} + failureThreshold: {{ .livenessProbe.failureThreshold }} + {{- end }} + {{- if .customReadinessProbe }} + readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} + {{- else if .readinessProbe.enabled }} + readinessProbe: + httpGet: + path: /v0/health + port: 8080 + initialDelaySeconds: {{ .readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .readinessProbe.periodSeconds }} + timeoutSeconds: {{ .readinessProbe.timeoutSeconds }} + successThreshold: {{ .readinessProbe.successThreshold }} + failureThreshold: {{ .readinessProbe.failureThreshold }} + {{- end }} + {{- if .customStartupProbe }} + startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} + {{- else if .startupProbe.enabled }} + startupProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: {{ .startupProbe.initialDelaySeconds }} + periodSeconds: {{ .startupProbe.periodSeconds }} + timeoutSeconds: {{ .startupProbe.timeoutSeconds }} + successThreshold: {{ .startupProbe.successThreshold }} + failureThreshold: {{ .startupProbe.failureThreshold }} + {{- end }} + ports: + - name: public-api + containerPort: {{ .containerPorts.public_api | default "8080" }} + {{- if .hostNetwork }} + hostPort: {{ .containerPorts.public_api }} + {{- end }} + - name: p2p + containerPort: {{ .containerPorts.p2p | default "5001" }} + {{- if .hostNetwork }} + hostPort: {{ .containerPorts.p2p }} + {{- end }} + {{- if .resources }} + resources: {{ toYaml .resources | nindent 12 }} + {{- end }} +{{- end }} From c66f9df93a31023213bb994d056e107db6c22fde Mon Sep 17 00:00:00 2001 From: soru23 Date: Sun, 30 Jul 2023 23:25:35 +0200 Subject: [PATCH 2/2] added support for sql proxy for deployments --- helm/prenet-values.yaml | 7 ++ helm/templates/deployments.yaml | 149 ++++++++++++++++++-------------- 2 files changed, 91 insertions(+), 65 deletions(-) diff --git a/helm/prenet-values.yaml b/helm/prenet-values.yaml index 37f6b5c7..f4dc93b9 100644 --- a/helm/prenet-values.yaml +++ b/helm/prenet-values.yaml @@ -64,6 +64,13 @@ deployments: containerPorts: public_api: 80 p2p: 8080 + cloudsql: + usePrivateIP: true + project: prenet + region: us-central1 + db_instance: polybase + image: sql_proxy + tag: 1.0.0 - name: indexer labels: app: polybase diff --git a/helm/templates/deployments.yaml b/helm/templates/deployments.yaml index 4ce00dde..b43161b9 100644 --- a/helm/templates/deployments.yaml +++ b/helm/templates/deployments.yaml @@ -17,12 +17,12 @@ metadata: spec: selector: matchLabels: - app: polybase + {{- include "polybase.labels" $ | nindent 8 }} replicas: {{ .replicaCount }} template: metadata: labels: - app: polybase + {{- include "polybase.labels" $ | nindent 8 }} {{- if .podLabels }} {{- toYaml .podLabels | nindent 8 }} {{- end }} @@ -40,69 +40,88 @@ spec: tolerations: {{- include "polybase.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }} {{- end }} containers: - - name: {{ .name }} - command: {{ .command }} - {{- if .args }} - args: {{ .args }} + - name: {{ .name }} + command: {{ .command }} + {{- if .args }} + args: {{ .args }} + {{- end }} + image: {{ include "polybase.main_image" $ }} + imagePullPolicy: {{ .imagePullPolicy | quote }} + env: + {{- if .extraEnvVars }} + {{- include "polybase.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 10 }} {{- end }} - image: {{ include "polybase.main_image" $ }} - imagePullPolicy: {{ .imagePullPolicy | quote }} - env: - FOO: BAR - {{- if .extraEnvVars }} - {{- include "polybase.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 10 }} + {{- if .customLivenessProbe }} + livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} + {{- else if .livenessProbe.enabled }} + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: {{ .livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .livenessProbe.periodSeconds }} + timeoutSeconds: {{ .livenessProbe.timeoutSeconds }} + successThreshold: {{ .livenessProbe.successThreshold }} + failureThreshold: {{ .livenessProbe.failureThreshold }} + {{- end }} + {{- if .customReadinessProbe }} + readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} + {{- else if .readinessProbe.enabled }} + readinessProbe: + httpGet: + path: /v0/health + port: 8080 + initialDelaySeconds: {{ .readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .readinessProbe.periodSeconds }} + timeoutSeconds: {{ .readinessProbe.timeoutSeconds }} + successThreshold: {{ .readinessProbe.successThreshold }} + failureThreshold: {{ .readinessProbe.failureThreshold }} + {{- end }} + {{- if .customStartupProbe }} + startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} + {{- else if .startupProbe.enabled }} + startupProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: {{ .startupProbe.initialDelaySeconds }} + periodSeconds: {{ .startupProbe.periodSeconds }} + timeoutSeconds: {{ .startupProbe.timeoutSeconds }} + successThreshold: {{ .startupProbe.successThreshold }} + failureThreshold: {{ .startupProbe.failureThreshold }} + {{- end }} + ports: + - name: public-api + containerPort: {{ .containerPorts.public_api | default "8080" }} + {{- if .hostNetwork }} + hostPort: {{ .containerPorts.public_api }} {{- end }} - {{- if .customLivenessProbe }} - livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} - {{- else if .livenessProbe.enabled }} - livenessProbe: - httpGet: - path: / - port: 8080 - initialDelaySeconds: {{ .livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .livenessProbe.periodSeconds }} - timeoutSeconds: {{ .livenessProbe.timeoutSeconds }} - successThreshold: {{ .livenessProbe.successThreshold }} - failureThreshold: {{ .livenessProbe.failureThreshold }} - {{- end }} - {{- if .customReadinessProbe }} - readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} - {{- else if .readinessProbe.enabled }} - readinessProbe: - httpGet: - path: /v0/health - port: 8080 - initialDelaySeconds: {{ .readinessProbe.initialDelaySeconds }} - periodSeconds: {{ .readinessProbe.periodSeconds }} - timeoutSeconds: {{ .readinessProbe.timeoutSeconds }} - successThreshold: {{ .readinessProbe.successThreshold }} - failureThreshold: {{ .readinessProbe.failureThreshold }} - {{- end }} - {{- if .customStartupProbe }} - startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} - {{- else if .startupProbe.enabled }} - startupProbe: - httpGet: - path: / - port: 8080 - initialDelaySeconds: {{ .startupProbe.initialDelaySeconds }} - periodSeconds: {{ .startupProbe.periodSeconds }} - timeoutSeconds: {{ .startupProbe.timeoutSeconds }} - successThreshold: {{ .startupProbe.successThreshold }} - failureThreshold: {{ .startupProbe.failureThreshold }} - {{- end }} - ports: - - name: public-api - containerPort: {{ .containerPorts.public_api | default "8080" }} - {{- if .hostNetwork }} - hostPort: {{ .containerPorts.public_api }} - {{- end }} - - name: p2p - containerPort: {{ .containerPorts.p2p | default "5001" }} - {{- if .hostNetwork }} - hostPort: {{ .containerPorts.p2p }} - {{- end }} - {{- if .resources }} - resources: {{ toYaml .resources | nindent 12 }} - {{- end }} + - name: p2p + containerPort: {{ .containerPorts.p2p | default "5001" }} + {{- if .hostNetwork }} + hostPort: {{ .containerPorts.p2p }} + {{- end }} + {{- if .resources }} + resources: {{ toYaml .resources | nindent 12 }} + {{- end }} + + #cloudsql + {{- if .cloudsql }} + - name: {{ .name }}-sql-proxy + args: + {{- if .cloudsql.credentialFile }} + - --credentials-file={{ .cloudsql.credentialFile }} + {{- end }} + {{- if .cloudsql.usePrivateIP }} + - --private-ip + {{- end }} + - --max-sigterm-delay={{ .cloudsql.timeout | default "30s" }} + - "{{ .project }}:{{ .cloudsql.region }}:{{ .cloudsql.db_instance }}" + image: {{ .cloudsql.image }}:{{ .cloudsql.tag }} + imagePullPolicy: IfNotPresent + securityContext: + {{- toYaml .cloudsql.securityContext | nindent 12 }} + resources: + {{- toYaml .cloudsql.resources | nindent 12 }} + {{- end }} {{- end }}