Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event controllers #8

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
chart:
- workflows
- workflows-cluster
- events
steps:
- name: Checkout Source
uses: actions/checkout@v4.1.1
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,29 @@ Secondly, deploy the workflows service in the virtual cluster:
vcluster connect workflows-cluster -- helm install workflows charts/workflows -n workflows --create-namespace
```

Finally, deploy the events service in the virtual cluster:
```sh
vcluster connect workflows-cluster -- helm install workflows charts/events -n events --create-namespace
```

## Deployment in developer mode

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

Secondly, deploy the workflows service in the virtual cluster using the developer manifest :
Secondly, deploy the workflows service in the virtual cluster using the developer manifest:
```sh
vcluster connect workflows-cluster -- helm install workflows charts/workflows -n workflows -f charts/workflows/dev-values.yaml --create-namespace
```
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.

Finally, deploy the events service in the virtual cluster using the developer manifest:
```sh
vcluster connect workflows-cluster -- helm install workflows charts/events -n events -f charts/events/dev-values.yaml --create-namespace
```

## Serve Docs

Firstly, install `mkdocs` and the requisite dependencies in `docs/requirements.txt`; For this you may wish to use `pipx`, as:
Expand Down
1 change: 1 addition & 0 deletions charts/events/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/*.tgz
6 changes: 6 additions & 0 deletions charts/events/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: argo-events
repository: https://argoproj.github.io/argo-helm
version: 2.4.4
digest: sha256:771d2ad27dd8a4521e5f8a5a4ad78d09785413efd7414ace4fbfe98e9ed677df
generated: "2024-05-23T17:05:28.447115602+01:00"
13 changes: 13 additions & 0 deletions charts/events/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: events
description: Data Analysis event triggering
type: application

version: 0.1.0

dependencies:
- name: argo-events
alias: argoevents
repository: https://argoproj.github.io/argo-helm
version: 2.4.4
condition: argo-events.enabled
27 changes: 27 additions & 0 deletions charts/events/dev-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
argo-events:
controller:
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi

eventBuses:
- name: default
namespace: events
resources:
requests:
cpu: 10m
memory: 50Mi
limits:
cpu: 100m
memory: 100Mi
metricsresources:
requests:
cpu: 10m
memory: 50Mi
limits:
cpu: 100m
memory: 100Mi
146 changes: 146 additions & 0 deletions charts/events/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Expand the name of the chart.
*/}}
{{- define "argo-events.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "argo-events.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create controller name and version as used by the chart label.
*/}}
{{- define "argo-events.controller.fullname" -}}
{{- printf "%s-%s" (include "argo-events.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the controller service account to use
*/}}
{{- define "argo-events.controller.serviceAccountName" -}}
{{- if .Values.controller.serviceAccount.create -}}
{{ default (include "argo-events.controller.fullname" .) .Values.controller.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.controller.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Create webhook name and version as used by the chart label.
*/}}
{{- define "argo-events.webhook.fullname" }}
{{- printf "%s-%s" (include "argo-events.fullname" .) .Values.webhook.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the webhook service account to use
*/}}
{{- define "argo-events.webhook.serviceAccountName" -}}
{{- if .Values.webhook.serviceAccount.create -}}
{{ default (include "argo-events.webhook.fullname" .) .Values.webhook.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.webhook.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "argo-events.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create kubernetes friendly chart version label for the controller.
Examples:
image.tag = v1.7.3
output = v1.7.3
image.tag = v1.7.3@sha256:a40f4f3ea20d354f00ab469a9f73102668fa545c4d632e1a8e11a206ad3093f3
output = v1.7.3
*/}}
{{- define "argo-events.controller_chart_version_label" -}}
{{- regexReplaceAll "[^a-zA-Z0-9-_.]+" (regexReplaceAll "@sha256:[a-f0-9]+" (default (include "argo-events.defaultTag" .) .Values.controller.image.tag) "") "" | trunc 63 | quote -}}
{{- end -}}

{{/*
Create kubernetes friendly chart version label for the events webhook.
Examples:
image.tag = v1.7.3
output = v1.7.3
image.tag = v1.7.3@sha256:a40f4f3ea20d354f00ab469a9f73102668fa545c4d632e1a8e11a206ad3093f3
output = v1.7.3
*/}}
{{- define "argo-events.webhook_chart_version_label" -}}
{{- regexReplaceAll "[^a-zA-Z0-9-_.]+" (regexReplaceAll "@sha256:[a-f0-9]+" (default (include "argo-events.defaultTag" .) .Values.webhook.image.tag) "") "" | trunc 63 | quote -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "argo-events.labels" -}}
helm.sh/chart: {{ include "argo-events.chart" .context }}
{{ include "argo-events.selectorLabels" (dict "context" .context "component" .component "name" .name) }}
app.kubernetes.io/managed-by: {{ .context.Release.Service }}
app.kubernetes.io/part-of: argo-events
{{- end }}

{{/*
Selector labels
*/}}
{{- define "argo-events.selectorLabels" -}}
{{- if .name -}}
app.kubernetes.io/name: {{ include "argo-events.name" .context }}-{{ .name }}
{{- end }}
app.kubernetes.io/instance: {{ .context.Release.Name }}
{{- if .component }}
app.kubernetes.io/component: {{ .component }}
{{- end }}
{{- end }}

{{/*
Return the default Argo Events app version
*/}}
{{- define "argo-events.defaultTag" -}}
{{- default .Chart.AppVersion .Values.global.image.tag }}
{{- end -}}

{{/*
Define Pdb apiVersion
*/}}
{{- define "argo-events.pdb.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
{{- printf "policy/v1" -}}
{{- else }}
{{- printf "policy/v1beta1" -}}
{{- end }}
{{- end }}

{{/*
Expand the namespace of the release.
Allows overriding it for multi-namespace deployments in combined charts.
*/}}
{{- define "argo-events.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end }}
28 changes: 28 additions & 0 deletions charts/events/templates/event-bus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml
{{- if .Values.argoevents.enabled }}
{{- range $eventBus := $.Values.eventBuses }}
---
apiVersion: argoproj.io/v1alpha1
kind: EventBus
metadata:
namespace: {{ $eventBus.namespace }}
name: {{ $eventBus.name }}
spec:
nats:
native:
# Optional, defaults to 3. If it is < 3, set it to 3, that is the minimal requirement.
replicas: 3
# Optional, auth strategy, "none" or "token", defaults to "none"
auth: token
{{- if $eventBus.resources }}
containerTemplate:
resources:
{{- $eventBus.resources | toYaml | nindent 10 }}
{{- end }}
{{- if $eventBus.metricsresources }}
metricsContainerTemplate:
resources:
{{- $eventBus.metricsresources | toYaml | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/events/templates/event-sources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.argoevents.enabled }}
{{- range $eventSource := $.Values.eventSources }}
---
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: {{ $eventSource.name }}
spec:
service:
ports:
- port: {{$eventSource.port }}
targetPort: {{$eventSource.port }}
{{- if $eventSource.webhook }}
webhook:
{{- $eventSource.webhook | toYaml | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/events/templates/sensor-service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: operate-workflow-sa
---
# Similarly you can use a ClusterRole and ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: operate-workflow-role
rules:
- apiGroups:
- argoproj.io
verbs:
- "*"
resources:
- workflows
- workflowtemplates
- cronworkflows
- clusterworkflowtemplates
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: operate-workflow-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: operate-workflow-role
subjects:
- kind: ServiceAccount
name: operate-workflow-sa
35 changes: 35 additions & 0 deletions charts/events/templates/workflow-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file enables a Workflow Pod (running Emissary executor) to be able to read and patch WorkflowTaskResults,
# which get shared with the Workflow Controller. The Controller uses the results to update Workflow status.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
workflows.argoproj.io/description: |
Recomended minimum permissions for the `emissary` executor.
name: executor
rules:
- apiGroups:
- argoproj.io
resources:
- workflowtaskresults
verbs:
- create
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: executor-default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: executor
subjects:
- kind: ServiceAccount
name: argo-workflow
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: argo-workflow
namespace: events
36 changes: 36 additions & 0 deletions charts/events/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
argo-events:
enabled: true
controller:
replicas: 1
garryod marked this conversation as resolved.
Show resolved Hide resolved
pdb:
minAvailable: 1
serviceAccount:
name: argo-events-sa
volumeMounts:
- name: controller-config-volume
mountPath: /etc/argo-events
volumes:
- name: controller-config-volume
configMap:
name: argo-events-controller-config
webhook:
enabled: true
serviceAccount:
name: argo-events-webhook-sa

eventBuses:
- name: default
namespace: events

eventSources:
- name: webhook
port: 12000
webhook:
# event-source can run multiple HTTP servers. Simply define a unique port to start a new HTTP server
example:
# port to run HTTP server on
port: "12000"
# endpoint to listen to
endpoint: /example
# HTTP request method to allow. In this case, only POST requests are accepted
method: POST
Loading