From bb50fc9fde1f35590e2ca5089b191f812784ea75 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 15 Dec 2023 18:53:09 +0100 Subject: [PATCH] feat(dispatch) add support for Netflix Dispatch --- charts/dispatch/Chart.yaml | 4 ++ charts/dispatch/templates/NOTES.txt | 1 + charts/dispatch/templates/_helpers.tpl | 30 ++++++++++++++ charts/dispatch/templates/configmap.yaml | 8 ++++ .../dispatch/templates/core-deployment.yaml | 32 +++++++++++++++ .../templates/scheduler-deployment.yaml | 26 +++++++++++++ charts/dispatch/templates/web-deployment.yaml | 32 +++++++++++++++ charts/dispatch/templates/web-service.yaml | 14 +++++++ charts/dispatch/values.yaml | 39 +++++++++++++++++++ 9 files changed, 186 insertions(+) create mode 100644 charts/dispatch/Chart.yaml create mode 100644 charts/dispatch/templates/NOTES.txt create mode 100644 charts/dispatch/templates/_helpers.tpl create mode 100644 charts/dispatch/templates/configmap.yaml create mode 100644 charts/dispatch/templates/core-deployment.yaml create mode 100644 charts/dispatch/templates/scheduler-deployment.yaml create mode 100644 charts/dispatch/templates/web-deployment.yaml create mode 100644 charts/dispatch/templates/web-service.yaml create mode 100644 charts/dispatch/values.yaml diff --git a/charts/dispatch/Chart.yaml b/charts/dispatch/Chart.yaml new file mode 100644 index 0000000..c9b73de --- /dev/null +++ b/charts/dispatch/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: dispatch +description: Netflix Dispatch incident management system +version: 0.1.0 \ No newline at end of file diff --git a/charts/dispatch/templates/NOTES.txt b/charts/dispatch/templates/NOTES.txt new file mode 100644 index 0000000..aa4128b --- /dev/null +++ b/charts/dispatch/templates/NOTES.txt @@ -0,0 +1 @@ +NOTES.txt \ No newline at end of file diff --git a/charts/dispatch/templates/_helpers.tpl b/charts/dispatch/templates/_helpers.tpl new file mode 100644 index 0000000..153dd57 --- /dev/null +++ b/charts/dispatch/templates/_helpers.tpl @@ -0,0 +1,30 @@ +# Define a template for the chart's full name. +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "dispatch.fullname" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end }} + +# Define a template for standard labels. +{{/* +Common labels +*/}} +{{- define "dispatch.labels" -}} +helm.sh/chart: {{ include "dispatch.chart" . }} +app.kubernetes.io/name: {{ include "dispatch.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 "dispatch.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" -}} +{{- end }} + +# Optionally, add more helper templates as needed. diff --git a/charts/dispatch/templates/configmap.yaml b/charts/dispatch/templates/configmap.yaml new file mode 100644 index 0000000..e915f0f --- /dev/null +++ b/charts/dispatch/templates/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "dispatch.fullname" . }}-config + labels: + {{- include "dispatch.labels" . | nindent 4 }} +data: + {{- toYaml .Values.configMap.general | nindent 2 }} \ No newline at end of file diff --git a/charts/dispatch/templates/core-deployment.yaml b/charts/dispatch/templates/core-deployment.yaml new file mode 100644 index 0000000..33b8510 --- /dev/null +++ b/charts/dispatch/templates/core-deployment.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dispatch.fullname" . }}-core + labels: + {{- include "dispatch.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "dispatch.fullname" . }}-core + template: + metadata: + labels: + app: {{ include "dispatch.fullname" . }}-core + spec: + initContainers: + - name: db-init + image: "{{ .Values.initContainers.dbInit.image.repository }}:{{ .Values.initContainers.dbInit.image.tag }}" + envFrom: + - secretRef: + name: {{ .Values.postgres.secretRef.name }} + containers: + - name: core + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: {{ .Values.core.container.command }} + envFrom: + - configMapRef: + name: {{ include "dispatch.fullname" . }}-config + - secretRef: + name: {{ .Values.postgres.secretRef.name }} \ No newline at end of file diff --git a/charts/dispatch/templates/scheduler-deployment.yaml b/charts/dispatch/templates/scheduler-deployment.yaml new file mode 100644 index 0000000..c975813 --- /dev/null +++ b/charts/dispatch/templates/scheduler-deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dispatch.fullname" . }}-scheduler + labels: + {{- include "dispatch.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "dispatch.fullname" . }}-scheduler + template: + metadata: + labels: + app: {{ include "dispatch.fullname" . }}-scheduler + spec: + containers: + - name: scheduler + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: {{ .Values.scheduler.command }} + envFrom: + - configMapRef: + name: {{ include "dispatch.fullname" . }}-config + - secretRef: + name: {{ .Values.postgres.secretRef.name }} diff --git a/charts/dispatch/templates/web-deployment.yaml b/charts/dispatch/templates/web-deployment.yaml new file mode 100644 index 0000000..e04dba1 --- /dev/null +++ b/charts/dispatch/templates/web-deployment.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dispatch.fullname" . }}-web + labels: + {{- include "dispatch.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "dispatch.fullname" . }}-web + template: + metadata: + labels: + app: {{ include "dispatch.fullname" . }}-web + spec: + containers: + - name: web + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: {{ .Values.web.command }} + ports: + - containerPort: {{ .Values.web.container.port }} + service: + type: ClusterIP + port: 80 + targetPort: 8000 + envFrom: + - configMapRef: + name: {{ include "dispatch.fullname" . }}-config + - secretRef: + name: {{ .Values.postgres.secretRef.name }} \ No newline at end of file diff --git a/charts/dispatch/templates/web-service.yaml b/charts/dispatch/templates/web-service.yaml new file mode 100644 index 0000000..508a8cb --- /dev/null +++ b/charts/dispatch/templates/web-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dispatch.fullname" . }}-web + labels: + {{- include "dispatch.labels" . | nindent 4 }} +spec: + type: {{ .Values.web.service.type }} + ports: + - port: {{ .Values.web.service.port }} + targetPort: {{ .Values.web.container.port }} + protocol: TCP + selector: + app: {{ include "dispatch.fullname" . }}-web diff --git a/charts/dispatch/values.yaml b/charts/dispatch/values.yaml new file mode 100644 index 0000000..124c22f --- /dev/null +++ b/charts/dispatch/values.yaml @@ -0,0 +1,39 @@ +image: + repository: ghcr.io/tommy-skaug/dispatch + tag: v20230919 + pullPolicy: Always + +initContainers: + dbInit: + image: + repository: ghcr.io/onedr0p/postgres-init + tag: "16" + envFrom: + - secretRef: + name: dispatch-secret + +core: + container: + command: [] + +web: + container: + port: 8000 + command: ["server", "start", "dispatch.main:app", "--host=0.0.0.0"] + service: + type: ClusterIP + port: 80 + +scheduler: + command: ["scheduler", "start"] + +configMap: + general: + COMPOSE_PROJECT_NAME: "dispatch" + DATABASE_HOSTNAME: "postgres-rw.databases.svc.cluster.local" + DATABASE_NAME: "dispatch" + DATABASE_PORT: "5432" + +postgres: + secretRef: + name: dispatch-secret \ No newline at end of file