Skip to content

Commit

Permalink
feat: add content based router demo
Browse files Browse the repository at this point in the history
- add content based router example demo
- other refactor of documentation renaming, partials

Fixes #36
  • Loading branch information
kameshsampath committed Mar 8, 2019
1 parent 7af9e58 commit 1138a5e
Show file tree
Hide file tree
Showing 19 changed files with 700 additions and 136 deletions.
4 changes: 2 additions & 2 deletions 09-camel-k/knative/channels.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
metadata:
name: messages-us
name: genre-comedy
spec:
provisioner:
apiVersion: eventing.knative.dev/v1alpha1
Expand All @@ -12,7 +12,7 @@ spec:
apiVersion: eventing.knative.dev/v1alpha1
kind: Channel
metadata:
name: messages-others
name: genre-others
spec:
provisioner:
apiVersion: eventing.knative.dev/v1alpha1
Expand Down
2 changes: 1 addition & 1 deletion documentation/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
* xref:05eventing/eventing.adoc[7. Eventing]
** xref:05eventing/eventing.adoc#eventing-prerequisite[Prerequisites]
** xref:05eventing/eventing.adoc#eventing-assumptions[Assumptions]
** xref:05eventing/eventing.adoc#eventing-watch-logs[Watching Logs]
** xref:05eventing/eventing-src-svc.adoc[Source to Service]
*** xref:05eventing/eventing-src-svc.adoc#eventing-source[Event Source]
*** xref:05eventing/eventing-src-svc.adoc#eventing-create-event-source[Create Event Source]
Expand All @@ -108,6 +107,7 @@
**** xref:05eventing/eventing-src-sub.adoc#eventing-gen-subscriber-service[Generate Service]
**** xref:05eventing/eventing-src-sub.adoc#eventing-deploy-subscriber-service[Deploy Service]
*** xref:05eventing/eventing-src-sub.adoc#eventing-cleanup[Cleanup]
** xref:05eventing/eventing.adoc#eventing-watch-logs[Watching Logs]
* xref:faq.adoc[8.Frequently Asked Questions]
Expand Down
11 changes: 10 additions & 1 deletion documentation/modules/ROOT/pages/01basic-fundas.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ image::greeter-00001.png[Greeter Service]

