Skip to content

Commit

Permalink
feat(helm): add task runner and prefect dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Fatih Acar <[email protected]>
  • Loading branch information
fatih-acar authored and dgarros committed Sep 13, 2024
1 parent c9d1d35 commit 5a3bcf6
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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: 2.7.0
version: 2.8.0
# 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
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down Expand Up @@ -46,3 +46,7 @@ dependencies:
version: "28.2.0"
repository: "https://traefik.github.io/charts"
condition: traefik.enabled
- name: prefect-server
version: "2024.7.25191224"
repository: "https://prefecthq.github.io/prefect-helm"
condition: prefect-server.enabled
43 changes: 43 additions & 0 deletions helm/templates/_env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,46 @@ Define default env variables if required.
value: "{{ .Values.redis.master.service.ports.redis }}"
{{- end }}
{{- end }}

{{- define "infrahub-helm.infrahubTaskRunner.defaultEnv" -}}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.KUBERNETES_CLUSTER_DOMAIN }}
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.global.kubernetesClusterDomain }}
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_ADDRESS }}
- name: INFRAHUB_ADDRESS
value: http://{{ include "infrahub-helm.fullname" . }}-infrahub-server.{{ .Release.Namespace }}.svc.{{ .Values.global.kubernetesClusterDomain }}:8000
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_INTERNAL_ADDRESS }}
- name: INFRAHUB_INTERNAL_ADDRESS
value: "http://{{ include "infrahub-helm.fullname" . }}-infrahub-server.{{ .Release.Namespace }}.svc.{{ .Values.global.kubernetesClusterDomain }}:8000"
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_DB_ADDRESS }}
- name: INFRAHUB_DB_ADDRESS
value: "{{ include "infrahub-helm.fullname" . }}-database.{{ .Release.Namespace }}.svc.{{ .Values.global.kubernetesClusterDomain }}"
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_DB_PORT }}
- name: INFRAHUB_DB_PORT
value: "{{ .Values.neo4j.services.neo4j.ports.bolt.port }}"
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_BROKER_ADDRESS }}
- name: INFRAHUB_BROKER_ADDRESS
value: "{{ include "infrahub-helm.fullname" . }}-message-queue.{{ .Release.Namespace }}.svc.{{ .Values.global.kubernetesClusterDomain }}"
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_BROKER_USERNAME }}
- name: INFRAHUB_BROKER_USERNAME
value: {{ .Values.rabbitmq.auth.username | quote }}
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_BROKER_PASSWORD }}
- name: INFRAHUB_BROKER_PASSWORD
value: {{ .Values.rabbitmq.auth.password | quote }}
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_CACHE_ADDRESS }}
- name: INFRAHUB_CACHE_ADDRESS
value: "{{ include "infrahub-helm.fullname" . }}-cache-master.{{ .Release.Namespace }}.svc.{{ .Values.global.kubernetesClusterDomain }}"
{{- end }}
{{- if not .Values.infrahubTaskRunner.infrahubTaskRunner.env.INFRAHUB_CACHE_PORT }}
- name: INFRAHUB_CACHE_PORT
value: "{{ .Values.redis.master.service.ports.redis }}"
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions helm/templates/infrahub-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ spec:
volumeMounts:
- mountPath: /opt/infrahub/storage
name: infrahub-server-storage-data
- name: workflow-data
mountPath: /opt/infrahub/workflow
restartPolicy: Always
volumes:
{{- if and .Values.infrahubServer.persistence.enabled }}
Expand All @@ -83,6 +85,14 @@ spec:
- name: infrahub-server-storage-data
emptyDir: {}
{{- end }}
{{- if and .Values.infrahubTaskRunner.persistence.enabled }}
- name: workflow-data
persistentVolumeClaim:
claimName: {{ tpl (.Values.infrahubTaskRunner.persistence.existingClaim | default (printf "%s-%s" (include "infrahub-helm.fullname" .) "workflow-data")) . }}
{{- else }}
- name: workflow-data
emptyDir: {}
{{- end }}

