Skip to content

Commit

Permalink
Merge pull request #14459 from sshaaf/funqy-knatve-events-update
Browse files Browse the repository at this point in the history
Funqy knative events update
  • Loading branch information
gsmet authored Feb 23, 2021
2 parents e00b616 + b5b3fb9 commit 8f5fede
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions docs/src/main/asciidoc/funqy-knative-events.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,20 @@ Again, make sure to replace `yourAccountName` with your docker or quay account n

== Deploy to Kubernetes/OpenShift

The first step is to define a Kubernetes/OpenShift service to points to your the docker image you created and pushed
during build. Take a look at {quickstarts-tree-url}/funqy-quickstarts/funqy-knative-events-quickstart/src/main/k8s/funqy-service.yaml[funqy-service.yaml]
The first step is to set up the broker in our namespace.
Following is an example command from the the Knative cli.

[source, yaml]
----
kn broker create default \
--namespace knativetutorial
----

The broker we have created is called `default`, this broker will receive the cloud events.
The broker is also referenced in the function YAML files.

The second step is to define a Kubernetes/OpenShift service to point to the Docker image you created and pushed
during build. Take a look at {quickstarts-tree-url}/funqy-quickstarts/funqy-knative-events-quickstart/src/main/k8s/funqy-service.yaml[funqy-service.yaml]

[source, yaml]
----
Expand All @@ -253,22 +265,22 @@ spec:
- image: docker.io/yourAccountName/funqy-knative-events-quickstart
----

This is a standard Kubernetes service definition yaml file.
This is a standard Kubernetes service definition YAML file.

NOTE: Make sure you change the image url to point to the image you built and pushed earlier!
NOTE: Make sure you change the image URL to point to the image you built and pushed earlier!

For our quickstart, one Kubernetes service will contain all functions. There's no reason you couldn't break up this
For our quickstart, one Kubernetes service will contain all functions. There's no reason you couldn't break up this
quickstart into multiple different projects and deploy a service for each function. For simplicity, and to show that you
don't have to have a deployment per function, the quickstart combines everything into one project, image, and service.

Deploy the service yaml.
Deploy the service:

[source,bash]
----
kubectl apply -n knativetutorial -f src/main/k8s/funqy-service.yaml
----

The next step is to deploy Knative Event triggers for each of the event types. As noted in the code section, each
The next step is to deploy Knative Event triggers for each of the event types. As noted in the code section, each
Funqy function is mapped to a specific Cloud Event type. You must create Knative Event triggers that map a Cloud Event
and route it to a specific Kubernetes service. We have 4 different triggers.

Expand All @@ -281,6 +293,7 @@ kind: Trigger
metadata:
name: defaultchain
spec:
broker: default
filter:
attributes:
type: defaultChain
Expand All @@ -294,13 +307,13 @@ spec:
The `spec:filter:attributes:type` maps a Cloud Event type to the Kubernetes service defined in `spec:subscriber:ref`.
When a Cloud Event is pushed to the Broker, it will trigger the spin up of the service mapped to that event.

There's a trigger yaml file for each of our 4 Funqy functions. Deploy them all:
There's a trigger YAML file for each of our 4 Funqy functions. Deploy them all:

[source,bash]
----
kubectl apply -n knativetutorial -f src/main/k8s/defaultChain-trigger.yaml
kubectl apply -n knativetutorial -f src/main/k8s/configChain-trigger.yaml
kubectl apply -n knativetutorial -f src/main/k8s/annoatedChain-trigger.yaml
kubectl apply -n knativetutorial -f src/main/k8s/annotatedChain-trigger.yaml
kubectl apply -n knativetutorial -f src/main/k8s/lastChainLink-trigger.yaml
----

Expand All @@ -324,17 +337,25 @@ Open a separate terminal. You'll first need to learn the URL of the broker. Ex
kubectl get broker default -o jsonpath='{.status.address.url}'
----

This will provide you a url like this (exactly like this if you followed the knative tutorial): `http://default-broker.knativetutorial.svc.cluster.local`
Remember this URL.
This will provide you a URL similar to e.g.: `http://broker-ingress.knative-eventing.svc.cluster.local/knativetutorial/default`. Remember this URL.

Next thing we need to do is ssh into our Kubernetes cluster so that we can send a curl request to our broker.
Following command will create a simple OS pod so we can curl into our functions.

[source,bash]
----
kubectl -n knativetutorial apply -f src/main/k8s/curler.yaml
----

You might need to wait a couple of seconds until the curler pod comes up. Run the following to get bash access to the curler pod:

[source,bash]
----
kubectl -n knativetutorial exec -it curler -- /bin/bash
----

You will now be in a shell within the Kubernetes cluster. Within the shell, execute this curl command

You will now be in a shell within the Kubernetes cluster. Within the shell, execute this curl command , the broker address is an example and might differ based on your project or broker name.

[source,bash]
----
Expand Down

0 comments on commit 8f5fede

Please sign in to comment.