Skip to content

Commit

Permalink
Merge pull request #137 from shoplineapp/feature/PLAT-428-Queue-Shard…
Browse files Browse the repository at this point in the history
…-update-to-use-Argo-event

feat: Create helm template for argo-event
  • Loading branch information
neal-sl authored Dec 20, 2023
2 parents ae63981 + 430e40b commit 158806a
Show file tree
Hide file tree
Showing 10 changed files with 566 additions and 0 deletions.
23 changes: 23 additions & 0 deletions argo-event/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions argo-event/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: argo-event
description: A Helm chart for deploying argo event
type: application
version: 0.0.1
8 changes: 8 additions & 0 deletions argo-event/templates/_eventsource.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- define "source.webhook" }}
{{- $item := index . 0 -}}
{{- $globalVal := index . 1 -}}
{{- $item.eventName | required "Missing eventName" }}:
endpoint: {{ $item.endpoint | required (printf "Missing endpoint for source: %s" $item.eventName) | printf "/webhook%s" }}
method: {{ $item.method | required (printf "Missing method for source: %s " $item.eventName) }}
port: {{ $globalVal.eventsource.config.webhookPort | quote}}
{{- end }}
9 changes: 9 additions & 0 deletions argo-event/templates/_helper.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- define "helper.containType" -}}
{{- $list := index . 0 -}}
{{- $search := index . 1 -}}
{{- if eq (first $list).type $search -}}
yes
{{- else if gt 1 (len $list) -}}
{{- include "helper.containType" (list (rest $list) $search) -}}
{{- end -}}
{{- end -}}
11 changes: 11 additions & 0 deletions argo-event/templates/_sensor.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- define "trigger.http" }}
http:
url: {{ .url }}
method: {{ .method | default "POST"}}
headers:
content-type: application/json
{{- with .payload }}
payload:
{{- toYaml . | nindent 14 }}
{{- end -}}
{{- end }}
83 changes: 83 additions & 0 deletions argo-event/templates/eventbus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: argoproj.io/v1alpha1
kind: EventBus
metadata:
name: {{ .Values.name }}
labels:
{{- with .Values.labels }}
{{ toYaml . | nindent 4 }}
{{- end }}
app: {{ .Values.name }}-eventbus
spec:
jetstream:
metadata:
labels:
{{- with .Values.labels }}
{{ toYaml . | nindent 8 }}
{{- end }}
app: {{ .Values.name }}-eventbus

version: {{ .Values.eventbus.config.version }}

affinity:
{{- with .Values.eventbus.config.affinity.nodeAffinity }}
nodeAffinity: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.eventbus.config.affinity.podAffinity }}
podAffinity: {{- toYaml . | nindent 8 }}
{{- end }}
podAntiAffinity:
{{- with .Values.eventbus.config.affinity.podAntiAffinity }}
{{- if hasKey . "requiredDuringSchedulingIgnoredDuringExecution" }}
requiredDuringSchedulingIgnoredDuringExecution: {{- toYaml .requiredDuringSchedulingIgnoredDuringExecution | nindent 10 }}
{{- end }}
{{- end }}
preferredDuringSchedulingIgnoredDuringExecution:
{{- with .Values.eventbus.config.affinity.podAntiAffinity }}
{{- if hasKey . "preferredDuringSchedulingIgnoredDuringExecution" }}
{{- toYaml .preferredDuringSchedulingIgnoredDuringExecution | nindent 10 }}
{{- end }}
{{- end }}
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Values.name }}-eventbus
topologyKey: topology.kubernetes.io/zone
weight: 100
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Values.name }}-eventbus
topologyKey: kubernetes.io/hostname
weight: 99

{{- with .Values.eventbus.config.persistence }}
persistence:
{{- with .storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- with .accessMode }}
accessMode: {{ . }}
{{- end }}
volumeSize: {{ .volumeSize | required "Missing volumeSize for jetstream"}}
{{- end }}

replicas: {{ .Values.eventbus.config.replicas | min 3 }}

{{- with .Values.eventbus.config }}
streamConfig: |
{{- with .maxAge }}
maxAge: {{ . }}
{{- end }}
{{- with .duplicates }}
duplicates: {{ . }}
{{- end }}
{{- end }}

settings: |
max_file_store: {{ .Values.eventbus.config.maxFileStore }}
73 changes: 73 additions & 0 deletions argo-event/templates/eventsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: {{ .Values.name }}
labels:
{{- with .Values.labels }}
{{ toYaml . | nindent 4 }}
{{- end }}
app: {{ .Values.name }}-eventsource
spec:
eventBusName: {{ .Values.name }}
replicas: {{ .Values.eventsource.config.replicas | max 1 }}

template:
metadata:
labels:
{{- with .Values.labels }}
{{ toYaml . | nindent 8 }}
{{- end }}
app: {{ .Values.name }}-eventsource
affinity:
{{- with .Values.eventsource.config.affinity.nodeAffinity }}
nodeAffinity: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.eventsource.config.affinity.podAffinity }}
podAffinity: {{- toYaml . | nindent 8 }}
{{- end }}
podAntiAffinity:
{{- with .Values.eventsource.config.affinity.podAntiAffinity }}
{{- if hasKey . "requiredDuringSchedulingIgnoredDuringExecution" }}
requiredDuringSchedulingIgnoredDuringExecution: {{- toYaml .requiredDuringSchedulingIgnoredDuringExecution | nindent 10 }}
{{- end }}
{{- end }}
preferredDuringSchedulingIgnoredDuringExecution:
{{- with .Values.eventsource.config.affinity.podAntiAffinity }}
{{- if hasKey . "preferredDuringSchedulingIgnoredDuringExecution" }}
{{- toYaml .preferredDuringSchedulingIgnoredDuringExecution | nindent 10 }}
{{- end }}
{{- end }}
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Values.name }}-eventsource
topologyKey: topology.kubernetes.io/zone
weight: 100
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Values.name }}-eventsource
topologyKey: kubernetes.io/hostname
weight: 99

service:
ports:
- port: {{ .Values.eventsource.config.servicePort }}
targetPort: {{ .Values.eventsource.config.webhookPort }}

{{- with .Values.eventsource.source -}}
{{if eq (include "helper.containType" (list . "webhook" )) "yes" }}
webhook:
{{- range $index, $element := . }}
{{- if eq $element.type "webhook" }}
{{ template "source.webhook" (list $element $.Values) }}
{{- end }}
{{- end }}
{{- end -}}
{{ end }}
31 changes: 31 additions & 0 deletions argo-event/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.ingress -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Values.name }}
annotations:
{{- toYaml .Values.ingress.annotations | nindent 4}}
spec:
{{- if .Values.ingress.tls }}
tls:
- hosts:
{{- range .Values.ingress.tls.hosts }}
- "{{ .host }}"
{{- end }}
secretName: {{ .Values.ingress.tls.secretName }}
{{- end }}
rules:
-
{{- if .Values.ingress.host }}
host: {{ .Values.ingress.host }}
{{- end }}
http:
paths:
- backend:
service:
name: {{ .Values.name }}-eventsource-svc
port:
number: {{ .Values.eventsource.config.servicePort }}
path: {{ .Values.ingress.path }}
pathType: ImplementationSpecific
{{- end -}}
82 changes: 82 additions & 0 deletions argo-event/templates/sensor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: {{ .Values.name }}
labels:
{{- with .Values.labels }}
{{ toYaml . | nindent 4 }}
{{- end }}
app: {{ .Values.name }}-sensor
spec:
eventBusName: {{ .Values.name }}
replicas: {{ .Values.eventsensor.config.replicas | max 1 }}

template:
metadata:
labels:
{{- with .Values.labels }}
{{ toYaml . | nindent 8 }}
{{- end }}
app: {{ .Values.name }}-sensor
affinity:
{{- with .Values.eventsensor.config.affinity.nodeAffinity }}
nodeAffinity: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.eventsensor.config.affinity.podAffinity }}
podAffinity: {{- toYaml . | nindent 8 }}
{{- end }}
podAntiAffinity:
{{- with .Values.eventsensor.config.affinity.podAntiAffinity }}
{{- if hasKey . "requiredDuringSchedulingIgnoredDuringExecution" }}
requiredDuringSchedulingIgnoredDuringExecution: {{- toYaml .requiredDuringSchedulingIgnoredDuringExecution | nindent 10 }}
{{- end }}
{{- end }}
preferredDuringSchedulingIgnoredDuringExecution:
{{- with .Values.eventsensor.config.affinity.podAntiAffinity }}
{{- if hasKey . "preferredDuringSchedulingIgnoredDuringExecution" }}
{{- toYaml .preferredDuringSchedulingIgnoredDuringExecution | nindent 10 }}
{{- end }}
{{- end }}
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Values.name }}-sensor
topologyKey: topology.kubernetes.io/zone
weight: 100
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Values.name }}-sensor
topologyKey: kubernetes.io/hostname
weight: 99

dependencies:
{{- range $element := .Values.eventsensor.dependencies }}
- name: {{ $element.dependencyName }}
eventSourceName: {{ $.Values.name }}
eventName: {{ $element.eventName }}
{{- if $element.filter }}
filter:
{{ toYaml $element.filter }}
{{- end }}
{{- end }}

triggers:
{{- range $element := .Values.eventsensor.triggers }}
- template:
name: {{ $element.name }}
{{- if eq $element.type "http" }}
{{- template "trigger.http" $element }}
{{- end }}
{{- with .retryStrategy -}}
retryStrategy:
steps: {{- .retryStrategy.steps | default 1 -}}
duration: {{- .retryStrategy.duration | default "1s" -}}
{{- end -}}
{{- end }}
Loading

0 comments on commit 158806a

Please sign in to comment.