From de15e370f5a1b46d02ba147a84536749ce83a730 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 12 Jul 2018 11:33:37 -0700 Subject: [PATCH 1/4] Update documentation for the GCP Pubsub example. --- sample/gcp_pubsub_function/README.md | 56 +++++++++++++++------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/sample/gcp_pubsub_function/README.md b/sample/gcp_pubsub_function/README.md index 5270fbaf9c5..8e68aa22b15 100644 --- a/sample/gcp_pubsub_function/README.md +++ b/sample/gcp_pubsub_function/README.md @@ -10,8 +10,8 @@ attaches to the specified GCP topic and then forwards them to the destination. ## Prerequisites 1. [Setup your development environment](../../DEVELOPMENT.md#getting-started) -2. [Start Knative](../../README.md#start-knative) -3. Decide on the DNS name that git can then call. Update knative/serving/config-domain.yaml domainSuffix. +1. [Start Knative](../../README.md#start-knative) +1. Decide on the DNS name that git can then call. Update knative/serving/config-domain.yaml domainSuffix. For example I used aikas.org as my hostname, so my config-domain.yaml looks like so: ```yaml @@ -19,7 +19,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: config-domain - namespace: knative-serving-system + namespace: knative-serving data: aikas.org: | ``` @@ -27,19 +27,17 @@ data: If you were already running the Knative controllers, you will need to re-apply the configmap. -4. Install GCP Pub Sub as an event source +1. Install GCP Pub Sub as an event source ```shell ko apply -f pkg/sources/gcppubsub/ ``` -5. Create a GCP Pub Sub topic +1. Create a GCP Pub Sub topic ```shell gcloud pubsub topics create knative-demo ``` -5. Install the event sources and types for [gcp_pubsub](../gcp_pubsub/README.md) - ## Creating a Service Account @@ -71,31 +69,32 @@ Once deployed, you can inspect the created resources with `kubectl` commands: ```shell # This will show the Route that we created: -kubectl get route -o yaml +kubectl get route gcp-pubsub-function -o yaml # This will show the Configuration that we created: -kubectl get configurations -o yaml +kubectl get configurations gcp-pubsub-function -o yaml # This will show the Revision that was created by our configuration: -kubectl get revisions -o yaml +kubectl get revisions -l serving.knative.dev/configuration=gcp-pubsub-function -o yaml # This will show the available EventSources that you can bind to: -kubectl get eventsources -oyaml +kubectl get eventsources gcppubsub -o yaml # This will show the available EventTypes that you can bind to: -kubectl get eventtypes -oyaml +kubectl get eventtypes receive -o yaml ``` To make this service accessible to GCP, we first need to determine its ingress -address (might have to wait a little while until 'ADDRESS' gets assigned): +address (might have to wait a little while until 'EXTERNAL-IP' gets assigned): ```shell -$ watch kubectl get ingress -NAME HOSTS ADDRESS PORTS AGE -gcp-pubsub-function-ingress gcp-pubsub-function.default.aikas.org,*.gcp-pubsub-function.default.aikas.org 130.211.116.160 80 20s +kubectl get svc knative-ingressgateway -n istio-system + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +knative-ingressgateway LoadBalancer 10.23.247.74 35.203.155.229 80:32380/TCP,443:32390/TCP,32400:32400/TCP 2d ``` -Once the `ADDRESS` gets assigned to the cluster, you need to assign a DNS name +Once the `EXTERNAL-IP` gets assigned to the cluster, you need to assign a DNS name for that IP address. This DNS address needs to be: `gcp-pubsub-function.default.` so for me, I would create a DNS entry from: `gcp-pubsub-function.default.aikas.org` pointing to @@ -159,27 +158,32 @@ topic: projects/quantum-reducer-434/topics/knative-demo ``` -Then look at the logs for the function: +The subscription has been setup, but the function is not yet running, as no +event has been received. + ```shell $ kubectl get pods -NAME READY STATUS RESTARTS AGE -gcp-pubsub-function-00001-deployment-68864b8c7d-rgx2w 3/3 Running 0 12m - - -# Replace gcp-pubsub-function with the pod name from above: -$ kubectl logs gcp-pubsub-function-00001-deployment-68864b8c7d-rgx2w user-container +NAME READY STATUS RESTARTS AGE +sub-9aa6465b-28e1-4149-80d9-abf6b514f3b4-bf7bbdd4-zpckj 1/1 Running 0 12m ``` -Nothing is there, so let's change that: +Let's send an event. ```shell $ gcloud pubsub topics publish knative-demo --message 'test message' ``` -Then look at the function logs: +Then look at the logs for the function: ```shell +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +gcp-pubsub-function-00001-deployment-68864b8c7d-rgx2w 3/3 Running 0 1m +sub-9aa6465b-28e1-4149-80d9-abf6b514f3b4-bf7bbdd4-zpckj 1/1 Running 0 12m + + +# Replace gcp-pubsub-function with the pod name from above: $ kubectl logs gcp-pubsub-function-00001-deployment-68864b8c7d-rgx2w user-container 2018/05/22 19:16:59 {"ID":"99171831321660","Data":"dGVzdCBtZXNzYWdl","Attributes":null,"PublishTime":"2018-05-22T19:16:59.727Z"} 2018/05/22 19:16:59 Received data: "test message" From 7a39432a08c37833b265d2c5f7b766c3933d7633 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 12 Jul 2018 11:41:28 -0700 Subject: [PATCH 2/4] Fix list numbering. --- sample/gcp_pubsub_function/README.md | 37 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sample/gcp_pubsub_function/README.md b/sample/gcp_pubsub_function/README.md index 8e68aa22b15..e0c5dcc493e 100644 --- a/sample/gcp_pubsub_function/README.md +++ b/sample/gcp_pubsub_function/README.md @@ -14,29 +14,30 @@ attaches to the specified GCP topic and then forwards them to the destination. 1. Decide on the DNS name that git can then call. Update knative/serving/config-domain.yaml domainSuffix. For example I used aikas.org as my hostname, so my config-domain.yaml looks like so: -```yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: config-domain - namespace: knative-serving -data: - aikas.org: | -``` + ```yaml + apiVersion: v1 + kind: ConfigMap + metadata: + name: config-domain + namespace: knative-serving + data: + aikas.org: | + ``` If you were already running the Knative controllers, you will need to re-apply the configmap. 1. Install GCP Pub Sub as an event source -```shell -ko apply -f pkg/sources/gcppubsub/ -``` + + ```shell + ko apply -f pkg/sources/gcppubsub/ + ``` 1. Create a GCP Pub Sub topic -```shell -gcloud pubsub topics create knative-demo -``` + ```shell + gcloud pubsub topics create knative-demo + ``` ## Creating a Service Account @@ -78,10 +79,10 @@ kubectl get configurations gcp-pubsub-function -o yaml kubectl get revisions -l serving.knative.dev/configuration=gcp-pubsub-function -o yaml # This will show the available EventSources that you can bind to: -kubectl get eventsources gcppubsub -o yaml +kubectl get eventsources -o yaml # This will show the available EventTypes that you can bind to: -kubectl get eventtypes receive -o yaml +kubectl get eventtypes -o yaml ``` To make this service accessible to GCP, we first need to determine its ingress @@ -98,7 +99,7 @@ Once the `EXTERNAL-IP` gets assigned to the cluster, you need to assign a DNS na for that IP address. This DNS address needs to be: `gcp-pubsub-function.default.` so for me, I would create a DNS entry from: `gcp-pubsub-function.default.aikas.org` pointing to -`130.211.116.160`. See also, [Using GCP +`35.203.155.229`. See also, [Using GCP DNS](https://support.google.com/domains/answer/3290350). So, you'd need to create an A record for From 0ae22b5a6f57420b1a1fb6779dc030a49ccf1ae2 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 12 Jul 2018 11:42:39 -0700 Subject: [PATCH 3/4] Fix list numbering. --- sample/gcp_pubsub_function/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/gcp_pubsub_function/README.md b/sample/gcp_pubsub_function/README.md index e0c5dcc493e..fa0f7cd7ddb 100644 --- a/sample/gcp_pubsub_function/README.md +++ b/sample/gcp_pubsub_function/README.md @@ -24,8 +24,8 @@ For example I used aikas.org as my hostname, so my config-domain.yaml looks like aikas.org: | ``` -If you were already running the Knative controllers, you will need to re-apply -the configmap. + If you were already running the Knative controllers, you will need to + re-apply the configmap. 1. Install GCP Pub Sub as an event source From 0a8149fd8506e020574a996d079c85f84090a35a Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 12 Jul 2018 11:47:29 -0700 Subject: [PATCH 4/4] Replace IP address. --- sample/gcp_pubsub_function/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sample/gcp_pubsub_function/README.md b/sample/gcp_pubsub_function/README.md index fa0f7cd7ddb..fb5595f4d39 100644 --- a/sample/gcp_pubsub_function/README.md +++ b/sample/gcp_pubsub_function/README.md @@ -103,7 +103,7 @@ create a DNS entry from: `gcp-pubsub-function.default.aikas.org` pointing to DNS](https://support.google.com/domains/answer/3290350). So, you'd need to create an A record for -`gcp-pubsub-function.default.aikas.org` pointing to `130.211.116.160` +`gcp-pubsub-function.default.aikas.org` pointing to `35.203.155.229`. To now bind the `gcp_pubsub_function` for GCP PubSub messages with the function we created above, you need to create a Bind object. Modify @@ -111,8 +111,8 @@ we created above, you need to create a Bind object. Modify want. For example, if I wanted to receive notifications to: project: -quantum-reducer-434 topic: knative-demo, my Bind object would look like the one -below. +`quantum-reducer-434` topic: `knative-demo`, my Bind object would look like the +one below. You can also specify a different Service Account to use for the bind / receive watcher by changing the spec.serviceAccountName to something else.