Skip to content

Commit 81fe190

Browse files
committed
Add helm charts and templates for deploying events
Added eventbus and event source deployments Updated README Add docs for triggering workflows with webhook sensor
1 parent c78b9c3 commit 81fe190

File tree

12 files changed

+390
-2
lines changed

12 files changed

+390
-2
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,29 @@ Secondly, deploy the workflows service in the virtual cluster:
1616
vcluster connect workflows-cluster -- helm install workflows charts/workflows -n workflows --create-namespace
1717
```
1818

19+
Finally, deploy the events service in the virtual cluster:
20+
```sh
21+
vcluster connect workflows-cluster -- helm install workflows charts/events -n events --create-namespace
22+
```
23+
1924
## Deployment in developer mode
2025

2126
First, deploy the workflows virtual cluster using the developer manifest:
2227
```sh
2328
helm install workflows-cluster charts/workflows-cluster -f charts/workflows-cluster/dev-values.yaml
2429
```
2530

26-
Secondly, deploy the workflows service in the virtual cluster using the developer manifest :
31+
Secondly, deploy the workflows service in the virtual cluster using the developer manifest:
2732
```sh
2833
vcluster connect workflows-cluster -- helm install workflows charts/workflows -n workflows -f charts/workflows/dev-values.yaml --create-namespace
2934
```
3035
Note that for getting the workflows-server to run inside the dev environment it is necessary to extract the argo-server-sso secret, delete the deployed sealed secret and then deploy a new sealed secret using ```kubectl create -f <SEALED-SECRET>``` inside the virtual cluster.
3136

37+
Finally, deploy the events service in the virtual cluster using the developer manifest:
38+
```sh
39+
vcluster connect workflows-cluster -- helm install workflows charts/events -n events -f charts/events/dev-values.yaml --create-namespace
40+
```
41+
3242
## Serve Docs
3343

3444
Firstly, install `mkdocs` and the requisite dependencies in `docs/requirements.txt`; For this you may wish to use `pipx`, as:
@@ -40,4 +50,4 @@ pipx runpip mkdocs install -r docs/requirements.txt
4050
Now, serve the docs with `mkdocs`:
4151
```sh
4252
mkdocs serve
43-
```
53+
```

