Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active February 10, 2024 20:05
Show Gist options
  • Select an option

  • Save vfarcic/a0a7ff04a7e22409cdfd8b466edb4e48 to your computer and use it in GitHub Desktop.

Select an option

Save vfarcic/a0a7ff04a7e22409cdfd8b466edb4e48 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/a0a7ff04a7e22409cdfd8b466edb4e48
#################################################
# Argo Events #
# Event-Based Dependency Manager for Kubernetes #
# https://youtu.be/sUPkGChvD54 #
#################################################
#########
# Setup #
#########
# It could be any Kubernetes cluster
minikube start
kubectl create namespace argo-events
kubectl apply \
--filename https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install.yaml
kubectl --namespace argo-events apply \
--filename https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml
git clone https://github.com/vfarcic/argo-events-demo.git
cd argo-events-demo
##########################
# Creating event sources #
##########################
cat event-source.yaml
kubectl --namespace argo-events apply \
--filename event-source.yaml
kubectl --namespace argo-events \
get eventsources
kubectl --namespace argo-events \
get services
kubectl --namespace argo-events \
get pods
# Replace `[...]` with the name of the `webhook-eventsource-*` Pod
export EVENTSOURCE_POD_NAME=$(\
kubectl --namespace argo-events \
get pods \
--output name \
--selector eventsource-name=webhook)
kubectl --namespace argo-events \
port-forward $EVENTSOURCE_POD_NAME 12000:12000 &
curl -X POST \
-H "Content-Type: application/json" \
-d '{"message":"My first webhook"}' \
http://localhost:12000/devops-toolkit
# Open https://github.com/argoproj/argo-events/blob/master/api/event-source.md#eventsourcespec
#################################
# Creating sensors and triggers #
#################################
cat sensor.yaml
kubectl --namespace argo-events apply \
--filename sensor.yaml
curl -X POST \
-H "Content-Type: application/json" \
-d '{"message":"My first webhook"}' \
http://localhost:12000/devops-toolkit
kubectl --namespace argo-events get pods
kubectl --namespace argo-events logs \
--selector app=payload
kubectl --namespace argo-events \
delete pods \
--selector app=payload
# Open https://github.com/argoproj/argo-events/blob/master/api/sensor.md#sensor
###########
# Destroy #
###########
pkill kubectl
minikube delete
@gophry

gophry commented May 31, 2021

Copy link
Copy Markdown

Thanks for tutorials. this had step by step clarity.
line 47 49 can be replaced by.
kubectl -n argo-events port-forward $(kubectl -n argo-events get pod -o NAME | grep webhook) 12000:12000

@vfarcic

vfarcic commented May 31, 2021

Copy link
Copy Markdown
Author

Thanks. I'll update the Gist with it soon...

@christianh814

Copy link
Copy Markdown

Without grep...

kubectl -n argo-events port-forward $(kubectl get pods -o name -l eventsource-name=webhook -n argo-events)  12000:12000

@vfarcic

vfarcic commented Feb 19, 2022

Copy link
Copy Markdown
Author

You're right. Gist updated... 😄

@vaporpin

vaporpin commented Jun 2, 2022

Copy link
Copy Markdown

@vfarcic, tried to reply on your argo-events youtube video in the comment section, but somehow not able to. My comment kept getting deleted.

Hope you do not mind me commenting here. Attached is the gist on deploying sensor and eventsource in another namespace, which I cannot get it to work.

I added these commands, on top of your gist, to deploy in another namespace. https://gist.github.com/vaporpin/a80877ded979d9c92ee44515a74884b7

@vfarcic

vfarcic commented Jun 2, 2022

Copy link
Copy Markdown
Author

Sorry for the comments. YT tends to delete those that contain links.

I'm traveling right now and will not be back until the weekend. I hope that I'll be able to go through it sometime next week. Is that OK?

@vaporpin

vaporpin commented Jun 3, 2022

Copy link
Copy Markdown

@vfarcic, definitely ok! in fact, thanks for helping out! enjoy your holiday!

@vfarcic

vfarcic commented May 16, 2023

Copy link
Copy Markdown
Author

I already answered in YouTube. We can continue here @sarsatis .

@Pzharyuk

Pzharyuk commented Feb 9, 2024

Copy link
Copy Markdown

I'm trying to expose the webhook externally, however it doesn't seem to work for me.

apiVersion: v1 kind: Service metadata: name: webhook-eventsource namespace: argo-events spec: ports: - name: tcp port: 12000 protocol: TCP targetPort: 12000 selector: eventsource-name: webhook type: NodePort

Do you have any examples of how to implement it with ingress?

@vfarcic

vfarcic commented Feb 10, 2024

Copy link
Copy Markdown
Author

@Pzharyuk If you're exposing it through ingress, you just have to add Ingress resource that points to the Service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment