From b37e0d6d7ce569a0d10d883df24b457d3f010053 Mon Sep 17 00:00:00 2001 From: Tommy Date: Tue, 19 Dec 2023 17:47:53 +0100 Subject: [PATCH] feat(hasura-engine) add graphql server chart --- charts/hasura-engine/Chart.yaml | 5 ++ charts/hasura-engine/README.md | 3 ++ charts/hasura-engine/templates/_helpers.tpl | 25 +++++++++ .../hasura-engine/templates/deployment.yaml | 53 +++++++++++++++++++ charts/hasura-engine/templates/service.yaml | 14 +++++ charts/hasura-engine/values.yaml | 33 ++++++++++++ 6 files changed, 133 insertions(+) create mode 100644 charts/hasura-engine/Chart.yaml create mode 100644 charts/hasura-engine/README.md create mode 100644 charts/hasura-engine/templates/_helpers.tpl create mode 100644 charts/hasura-engine/templates/deployment.yaml create mode 100644 charts/hasura-engine/templates/service.yaml create mode 100644 charts/hasura-engine/values.yaml diff --git a/charts/hasura-engine/Chart.yaml b/charts/hasura-engine/Chart.yaml new file mode 100644 index 0000000..b97a628 --- /dev/null +++ b/charts/hasura-engine/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: hasura-engine +description: GraphQL Engine to make data accessible over a GraphQL API +type: application +version: 0.1.2 \ No newline at end of file diff --git a/charts/hasura-engine/README.md b/charts/hasura-engine/README.md new file mode 100644 index 0000000..a26f278 --- /dev/null +++ b/charts/hasura-engine/README.md @@ -0,0 +1,3 @@ + + +https://cloudnative-pg.io/blog/hasura-graphql/ \ No newline at end of file diff --git a/charts/hasura-engine/templates/_helpers.tpl b/charts/hasura-engine/templates/_helpers.tpl new file mode 100644 index 0000000..9e93c8c --- /dev/null +++ b/charts/hasura-engine/templates/_helpers.tpl @@ -0,0 +1,25 @@ +{{- define "hasura.fullname" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end }} + +# Define a template for standard labels. +{{/* +Common labels +*/}} +{{- define "hasura.labels" -}} +helm.sh/chart: {{ include "hasura.chart" . }} +app.kubernetes.io/name: {{ include "hasura.fullname" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/version: {{ .Chart.Version | quote }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +# Define a template for the chart name and version. +{{/* +Generate basic labels +*/}} +{{- define "hasura.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" -}} +{{- end }} + +# Optionally, add more helper templates as needed. diff --git a/charts/hasura-engine/templates/deployment.yaml b/charts/hasura-engine/templates/deployment.yaml new file mode 100644 index 0000000..c417545 --- /dev/null +++ b/charts/hasura-engine/templates/deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hasura.fullname" . }} + labels: + {{- include "hasura.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "hasura.fullname" . }} + template: + metadata: + labels: + app: {{ include "hasura.fullname" . }} + spec: + initContainers: + - name: db-init + image: "{{ .Values.initContainers.dbInit.image.repository }}:{{ .Values.initContainers.dbInit.image.tag }}" + envFrom: + - secretRef: + name: {{ .Values.envFromSecret }} + containers: + - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + name: hasura + env: + - name: HASURA_GRAPHQL_ADMIN_INTERNAL_ERRORS + value: "false" + - name: HASURA_GRAPHQL_ENABLE_MAINTENANCE_MODE + value: "false" + - name: HASURA_GRAPHQL_CORS_DOMAIN + value: "{{ .Values.corsDomains }}" + - name: HASURA_GRAPHQL_ENABLE_CONSOLE + value: "{{ .Values.features.console }}" + - name: HASURA_GRAPHQL_DEV_MODE + value: "{{ .Values.features.devMode }}" + envFrom: + - secretRef: + name: {{ .Values.envFromSecret }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: http + readinessProbe: + httpGet: + path: /healthz + port: http + resources: {} diff --git a/charts/hasura-engine/templates/service.yaml b/charts/hasura-engine/templates/service.yaml new file mode 100644 index 0000000..1b84a70 --- /dev/null +++ b/charts/hasura-engine/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hasura.fullname" . }} + labels: + {{- include "hasura.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 8080 + protocol: TCP + selector: + app: {{ include "hasura.fullname" . }} diff --git a/charts/hasura-engine/values.yaml b/charts/hasura-engine/values.yaml new file mode 100644 index 0000000..483be9b --- /dev/null +++ b/charts/hasura-engine/values.yaml @@ -0,0 +1,33 @@ +image: + repository: hasura/graphql-engine + tag: v2.36.0 + pullPolicy: IfNotPresent + +initContainers: + dbInit: + image: + repository: ghcr.io/onedr0p/postgres-init + tag: "16" + envFrom: + - secretRef: + name: dispatch-secret + +replicas: "1" + +service: + type: ClusterIP + port: 80 + +features: + devMode: true + console: true + +corsDomains: "*" + +envFromSecret: hasura-secret +admin: + secretKey: HASURA_GRAPHQL_ADMIN_SECRET +jwt: + secretKey: HASURA_GRAPHQL_JWT_SECRET +postgres: + secretKey: HASURA_GRAPHQL_DATABASE_URL \ No newline at end of file