charts/events/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
charts/*.tgz

charts/events/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: argo-events
3+
repository: https://argoproj.github.io/argo-helm
4+
version: 2.4.4
5+
digest: sha256:43642b1972ced846b5c5b19e30969d7ddebfed5a4d53adf2102b9bd5c3e67c9e
6+
generated: "2024-05-16T16:12:45.406029942+01:00"

charts/events/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v2
2+
name: events
3+
description: Data Analysis event triggering
4+
type: application
5+
6+
version: 0.1.0
7+
8+
dependencies:
9+
- name: argo-events
10+
repository: https://argoproj.github.io/argo-helm
11+
version: 2.4.4
12+
condition: argo-events.enabled

charts/events/dev-values.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
argo-events:
2+
controller:
3+
resources:
4+
limits:
5+
cpu: 500m
6+
memory: 512Mi
7+
requests:
8+
cpu: 250m
9+
memory: 256Mi
10+
11+
eventBuses:
12+
- name: default
13+
namespace: events
14+
resources:
15+
requests:
16+
cpu: 10m
17+
memory: 50Mi
18+
limits:
19+
cpu: 100m
20+
memory: 100Mi
21+
metricsresources:
22+
requests:
23+
cpu: 10m
24+
memory: 50Mi
25+
limits:
26+
cpu: 100m
27+
memory: 100Mi

charts/events/templates/_helpers.tpl

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Expand the name of the chart.
5+
*/}}
6+
{{- define "argo-events.name" -}}
7+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
8+
{{- end }}
9+
10+
{{/*
11+
Create a default fully qualified app name.
12+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
13+
If release name contains chart name it will be used as a full name.
14+
*/}}
15+
{{- define "argo-events.fullname" -}}
16+
{{- if .Values.fullnameOverride }}
17+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- $name := default .Chart.Name .Values.nameOverride }}
20+
{{- if contains $name .Release.Name }}
21+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
22+
{{- else }}
23+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
24+
{{- end }}
25+
{{- end }}
26+
{{- end }}
27+
28+
{{/*
29+
Create controller name and version as used by the chart label.
30+
*/}}
31+
{{- define "argo-events.controller.fullname" -}}
32+
{{- printf "%s-%s" (include "argo-events.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}}
33+
{{- end -}}
34+
35+
{{/*
36+
Create the name of the controller service account to use
37+
*/}}
38+
{{- define "argo-events.controller.serviceAccountName" -}}
39+
{{- if .Values.controller.serviceAccount.create -}}
40+
{{ default (include "argo-events.controller.fullname" .) .Values.controller.serviceAccount.name }}
41+
{{- else -}}
42+
{{ default "default" .Values.controller.serviceAccount.name }}
43+
{{- end -}}
44+
{{- end -}}
45+
46+
{{/*
47+
Create webhook name and version as used by the chart label.
48+
*/}}
49+
{{- define "argo-events.webhook.fullname" }}
50+
{{- printf "%s-%s" (include "argo-events.fullname" .) .Values.webhook.name | trunc 63 | trimSuffix "-" -}}
51+
{{- end -}}
52+
53+
{{/*
54+
Create the name of the webhook service account to use
55+
*/}}
56+
{{- define "argo-events.webhook.serviceAccountName" -}}
57+
{{- if .Values.webhook.serviceAccount.create -}}
58+
{{ default (include "argo-events.webhook.fullname" .) .Values.webhook.serviceAccount.name }}
59+
{{- else -}}
60+
{{ default "default" .Values.webhook.serviceAccount.name }}
61+
{{- end -}}
62+
{{- end -}}
63+
64+
{{/*
65+
Create chart name and version as used by the chart label.
66+
*/}}
67+
{{- define "argo-events.chart" -}}
68+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
69+
{{- end -}}
70+
71+
{{/*
72+
Create kubernetes friendly chart version label for the controller.
73+
74+
Examples:
75+
image.tag = v1.7.3
76+
output = v1.7.3
77+
78+
image.tag = v1.7.3@sha256:a40f4f3ea20d354f00ab469a9f73102668fa545c4d632e1a8e11a206ad3093f3
79+
output = v1.7.3
80+
*/}}
81+
{{- define "argo-events.controller_chart_version_label" -}}
82+
{{- regexReplaceAll "[^a-zA-Z0-9-_.]+" (regexReplaceAll "@sha256:[a-f0-9]+" (default (include "argo-events.defaultTag" .) .Values.controller.image.tag) "") "" | trunc 63 | quote -}}
83+
{{- end -}}
84+
85+
{{/*
86+
Create kubernetes friendly chart version label for the events webhook.
87+
88+
Examples:
89+
image.tag = v1.7.3
90+
output = v1.7.3
91+
92+
image.tag = v1.7.3@sha256:a40f4f3ea20d354f00ab469a9f73102668fa545c4d632e1a8e11a206ad3093f3
93+
output = v1.7.3
94+
*/}}
95+
{{- define "argo-events.webhook_chart_version_label" -}}
96+
{{- regexReplaceAll "[^a-zA-Z0-9-_.]+" (regexReplaceAll "@sha256:[a-f0-9]+" (default (include "argo-events.defaultTag" .) .Values.webhook.image.tag) "") "" | trunc 63 | quote -}}
97+
{{- end -}}
98+
99+
{{/*
100+
Common labels
101+
*/}}
102+
{{- define "argo-events.labels" -}}
103+
helm.sh/chart: {{ include "argo-events.chart" .context }}
104+
{{ include "argo-events.selectorLabels" (dict "context" .context "component" .component "name" .name) }}
105+
app.kubernetes.io/managed-by: {{ .context.Release.Service }}
106+
app.kubernetes.io/part-of: argo-events
107+
{{- end }}
108+
109+
{{/*
110+
Selector labels
111+
*/}}
112+
{{- define "argo-events.selectorLabels" -}}
113+
{{- if .name -}}
114+
app.kubernetes.io/name: {{ include "argo-events.name" .context }}-{{ .name }}
115+
{{- end }}
116+
app.kubernetes.io/instance: {{ .context.Release.Name }}
117+
{{- if .component }}
118+
app.kubernetes.io/component: {{ .component }}
119+
{{- end }}
120+
{{- end }}
121+
122+
{{/*
123+
Return the default Argo Events app version
124+
*/}}
125+
{{- define "argo-events.defaultTag" -}}
126+
{{- default .Chart.AppVersion .Values.global.image.tag }}
127+
{{- end -}}
128+
129+
{{/*
130+
Define Pdb apiVersion
131+
*/}}
132+
{{- define "argo-events.pdb.apiVersion" -}}
133+
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
134+
{{- printf "policy/v1" -}}
135+
{{- else }}
136+
{{- printf "policy/v1beta1" -}}
137+
{{- end }}
138+
{{- end }}
139+
140+
{{/*
141+
Expand the namespace of the release.
142+
Allows overriding it for multi-namespace deployments in combined charts.
143+
*/}}
144+
{{- define "argo-events.namespace" -}}
145+
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
146+
{{- end }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml
2+
{{- if index .Values "argo-events" "enabled" }}
3+
{{- range $eventBus := $.Values.eventBuses }}
4+
---
5+
apiVersion: argoproj.io/v1alpha1
6+
kind: EventBus
7+
metadata:
8+
namespace: {{ $eventBus.namespace }}
9+
name: {{ $eventBus.name }}
10+
spec:
11+
nats:
12+
native:
13+
# Optional, defaults to 3. If it is < 3, set it to 3, that is the minimal requirement.
14+
replicas: 3
15+
# Optional, auth strategy, "none" or "token", defaults to "none"
16+
auth: token
17+
{{- if $eventBus.resources }}
18+
containerTemplate:
19+
resources:
20+
{{- $eventBus.resources | toYaml | nindent 10 }}
21+
{{- end }}
22+
{{- if $eventBus.metricsresources }}
23+
metricsContainerTemplate:
24+
resources:
25+
{{- $eventBus.metricsresources | toYaml | nindent 10 }}
26+
{{- end }}
27+
{{- end }}
28+
{{- end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if index .Values "argo-events" "enabled" }}
2+
{{- range $eventSource := $.Values.eventSources }}
3+
{{- if eq $eventSource.name "webhook" }}
4+
---
5+
apiVersion: argoproj.io/v1alpha1
6+
kind: EventSource
7+
metadata:
8+
name: webhook
9+
spec:
10+
service:
11+
ports:
12+
- port: {{$eventSource.port }}
13+
targetPort: {{$eventSource.port }}
14+
webhook:
15+
# event-source can run multiple HTTP servers. Simply define a unique port to start a new HTTP server
16+
example:
17+
# port to run HTTP server on
18+
port: "{{$eventSource.port }}"
19+
# endpoint to listen to
20+
endpoint: /{{ $eventSource.endpoint }}
21+
# HTTP request method to allow. In this case, only POST requests are accepted
22+
method: POST
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: operate-workflow-sa
5+
---
6+
# Similarly you can use a ClusterRole and ClusterRoleBinding
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
kind: Role
9+
metadata:
10+
name: operate-workflow-role
11+
rules:
12+
- apiGroups:
13+
- argoproj.io
14+
verbs:
15+
- "*"
16+
resources:
17+
- workflows
18+
- workflowtemplates
19+
- cronworkflows
20+
- clusterworkflowtemplates
21+
---
22+
apiVersion: rbac.authorization.k8s.io/v1
23+
kind: RoleBinding
24+
metadata:
25+
name: operate-workflow-role-binding
26+
roleRef:
27+
apiGroup: rbac.authorization.k8s.io
28+
kind: Role
29+
name: operate-workflow-role
30+
subjects:
31+
- kind: ServiceAccount
32+
name: operate-workflow-sa
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This file enables a Workflow Pod (running Emissary executor) to be able to read and patch WorkflowTaskResults,
2+
# which get shared with the Workflow Controller. The Controller uses the results to update Workflow status.
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: Role
5+
metadata:
6+
annotations:
7+
workflows.argoproj.io/description: |
8+
Recomended minimum permissions for the `emissary` executor.
9+
name: executor
10+
rules:
11+
- apiGroups:
12+
- argoproj.io
13+
resources:
14+
- workflowtaskresults
15+
verbs:
16+
- create
17+
- patch
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: RoleBinding
21+
metadata:
22+
name: executor-default
23+
roleRef:
24+
apiGroup: rbac.authorization.k8s.io
25+
kind: Role
26+
name: executor
27+
subjects:
28+
- kind: ServiceAccount
29+
name: argo-workflow
30+
---
31+
apiVersion: v1
32+
kind: ServiceAccount
33+
metadata:
34+
name: argo-workflow
35+
namespace: events

charts/events/values.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
argo-events:
2+
enabled: true
3+
controller:
4+
replicas: 1
5+
pdb:
6+
minAvailable: 1
7+
serviceAccount:
8+
name: argo-events-sa
9+
volumeMounts:
10+
- name: controller-config-volume
11+
mountPath: /etc/argo-events
12+
volumes:
13+
- name: controller-config-volume
14+
configMap:
15+
name: argo-events-controller-config
16+
webhook:
17+
enabled: true
18+
serviceAccount:
19+
name: argo-events-webhook-sa
20+
21+
eventBuses:
22+
- name: default
23+
namespace: events
24+
25+
eventSources:
26+
- name: webhook
27+
port: 12000
28+
endpoint: example

0 commit comments

Comments
 (0)