Skip to content

Commit

Permalink
Enable Data API and Hasura in CKAN charts (#13)
Browse files Browse the repository at this point in the history
* Enable hasura in k8s
* Add hasura envars
* Add data-api svc/secret/deployment
  • Loading branch information
MuhammadIsmailShahzad authored Feb 6, 2023
1 parent 6c240a3 commit 8ec6181
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ckan/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v3.0.1
version: v3.0.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
60 changes: 60 additions & 0 deletions ckan/templates/data-api-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{ if .Values.dataAPI.enable }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.general.projectId }}-data-api
labels:
app: data-api
spec:
{{ if not .Values.dataAPI.hpa.enable }}
replicas: {{ .Values.dataAPI.replicaCount | default 1 }}
{{ end }}
selector:
matchLabels:
app: data-api
template:
metadata:
labels:
app: data-api
spec:
{{ if .Values.general.imagePullSecrets }}
imagePullSecrets:
- name: {{ .Values.general.imagePullSecrets }}
{{ end }}
containers:
- name: data-api
{{ if .Values.dataAPI.image.digest }}
image: {{ .Values.dataAPI.image.repository | default "datopian/data-api" }}@{{ .Values.dataAPI.image.digest }}
{{ else }}
image: {{ .Values.dataAPI.image.repository | default "datopian/data-api" }}:{{ .Values.dataAPI.image.tag }}
{{ end }}
imagePullPolicy: {{ .Values.dataAPI.image.pullPolicy | default "Always" }}
{{ if .Values.dataAPI.env }}
envFrom:
- secretRef:
name: {{ .Values.general.projectId }}-data-api-envvars
{{ end }}
{{ if .Values.dataAPI.livenessProbe }}
livenessProbe:
{{ with .Values.dataAPI.livenessProbe }}
{{ toYaml . | nindent 12 }}
{{ end }}
{{ end }}
resources:
{{ if .Values.dataAPI.resources }}
{{ with .Values.dataAPI.resources }}
{{ toYaml . | nindent 12 }}
{{ end }}
{{ else }}
limits:
cpu: 600m
memory: 1G
requests:
cpu: 100m
memory: 0.8G
{{ end }}
ports:
- containerPort: 3000
protocol: TCP

{{ end }}
17 changes: 17 additions & 0 deletions ckan/templates/data-api-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ if .Values.dataAPI.enable }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.general.projectId }}-data-api-svc
spec:
type: {{ .Values.dataAPI.serviceType | default "ClusterIP" }}
ports:
- port: {{ .Values.dataAPI.port | default 80 }}
targetPort: {{ .Values.dataAPI.targetPort | default 3000 }}
protocol: TCP
name: http
selector:
app: data-api
{{ end }}


53 changes: 53 additions & 0 deletions ckan/templates/hasura-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{ if .Values.hasura.enable }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.general.projectId }}-hasura
labels:
app: hasura
spec:
{{ if not .Values.hasura.hpa.enable }}
replicas: {{ .Values.hasura.replicaCount | default 1 }}
{{ end }}
selector:
matchLabels:
app: hasura
template:
metadata:
labels:
app: hasura
spec:
{{ if .Values.general.imagePullSecrets }}
imagePullSecrets:
- name: {{ .Values.general.imagePullSecrets }}
{{ end }}
containers:
- name: hasura
{{ if .Values.hasura.image.digest }}
image: {{ .Values.hasura.image.repository | default "hasura/graphql-engine" }}@{{ .Values.hasura.image.digest }}
{{ else }}
image: {{ .Values.hasura.image.repository | default "hasura/graphql-engine" }}:{{ .Values.hasura.image.tag }}
{{ end }}
{{ if .Values.hasura.env }}
envFrom:
- secretRef:
name: {{ .Values.general.projectId }}-hasura-envvars
{{ end }}
resources:
{{ if .Values.hasura.resources }}
{{ with .Values.hasura.resources }}
{{ toYaml . | nindent 12 }}
{{ end }}
{{ else }}
limits:
cpu: 600m
memory: 1G
requests:
cpu: 100m
memory: 0.8G
{{ end }}
ports:
- containerPort: 8080
protocol: TCP

{{ end }}
15 changes: 15 additions & 0 deletions ckan/templates/hasura-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ if .Values.hasura.enable }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.general.projectId }}-hasura-svc
spec:
type: {{ .Values.hasura.serviceType | default "ClusterIP" }}
ports:
- port: {{ .Values.hasura.port | default 80 }}
targetPort: {{ .Values.hasura.targetPort | default 8080 }}
protocol: TCP
name: http
selector:
app: hasura
{{ end }}
11 changes: 11 additions & 0 deletions ckan/templates/secrets/data-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.dataAPI.enable -}}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ .Values.general.projectId }}-data-api-envvars
{{- with .Values.dataAPI.env }}
stringData:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions ckan/templates/secrets/hasura.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.hasura.enable -}}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ .Values.general.projectId }}-hasura-envvars
{{- with .Values.hasura.env }}
stringData:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}

0 comments on commit 8ec6181

Please sign in to comment.