[#basics-invoke-service]
== Invoke Service
include::partial$invoke-service.adoc[tag=*]

:k8s-env: minikube
:k8s-cli: kubectl
include::ROOT:partial$invoke-service.adoc[tag=*]

.(OR)

:k8s-env: minishift
:k8s-cli: oc
include::ROOT:partial$invoke-service.adoc[tag=*]

The last curl command should return a response like **Hi greeter => greeter-00001-deployment-5d696cc6c8-m65s5: 1**

Expand Down
10 changes: 9 additions & 1 deletion documentation/modules/ROOT/pages/02configs-and-routes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ image::greeter-00001.png[Greeter Service]
[#crtd-invoke-service]
== Invoke Service

include::partial$invoke-service.adoc[tag=*]
:k8s-env: minikube
:k8s-cli: kubectl
include::ROOT:partial$invoke-service.adoc[tag=*]

.(OR)

:k8s-env: minishift
:k8s-cli: oc
include::ROOT:partial$invoke-service.adoc[tag=*]

The command will return `HTTP 404` as there are no routes deployed yet. Let us now deploy a route.

Expand Down
10 changes: 9 additions & 1 deletion documentation/modules/ROOT/pages/03scaling.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ image::greeter-00001.png[Greeter Service]
[#scaling-invoke-service]
== Invoke Service

include::partial$invoke-service.adoc[tags=*]
:k8s-env: minikube
:k8s-cli: kubectl
include::ROOT:partial$invoke-service.adoc[tag=*]

.(OR)

:k8s-env: minishift
:k8s-cli: oc
include::ROOT:partial$invoke-service.adoc[tag=*]

The last `curl` command should return a response like **Hi greeter => greeter-00001-deployment-5d696cc6c8-m65s5: 1**

Expand Down
10 changes: 9 additions & 1 deletion documentation/modules/ROOT/pages/04build/build-templates.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,15 @@ image::event-greeter-00001.png[Event Greeter Service]
[#build-template-invoke-service]
== Invoke Service

include::partial$invoke-service.adoc[tag=env]
:k8s-env: minikube
:k8s-cli: kubectl
include::ROOT:partial$invoke-service.adoc[tag=env]

.(OR)

:k8s-env: minishift
:k8s-cli: oc
include::ROOT:partial$invoke-service.adoc[tag=env]

[source,bash,subs="+macros,+attributes",linenums]
----
Expand Down
10 changes: 9 additions & 1 deletion documentation/modules/ROOT/pages/04build/build.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,15 @@ image::event-greeter-00001.png[Event Greeter Service]
[#build-invoke-service]
== Invoke service

include::partial$invoke-service.adoc[tag=env]
:k8s-env: minikube
:k8s-cli: kubectl
include::ROOT:partial$invoke-service.adoc[tag=env]

.(OR)

:k8s-env: minishift
:k8s-cli: oc
include::ROOT:partial$invoke-service.adoc[tag=env]

[source,bash,subs="+macros,+attributes",linenums]
----
Expand Down
18 changes: 10 additions & 8 deletions documentation/modules/ROOT/pages/_partials/invoke-service.adoc
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# tag::env[]
[source,bash,linenums]
[k8s-env='']
[k8s-cli='']
#tag::env[]
[source,bash,subs="+macros,+attributes"]
----
INGRESSGATEWAY=istio-ingressgateway
IP_ADDRESS="$(minishift ip):$(kubectl get svc $INGRESSGATEWAY --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')"
IP_ADDRESS="$({k8s-env} ip):$({k8s-cli} get svc $INGRESSGATEWAY --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')"
----
# end::env[]
#end::env[]

# tag::call[]
[source,bash,linenums]
#tag::call[]
[source,bash,subs="+macros,+attributes"]
----
curl -v -H "Host: greeter.knativetutorial.example.com" $IP_ADDRESS
----

.(OR)

[source,bash,linenums]
[source,bash,subs="+macros,+attributes"]
----
http $IP_ADDRESS 'Host: greeter.knativetutorial.example.com'
----
# end::call[]
#end::call[]
23 changes: 20 additions & 3 deletions documentation/modules/camelk/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*** xref:camelk:setup.adoc#camelk-install-minio-s3[Install minio s3 Server]
**** xref:camelk:setup.adoc#minio-aws-cli-configure[Configure AWS cli]
*** xref:camelk:setup.adoc#install-camel-k[Install Camel-K ]
** xref:camelk:getting-started.adoc[Getting Started]
*** xref:camelk:setup.adoc#configure-local-registry[Configure Local Container Registry]
** xref:camelk:getting-started.adoc[Message Filter]
*** xref:camelk:getting-started.adoc#gs-prereq[Prerequisite]
*** xref:camelk:getting-started.adoc#gs-overview[Demo Overview]
*** xref:camelk:getting-started.adoc#gs-deployment[Deployment]
Expand All @@ -17,7 +18,7 @@
***** xref:camelk:getting-started.adoc#gs-test-data[Upload Test Data]
***** xref:camelk:getting-started.adoc#gs-invoke-service[Invoke service]
*** xref:camelk:getting-started.adoc#gs-cleanup[Cleanup]
** xref:camelk:poll-enrich.adoc[s3 File Downloader]
** xref:camelk:poll-enrich.adoc[Poll Enrich]
*** xref:camelk:poll-enrich.adoc#pe-prereq[Prerequisite]
*** xref:camelk:poll-enrich.adoc#pe-overview[Demo Overview]
*** xref:camelk:poll-enrich.adoc#pe-deployment[Deployment]
Expand All @@ -28,4 +29,20 @@
*** xref:camelk:poll-enrich.adoc#pe-test-cartoon-messages-downloader[Testing Route]
***** xref:camelk:poll-enrich.adoc#pe-test-data[Upload Test Data]
***** xref:camelk:poll-enrich.adoc#pe-invoke-service[Invoke service]
*** xref:camelk:poll-enrich.adoc#pe-cleanup[Cleanup]
*** xref:camelk:poll-enrich.adoc#pe-cleanup[Cleanup]
** xref:camelk:content-based-router.adoc[Content Based Router]
*** xref:camelk:content-based-router.adoc#cbr-prereq[Prerequisite]
*** xref:camelk:content-based-router.adoc#cbr-overview[Demo Overview]
*** xref:camelk:content-based-router.adoc#cbr-deployment[Deployment]
**** xref:camelk:content-based-router.adoc#cbr-make-s3-data-bucket[Create data s3 bucket]
**** xref:camelk:content-based-router.adoc#cbr-create-channels[Create Knative Channels]
**** xref:camelk:content-based-router.adoc#cbr-deploy-routes[Deploy Routes]
***** xref:camelk:content-based-router.adoc#cbr-comedy-genre-handler[Comedy Genre Handler]
***** xref:camelk:content-based-router.adoc#cbr-others-genre-handler[Others Genre Handler]
***** xref:camelk:content-based-router.adoc#cbr-cartoon-genre-router[Cartoon Genre Router]
*** xref:camelk:content-based-router.adoc#cbr-see-what-you-have-deployed[See what you have deployed ]
*** xref:camelk:content-based-router.adoc#cbr-watch-logs[Watching Logs]
*** xref:camelk:content-based-router.adoc#cbr-test-cartoon-genre-router[Testing Route]
***** xref:camelk:content-based-router.adoc#cbr-test-data[Upload Test Data]
***** xref:camelk:content-based-router.adoc#cbr-invoke-service[Invoke service]
*** xref:camelk:content-based-router.adoc#cbr-cleanup[Cleanup]
4 changes: 2 additions & 2 deletions documentation/modules/camelk/pages/_attributes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
:scaling-repo: 03-scaling
:build-repo: 04-build
:eventing-repo: 05-eventing
:camelk-repo: 09-camelk
:camelk-repo: 09-camel-k
:experimental:
:knative-version: v0.3.0
:knative-version: v0.4.0
:knative-serving-repo: https://github.com/knative/serving/releases/download
:knative-build-repo: https://github.com/knative/build/releases/download
:knative-eventing-repo: https://github.com/knative/eventing/releases/download
Expand Down
35 changes: 10 additions & 25 deletions documentation/modules/camelk/pages/_partials/extras.adoc
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
[k8s-cli='']

# tag::minio[]
#tag::config-k8s-local-registry[]

For various exercises in this cookbook we will be using the s3 kind of object storage. We will use open source object storage called https://github.com/minio/minio[minio] that is compatible with Amazon S3

The following section details how to setup minio server

[source,bash]
----
cd $COOKBOOKS_SOURCES_HOME/minio-s3-server
oc apply -f skaffold.yaml -n cookbook
oc expose svc minio-server -n cookbook
[source,bash,subs="+macros,+attributes"]
----
K8S_LOCAL_REGISTRY=`{k8s-cli} get svc -n kube-system registry -ojsonpath='{.spec.clusterIP}'`
[.text-center]
**(OR)**
[source,bash]
----
kubectl apply -f skaffold.yaml -n cookbook
val="ko.local,dev.local,pass:[${K8S_LOCAL_REGISTRY}]"
{k8s-cli} -n knative-serving get cm config-controller -oyaml \
| yq w - data.registriesSkippingTagResolving $val \
| kubectl apply -f -
----

[NOTE]
====
Details on how to use AWS s3 with minio is available https://docs.minio.io/docs/aws-cli-with-minio.html[here]
====

A successful minio deployment can be viewed via OpenShift dashboard as shown below:

image::minio-server.png[minio server]

#end::minio[]
#end::config-k8s-local-registry[]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
[file-name='']

#tag::set-svc-url[]

We need to know the knative service `{svc-name}` domain name that needs to be passed as **Host** header, we will query and and set that value in an environment variable called `SVC_URL`:

[source,bash,subs="+macros,+attributes"]
----
SVC_URL=`kubectl -n knativetutorial get ksvc {svc-name} -ojsonpath='{.status.domain}'`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[kube-ns='']
[it-name='']

#tag::integration-status[]
[source,bash,subs="+macros,+attributes"]
----
kubectl -n {kube-ns} get integrations.camel.apache.org {it-name}
----
.(OR)
[source,bash,subs="+macros,+attributes"]
----
oc -n {kube-ns} get integrations.camel.apache.org {it-name}
----
#end::integration-status[]
55 changes: 55 additions & 0 deletions documentation/modules/camelk/pages/_partials/minio-and-s3.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[k8s-env='minikube']
[s3-bucket='data']
[s3-upload-file='message1.xml']
[s3-upload-file-link='']

#tag::minio-aws-config[]
[source,bash,subs="+macros,+attributes"]
----
aws configure
# AWS Access Key ID [None]: demoaccesskey #<1>
# AWS Secret Access Key [None]: demosecretkey #<2>
# Default region name [None]:
# Default output format [None]:

aws configure set default.s3.signature_version s3v4 #<3>

aws configure list #<4>
----

<1> Using default user access key **demoaccesskey**
<2> Using default user secret key **demosecretkey**
<3> Enable **AWS Signature Version '4'** for minio server
<4> List the configuration

#end::minio-aws-config[]

#tag::s3-url[]
[source,bash,subs="+macros,+attributes"]
----
S3_URL=$({k8s-env} service -n knativetutorial minio-server --url)
----
#end::s3-url[]

#tag::s3-make-bucket[]

[source,bash,subs="+macros,+attributes"]
----
aws --endpoint-url $S3_URL s3 mb s3://{s3-bucket}
----

#end::s3-make-bucket[]

#tag::s3-upload-file[]
[source,bash,subs="+macros,+attributes"]
----
aws --endpoint-url $S3_URL s3 cp link:{s3-upload-file-link}[{s3-upload-file}] s3://{s3-bucket}
----
#end::s3-upload-file[]

#tag::s3-ls-bucket[]
[source,bash,subs="+macros,+attributes"]
----
aws --endpoint-url $S3_URL s3 ls s3://{s3-bucket}
----
#end::s3-ls-bucket[]
34 changes: 0 additions & 34 deletions documentation/modules/camelk/pages/_partials/minio-config.adoc

This file was deleted.

0 comments on commit 1138a5e

Please sign in to comment.