bind minio events to argo workflows
diff --git a/argo/argo-events-crds-install.yaml b/argo/argo-events-crds-install.yaml
new file mode 100644
index 0000000..c746479
--- /dev/null
+++ b/argo/argo-events-crds-install.yaml
@@ -0,0 +1,221 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+ name: gateways.argoproj.io
+spec:
+ group: argoproj.io
+ names:
+ kind: Gateway
+ listKind: GatewayList
+ plural: gateways
+ singular: gateway
+ shortNames:
+ - gw
+ scope: Namespaced
+ version: "v1alpha1"
+---
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+ name: sensors.argoproj.io
+spec:
+ group: argoproj.io
+ names:
+ kind: Sensor
+ listKind: SensorList
+ plural: sensors
+ singular: sensor
+ shortNames:
+ - sn
+ scope: Namespaced
+ version: "v1alpha1"
+---
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+ name: eventsources.argoproj.io
+spec:
+ group: argoproj.io
+ scope: Namespaced
+ names:
+ kind: EventSource
+ plural: eventsources
+ singular: eventsource
+ listKind: EventSourceList
+ shortNames:
+ - es
+ version: "v1alpha1"
+---
+# apiVersion: v1
+# kind: Namespace
+# metadata:
+# name: argo-events
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: argo-events-sa
+ namespace: kube-system
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+ name: argo-events-role-binding
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: argo-events-role
+subjects:
+ - kind: ServiceAccount
+ name: argo-events-sa
+ namespace: kube-system
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: Role
+metadata:
+ name: argo-events-role
+rules:
+ - apiGroups:
+ - argoproj.io
+ verbs:
+ - create
+ - delete
+ - deletecollection
+ - get
+ - list
+ - patch
+ - update
+ - watch
+ resources:
+ - workflows
+ - workflows/finalizers
+ - workflowtemplates
+ - workflowtemplates/finalizers
+ - gateways
+ - gateways/finalizers
+ - sensors
+ - sensors/finalizers
+ - eventsources
+ - eventsources/finalizers
+ - apiGroups:
+ - ""
+ resources:
+ - pods
+ - pods/exec
+ - configmaps
+ - secrets
+ - services
+ - events
+ - persistentvolumeclaims
+ verbs:
+ - create
+ - get
+ - list
+ - watch
+ - update
+ - patch
+ - delete
+ - apiGroups:
+ - "batch"
+ resources:
+ - jobs
+ verbs:
+ - create
+ - get
+ - list
+ - watch
+ - update
+ - patch
+ - delete
+ - apiGroups:
+ - "apps"
+ resources:
+ - deployments
+ verbs:
+ - create
+ - get
+ - list
+ - watch
+ - update
+ - patch
+ - delete
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: gateway-controller-configmap
+ namespace: kube-system
+data:
+ config: |
+ instanceID: argo-events
+ namespace: kube-system
+---
+# The gateway-controller listens for changes on the gateway CRD and creates gateway
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: gateway-controller
+ namespace: kube-system
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: gateway-controller
+ template:
+ metadata:
+ labels:
+ app: gateway-controller
+ spec:
+ serviceAccountName: argo-events-sa
+ containers:
+ - name: gateway-controller
+ image: argoproj/gateway-controller:v0.13.0
+ imagePullPolicy: Always
+ env:
+ - name: NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ - name: CONTROLLER_CONFIG_MAP
+ value: gateway-controller-configmap
+---
+# The sensor-controller configmap includes configuration information for the sensor-controller
+# To watch sensors created in different namespace than the controller is deployed in, remove the namespace: kube-system.
+# Similarly to watch sensors created in specific namespace, change to namespace: <your_namespace>
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: sensor-controller-configmap
+ namespace: kube-system
+data:
+ config: |
+ instanceID: argo-events
+ namespace: kube-system
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: sensor-controller
+ namespace: kube-system
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: sensor-controller
+ template:
+ metadata:
+ labels:
+ app: sensor-controller
+ spec:
+ serviceAccountName: argo-events-sa
+ containers:
+ - name: sensor-controller
+ image: argoproj/sensor-controller:v0.13.0
+ imagePullPolicy: Always
+ env:
+ - name: NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ - name: CONTROLLER_CONFIG_MAP
+ value: sensor-controller-configmap
diff --git a/argo/event-source.yaml b/argo/event-source.yaml
new file mode 100644
index 0000000..11610a0
--- /dev/null
+++ b/argo/event-source.yaml
@@ -0,0 +1,21 @@
+apiVersion: argoproj.io/v1alpha1
+kind: EventSource
+metadata:
+ name: minio-event-source
+spec:
+ type: "minio"
+ minio:
+ example:
+ bucket:
+ name: input
+ endpoint: mio-minio.default.svc:9000
+ events:
+ - s3:ObjectCreated:Put
+ - s3:ObjectRemoved:Delete
+ insecure: true
+ accessKey:
+ key: accesskey
+ name: artifacts-minio
+ secretKey:
+ key: secretkey
+ name: artifacts-minio
\ No newline at end of file
diff --git a/argo/gateway.yaml b/argo/gateway.yaml
new file mode 100644
index 0000000..e56f926
--- /dev/null
+++ b/argo/gateway.yaml
@@ -0,0 +1,29 @@
+apiVersion: argoproj.io/v1alpha1
+kind: Gateway
+metadata:
+ name: minio-gateway
+ labels:
+ # gateway controller with instanceId "argo-events" will process this gateway
+ gateways.argoproj.io/gateway-controller-instanceid: argo-events
+spec:
+ type: minio
+ eventSourceRef:
+ name: minio-event-source
+ template:
+ metadata:
+ name: minio-gateway
+ labels:
+ gateway-name: minio-gateway
+ spec:
+ containers:
+ - name: gateway-client
+ image: argoproj/gateway-client:v0.13.0
+ imagePullPolicy: Always
+ command: ["/bin/gateway-client"]
+ - name: minio-events
+ image: argoproj/artifact-gateway:v0.13.0
+ imagePullPolicy: Always
+ serviceAccountName: argo-events-sa
+ subscribers:
+ http:
+ - "http://minio-sensor.kube-system.svc:9300/"
diff --git a/argo/mio-minio-secrets.yaml b/argo/mio-minio-secrets.yaml
new file mode 100644
index 0000000..cdd09f3
--- /dev/null
+++ b/argo/mio-minio-secrets.yaml
@@ -0,0 +1,9 @@
+apiVersion: v1
+kind: Secret
+metadata:
+ name: artifacts-minio
+data:
+ # base64 of minio
+ accesskey: Z2lv
+ # base64 of minio123
+ secretkey: cDEyMzQ1Njc4
diff --git a/argo/sensor.yaml b/argo/sensor.yaml
new file mode 100644
index 0000000..8c0427c
--- /dev/null
+++ b/argo/sensor.yaml
@@ -0,0 +1,52 @@
+apiVersion: argoproj.io/v1alpha1
+kind: Sensor
+metadata:
+ name: minio-sensor
+ labels:
+ # sensor controller with instanceId "argo-events" will process this sensor
+ sensors.argoproj.io/sensor-controller-instanceid: argo-events
+spec:
+ template:
+ spec:
+ containers:
+ - name: sensor
+ image: argoproj/sensor:v0.13.0
+ imagePullPolicy: Always
+ serviceAccountName: argo-events-sa
+ subscription:
+ http:
+ port: 9300
+ dependencies:
+ - name: test-dep
+ gatewayName: minio-gateway
+ eventName: example
+ triggers:
+ - template:
+ name: minio-workflow-trigger
+ k8s:
+ group: argoproj.io
+ version: v1alpha1
+ resource: workflows
+ operation: create
+ source:
+ resource:
+ apiVersion: argoproj.io/v1alpha1
+ kind: Workflow
+ metadata:
+ generateName: artifact-workflow-2-
+ spec:
+ entrypoint: whalesay
+ templates:
+ - name: whalesay
+ container:
+ command:
+ - cowsay
+ image: docker/whalesay:latest
+ args:
+ - THIS_WILL_BE_REPLACED
+ # The container args from the workflow are overridden by the s3 notification key
+ parameters:
+ - src:
+ dependencyName: test-dep
+ dataKey: notification.0.s3.object.key
+ dest: spec.templates.0.container.args.0
diff --git a/argo/setup.sh b/argo/setup.sh
new file mode 100644
index 0000000..72a2339
--- /dev/null
+++ b/argo/setup.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+export MINIO_ACCESSKEY="gio"
+export MINIO_SECRETKEY="p12345678"
+export MINIO_HOST="http://localhost:9000"
+
+# -- kubectl apply -n kube-system -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
+
+# helm install mio --set accessKey=${MINIO_ACCESSKEY},secretKey=${MINIO_SECRETKEY} stable/minio
+read -s
+kubectl port-forward svc/mio-minio 9000 &
+read -s
+mc config host add mio-minio ${MINIO_HOST} ${MINIO_ACCESSKEY} ${MINIO_SECRETKEY}
+mc mb mio-minio/input
+
+
+kubectl apply -n kube-system -f mio-minio-secrets.yaml
+
+
+
+helm repo add argo https://argoproj.github.io/argo-helm
+helm install my-argo --namespace kube-system argo/argo
+read -s
+kubectl -n kube-system port-forward deployment/my-argo-server 2746 &
+read -s
+
+kubectl apply -n kube-system -f argo-events-crds-install.yaml
+
+
+kubectl apply -n kube-system -f event-source.yaml
+kubectl apply -n kube-system -f gateway.yaml
+kubectl apply -n kube-system -f sensor.yaml