---
apiVersion: v1
Expand Down
97 changes: 97 additions & 0 deletions helm/templates/infrahub-task-runner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "infrahub-helm.fullname" . }}-infrahub-task-runner
labels:
service: infrahub-task-runner
{{- include "infrahub-helm.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.infrahubTaskRunner.replicas | default 1 }}
selector:
matchLabels:
service: infrahub-task-runner
{{- include "infrahub-helm.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
service: infrahub-task-runner
{{- with .Values.infrahubTaskRunner.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "infrahub-helm.selectorLabels" . | nindent 8 }}
{{- with .Values.infrahubTaskRunner.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.infrahubTaskRunner.affinity }}
affinity: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.infrahubTaskRunner.tolerations }}
tolerations: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.infrahubTaskRunner.runtimeClassName }}
runtimeClassName: {{ . }}
{{- end }}
containers:
- args: {{- toYaml .Values.infrahubTaskRunner.infrahubTaskRunner.args | nindent 12 }}
env:
{{- include "infrahub-helm.infrahubTaskRunner.defaultEnv" . | nindent 12 }}
{{- range $key, $value := .Values.infrahubTaskRunner.infrahubTaskRunner.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- with .Values.infrahubTaskRunner.infrahubTaskRunner.envFromExistingSecret }}
envFrom:
- secretRef:
name: {{ . }}
{{- end }}
image: {{ default .Values.global.imageRegistry .Values.infrahubTaskRunner.infrahubTaskRunner.imageRegistry }}/{{ .Values.global.infrahubRepository }}:{{ .Values.global.infrahubTag | default .Chart.AppVersion }}
imagePullPolicy: {{ default .Values.global.imagePullPolicy .Values.infrahubTaskRunner.infrahubTaskRunner.imagePullPolicy }}
name: infrahub-task-runner
resources: {}
tty: true
volumeMounts:
- name: git-data
mountPath: /opt/infrahub/git
- name: workflow-data
mountPath: /opt/infrahub/workflow
restartPolicy: Always
volumes:
{{- if and .Values.infrahubGit.persistence.enabled }}
- name: git-data
persistentVolumeClaim:
claimName: {{ tpl (.Values.infrahubGit.persistence.existingClaim | default (printf "%s-%s" (include "infrahub-helm.fullname" .) "git-data")) . }}
{{- else }}
- name: git-data
emptyDir: {}
{{- end }}
{{- if and .Values.infrahubTaskRunner.persistence.enabled }}
- name: workflow-data
persistentVolumeClaim:
claimName: {{ tpl (.Values.infrahubTaskRunner.persistence.existingClaim | default (printf "%s-%s" (include "infrahub-helm.fullname" .) "workflow-data")) . }}
{{- else }}
- name: workflow-data
emptyDir: {}
{{- end }}

{{- if and .Values.infrahubTaskRunner.persistence.enabled (not .Values.infrahubTaskRunner.persistence.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "infrahub-helm.fullname" . }}-workflow-data
labels:
service: workflow-data
{{- include "infrahub-helm.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.infrahubTaskRunner.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.infrahubTaskRunner.persistence.size | quote }}
{{- with .Values.infrahubTaskRunner.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- end }}
60 changes: 60 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,45 @@ infrahubGit:
INFRAHUB_API_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_TIMEOUT: "20"
INFRAHUB_GIT_REPOSITORIES_DIRECTORY: "/opt/infrahub/git"
PREFECT_API_URL: "http://prefect-server:4200/api"
PREFECT_WORKER_QUERY_SECONDS: 3
PREFECT_AGENT_QUERY_INTERVAL: 3
PREFECT_LOCAL_STORAGE_PATH: /opt/infrahub/workflow
imagePullPolicy: Always
imageRegistry: registry.opsmill.io

# ----------- Infrahub Task Runner -----------
infrahubTaskRunner:
replicas: 2
persistence:
enabled: true
size: 100Mi
accessMode: ReadWriteMany
storageClassName: nfs
infrahubTaskRunner:
args:
- prefect
- worker
- start
- --type
- infrahubasync
- --pool
- infrahub-internal
- --with-healthcheck
env:
INFRAHUB_CACHE_PORT: 6379
INFRAHUB_DB_TYPE: neo4j
INFRAHUB_LOG_LEVEL: DEBUG
INFRAHUB_PRODUCTION: "false"
INFRAHUB_API_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_TIMEOUT: "20"
INFRAHUB_GIT_REPOSITORIES_DIRECTORY: "/opt/infrahub/git"
INFRAHUB_WORKFLOW_ADDRESS: prefect-server
INFRAHUB_WORKFLOW_PORT: 4200
PREFECT_API_URL: "http://prefect-server:4200/api"
PREFECT_WORKER_QUERY_SECONDS: 3
PREFECT_AGENT_QUERY_INTERVAL: 3
PREFECT_LOCAL_STORAGE_PATH: /opt/infrahub/workflow
imagePullPolicy: Always
imageRegistry: registry.opsmill.io

Expand Down Expand Up @@ -105,6 +144,10 @@ infrahubServer:
INFRAHUB_INITIAL_ADMIN_TOKEN: 06438eb2-8019-4776-878c-0941b1f1d1ec
INFRAHUB_SECURITY_SECRET_KEY: 327f747f-efac-42be-9e73-999f08f86b92
INFRAHUB_GIT_REPOSITORIES_DIRECTORY: "/opt/infrahub/git"
INFRAHUB_WORKFLOW_ADDRESS: prefect-server
INFRAHUB_WORKFLOW_PORT: 4200
PREFECT_API_URL: "http://prefect-server:4200/api"
PREFECT_LOCAL_STORAGE_PATH: /opt/infrahub/workflow
imagePullPolicy: Always
imageRegistry: registry.opsmill.io
ports:
Expand Down Expand Up @@ -165,6 +208,23 @@ nats:
jetstream:
enabled: true

# ------------- Prefect -------------
prefect-server:
enabled: true
server:
image:
prefectTag: 3.0.0-python3.12-kubernetes
env:
- name: PREFECT_UI_SERVE_BASE
value: /
serviceAccount:
create: false
postgresql:
enabled: true
primary:
persistence:
enabled: false

# -------------- Cloud --------------
traefik:
enabled: false
Expand Down

0 comments on commit 5a3bcf6

Please sign in to comment.