├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── main.yml │ └── staging.yml ├── .gitignore ├── .tool-versions ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── advanced ├── camel-k │ ├── .editorconfig │ ├── channels.yaml │ ├── eip │ │ ├── fruits-processor-kamelet.yaml │ │ ├── fruits-processor-to-knative.yaml │ │ ├── fruits-processor.yaml │ │ ├── fruits-producer.yaml │ │ └── sugary-fruits.yaml │ └── get-started │ │ ├── echoer.yaml │ │ ├── timed-greeter-binding.yaml │ │ ├── timed-greeter-kamelet.yaml │ │ ├── timed-greeter-source.yaml │ │ └── timed-greeter.yaml └── observability │ ├── config-observability-patch.yaml │ ├── customer.yaml │ ├── preference.yaml │ ├── recommendation-v2.yaml │ └── recommendation.yaml ├── apps ├── apache-artemis │ └── skaffold.yaml ├── eventinghello │ ├── .dockerignore │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── 1_jvmbuild.sh │ ├── 1_nativebuild.sh │ ├── 2_dockerbuild_jvm.sh │ ├── 2_dockerbuild_native.sh │ ├── 3_dockerbuild_push_jvm.sh │ ├── 3_dockerbuild_push_native.sh │ ├── README.md │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── docker │ │ │ ├── Dockerfile.jvm │ │ │ └── Dockerfile.native │ │ ├── java │ │ │ └── com │ │ │ │ └── redhat │ │ │ │ └── developers │ │ │ │ └── LoggerResource.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── resources │ │ │ │ └── index.html │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── redhat │ │ └── developers │ │ ├── LoggerResourceTest.java │ │ └── NativeLoggerResourceIT.java ├── fruits-events-display-ui │ ├── .dockerignore │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── LICENSE │ ├── README.adoc │ ├── buildLocal.sh │ ├── buildRemote.sh │ ├── kubernetes │ │ └── app.yaml │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── docker │ │ │ ├── Dockerfile.jvm │ │ │ └── Dockerfile.native │ │ ├── java │ │ │ └── com │ │ │ │ └── redhat │ │ │ │ └── developers │ │ │ │ └── demos │ │ │ │ ├── FruitsEventProcessor.java │ │ │ │ └── FruitsResource.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── resources │ │ │ │ └── index.html │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── redhat │ │ │ └── developers │ │ │ └── demos │ │ │ ├── FruitsResourceTest.java │ │ │ └── NativeFruitsResourceIT.java │ │ ├── sample-ce-data.json │ │ └── sample.json ├── greeter │ └── java │ │ ├── quarkus │ │ ├── .editorconfig │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── Dockerfile │ │ ├── Dockerfile.jvm │ │ ├── README.adoc │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── redhat │ │ │ └── developer │ │ │ └── demos │ │ │ ├── GreeterResource.java │ │ │ └── GreetingService.java │ │ └── springboot │ │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ │ ├── Dockerfile │ │ ├── Dockerfile.all │ │ ├── README.adoc │ │ ├── buildImage.sh │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── demo │ │ │ ├── DemoApplication.java │ │ │ └── GreeterController.java │ │ └── resources │ │ └── application.properties ├── minikube-registry-helper │ ├── kubectl │ ├── node-etc-hosts-update.yaml │ ├── patch-coredns.sh │ └── registry-aliases-config.yaml ├── minio-s3-server │ └── skaffold.yaml ├── nexus │ └── app.yaml └── prime-generator │ ├── .editorconfig │ ├── quarkus │ ├── .dockerignore │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── docker │ │ │ └── Dockerfile.jvm │ │ ├── java │ │ │ └── org │ │ │ │ └── workspace7 │ │ │ │ └── primegen │ │ │ │ ├── PrimeGenerateResource.java │ │ │ │ └── PrimeService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── demo │ │ └── Demo.java │ └── springboot │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── org │ │ └── workspce7 │ │ └── primegen │ │ └── primegenerator │ │ ├── PrimeGenerateController.java │ │ ├── PrimeGeneratorApplication.java │ │ └── PrimeService.java │ └── resources │ └── application.properties ├── bin ├── call.sh ├── clean-completed.sh ├── install-configure-all-components.sh ├── kafka-consumer.sh ├── kafka-list-topics.sh ├── kafka-producer.sh ├── kind-cluster-config.yaml ├── load.sh ├── poll.sh ├── start-kind-cluster.sh └── start-minikube.sh ├── build-tasks.ts ├── dev-site.yml ├── devfile.yaml ├── documentation ├── antora.yml └── modules │ ├── ROOT │ ├── assets │ │ └── images │ │ │ └── knative-cookbook.png │ ├── nav.adoc │ └── pages │ │ ├── _partials │ │ ├── advanced-nav.adoc │ │ ├── camelk-nav.adoc │ │ ├── deploy-knative-resources.adoc │ │ ├── eventing-nav.adoc │ │ ├── invoke-service.adoc │ │ ├── knative-objects.adoc │ │ ├── prereq-cli.adoc │ │ ├── serving-nav.adoc │ │ ├── set-env-vars.adoc │ │ ├── setup-nav.adoc │ │ └── watching-logs.adoc │ │ └── index.adoc │ ├── _attributes.adoc │ ├── advanced │ ├── _attributes.adoc │ ├── assets │ │ └── images │ │ │ ├── cbr_app_overview.png │ │ │ ├── cbr_app_ui_empty.png │ │ │ └── cbr_app_ui_with_data.png │ ├── examples │ │ └── kafka-topic-my-topic.yaml │ ├── nav.adoc │ └── pages │ │ ├── _attributes.adoc │ │ ├── _partials │ │ ├── adv-kubectl-queries.adoc │ │ └── default-knative-channel.adoc │ │ ├── camel-k-cbr.adoc │ │ ├── deploy-apache-kafka.adoc │ │ ├── eventing-with-kafka.adoc │ │ ├── index.adoc │ │ └── setup.adoc │ ├── camelk │ ├── _attributes.adoc │ ├── assets │ │ └── images │ │ │ └── kamelet-binding-simple.png │ ├── nav.adoc │ └── pages │ │ ├── _attributes.adoc │ │ ├── _partials │ │ ├── camel-k-k8s-objects.adoc │ │ ├── extras.adoc │ │ ├── invoke-service.adoc │ │ ├── kamel-objects-status.adoc │ │ ├── prereqs.adoc │ │ ├── source-code.adoc │ │ └── wait-for-pods.adoc │ │ ├── camel-k-basics.adoc │ │ ├── camel-k-eventing.adoc │ │ ├── index.adoc │ │ └── setup.adoc │ ├── eventing │ ├── _attributes.adoc │ ├── assets │ │ └── images │ │ │ ├── brokers-triggers.png │ │ │ ├── channels-subs.png │ │ │ ├── che_env_overview.png │ │ │ └── source-sink.png │ ├── examples │ │ └── eventing │ │ │ ├── channel-subscriber.yaml │ │ │ ├── channel.yaml │ │ │ ├── curler.yaml │ │ │ ├── default-channel-config.yaml │ │ │ ├── default-kafka-channel.yaml │ │ │ ├── event-source-broker.yaml │ │ │ ├── event-source-svc.yaml │ │ │ ├── event-source.yaml │ │ │ ├── eventing-aloha-sink.yaml │ │ │ ├── eventing-bonjour-sink.yaml │ │ │ ├── eventing-hello-sink.yaml │ │ │ ├── eventing-helloa-sink.yaml │ │ │ ├── eventing-helloa-sub.yaml │ │ │ ├── eventing-hellob-sink.yaml │ │ │ ├── eventing-hellob-sub.yaml │ │ │ ├── eventinghello-channel.yaml │ │ │ ├── eventinghello-source-ch.yaml │ │ │ ├── eventinghello-source.yaml │ │ │ ├── kafka-broker-my-cluster.yaml │ │ │ ├── kafka-topic-my-topic.yaml │ │ │ ├── mykafka-source.yaml │ │ │ ├── service.yaml │ │ │ ├── trigger-helloaloha.yaml │ │ │ ├── trigger-hellobonjour.yaml │ │ │ └── trigger.yaml │ ├── nav.adoc │ └── pages │ │ ├── _attributes.adoc │ │ ├── _partials │ │ ├── deploy-knative-resources.adoc │ │ ├── eventing-snippets.adoc │ │ ├── invoke-service.adoc │ │ ├── knative-objects.adoc │ │ ├── prereq-cli.adoc │ │ ├── watch-scaling-pods.adoc │ │ ├── watching-build-logs.adoc │ │ └── watching-logs.adoc │ │ ├── channel-and-subscribers.adoc │ │ ├── eventing-src-to-sink.adoc │ │ ├── eventing-trigger-broker.adoc │ │ ├── eventing.adoc │ │ └── index.adoc │ ├── serving │ ├── _attributes.adoc │ ├── examples │ │ ├── kn │ │ │ ├── kn_ksvc_desc.yaml │ │ │ └── kn_rev_desc.yaml │ │ ├── scaling │ │ │ ├── service-10.yaml │ │ │ └── service-min-max-scale.yaml │ │ └── serving │ │ │ ├── colors-service-blue.yaml │ │ │ ├── colors-service-canary.yaml │ │ │ ├── colors-service-green.yaml │ │ │ ├── service-pinned.yaml │ │ │ └── service.yaml │ ├── images │ │ ├── blue-green-canary-blue.png │ │ ├── blue-green-canary-green.png │ │ ├── blue-green-canary.gif │ │ └── che_env_overview.png │ ├── nav.adoc │ └── pages │ │ ├── _attributes.adoc │ │ ├── _partials │ │ ├── build-containers.adoc │ │ ├── deploy-knative-resources.adoc │ │ ├── invoke-service.adoc │ │ ├── istio-ingress.adoc │ │ ├── knative-objects.adoc │ │ ├── prereq-cli.adoc │ │ ├── watch-scaling-pods.adoc │ │ ├── watching-build-logs.adoc │ │ └── watching-logs.adoc │ │ ├── basic-fundas.adoc │ │ ├── index.adoc │ │ ├── knative-client.adoc │ │ ├── scaling.adoc │ │ └── traffic-distribution.adoc │ ├── setup │ ├── _attributes.adoc │ ├── pages │ │ ├── _attributes.adoc │ │ ├── kubernetes-cluster.adoc │ │ ├── minikube.adoc │ │ ├── openshift.adoc │ │ ├── setup.adoc │ │ ├── tutorial-dev-env.adoc │ │ └── tutorial-sources.adoc │ └── partials │ │ └── tutorial-dev-env.adoc │ └── workshop │ └── pages │ └── _partials │ └── openshift-setup.adoc ├── eventing ├── channel-subscriber.yaml ├── channel.yaml ├── curler.yaml ├── default-broker.yaml ├── default-channel-config.yaml ├── default-kafka-channel.yaml ├── event-source-broker.yaml ├── event-source.yaml ├── eventing-aloha-sink.yaml ├── eventing-bonjour-sink.yaml ├── eventing-hello-sink.yaml ├── eventing-helloa-sink.yaml ├── eventing-helloa-sub.yaml ├── eventing-hellob-sink.yaml ├── eventing-hellob-sub.yaml ├── eventinghello-channel.yaml ├── eventinghello-source-ch.yaml ├── eventinghello-source-ping.yaml ├── eventinghello-source.yaml ├── kafka-broker-my-cluster.yaml ├── kafka-topic-my-topic.yaml ├── mykafka-source.yaml ├── service.yaml ├── trigger-helloaloha.yaml ├── trigger-hellobonjour.yaml └── trigger.yaml ├── gulpfile.ts ├── install ├── community-operators-csc.yaml ├── csv-columns.txt ├── knative-eventing │ └── subscription.yaml ├── knative-serving │ ├── cr.yaml │ └── subscription.yaml ├── observability │ ├── deploy-jaeger.sh │ ├── install-jaeger.sh │ └── install-prometheus-grafana.sh ├── redhat-operators-csc.yaml ├── tektoncd-pipelines │ └── subscription.yaml ├── tutorial-tools.yaml └── utils │ ├── camel-k-maven-settings.xml │ ├── fruit-events-display.yaml │ ├── fruityvice-proxy.yaml │ └── nexus.yaml ├── lib ├── remote-include-processor.js └── tab-block.js ├── package.json ├── serving ├── colors-service-blue.yaml ├── colors-service-canary.yaml ├── colors-service-green.yaml ├── service-10.yaml ├── service-min-max-scale.yaml └── service.yaml ├── site.yaml ├── staging.sh ├── staging.yml ├── supplemental-ui ├── img │ └── favicon.ico └── partials │ └── footer-nav.hbs ├── version.txt ├── workshop.yaml └── workshopDocs.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | charset = utf-8 6 | trim_trailing_whitespace = false 7 | insert_final_newline = false 8 | 9 | [*.java] 10 | indent_style = space 11 | indent_size = 4 12 | 13 | [*.xml] 14 | indent_style = space 15 | indent_size = 2 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.{cmd,[cC][mM][dD]} text eol=crlf 3 | *.{bat,[bB][aA][tT]} text eol=crlf -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Knative Tutorial 2 | 3 | on: 4 | push: 5 | paths: 6 | - '**' 7 | - '!.github/workflows/**' 8 | - '.github/workflows/main.yml' 9 | - '.github/workflows/site.yaml' 10 | env: 11 | SITE_DIR: "gh-pages" 12 | 13 | jobs: 14 | buildAnDeploySite: 15 | name: "Build site with Antora" 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | - name: "Generate site using antora site action" 21 | uses: kameshsampath/antora-site-action@v0.2.4 22 | with: 23 | antora_playbook: site.yaml 24 | - name: Deploy Site 25 | id: deploy_site 26 | uses: peaceiris/actions-gh-pages@v3 27 | with: 28 | #deploy_key: "${{ secrets.TKN_STAGING_SITE_DEPLOY }}" 29 | github_token: ${{ secrets.GITHUB_TOKEN }} 30 | publish_dir: "${{ env.SITE_DIR }}" 31 | publish_branch: "gh-pages" 32 | full_commit_message: "[Release]${{ github.event.head_commit.message }}" 33 | -------------------------------------------------------------------------------- /.github/workflows/staging.yml: -------------------------------------------------------------------------------- 1 | name: Knative Tutorial Staging 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | env: 8 | SITE_DIR: 'gh-pages' 9 | STAGING_REPO: 'redhat-developer-docs/knative-tutorial-staging' 10 | STAGING_SITE_PLAYBOOK: 'staging.yml' 11 | jobs: 12 | stagingSite: 13 | name: Build and Deploy Staging Site 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v2 18 | - name: Generate Site 19 | uses: kameshsampath/antora-site-action@v0.2.4 20 | with: 21 | antora_playbook: "${{ env.STAGING_SITE_PLAYBOOK }}" 22 | - name: List Directory 23 | run: | 24 | ls -ltr "${{ github.workspace }}" 25 | ls -ltr "${{ env.SITE_DIR }}" 26 | - name: Deploy Site 27 | id: deploy_site 28 | uses: peaceiris/actions-gh-pages@v3 29 | with: 30 | deploy_key: "${{ secrets.KNATIVE_TUTORIAL_STAGING }}" 31 | publish_dir: "${{ env.SITE_DIR }}" 32 | publish_branch: "gh-pages" 33 | external_repository: "${{ env.STAGING_REPO }}" 34 | full_commit_message: ${{ github.event.head_commit.message }} 35 | - uses: GoogleCloudPlatform/release-please-action@v2.7.0 36 | id: release 37 | with: 38 | token: ${{ secrets.GITHUB_TOKEN }} 39 | release-type: simple 40 | bump-minor-pre-major: true 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea 3 | target/ 4 | build/ 5 | .gradle/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | 15 | .cache 16 | 17 | # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) 18 | !/.mvn/wrapper/maven-wrapper.jar 19 | .settings 20 | .vscode 21 | .project 22 | .classpath 23 | docs/output/* 24 | /hello.txt 25 | .idea 26 | work/**/* 27 | !work/README.md 28 | # 29 | **/setenv.sh 30 | 31 | gh-pages 32 | node_modules 33 | 34 | .firebaserc 35 | firebase.json 36 | .firebase 37 | openshift-cloud-functions 38 | workshop-attributes.yaml 39 | workshop-site.yaml 40 | **/.factorypath 41 | install/kafka 42 | install/knative-eventing/knative-kafka.yaml 43 | bin/kubectl 44 | gh-pages 45 | staging-gh-pages 46 | 47 | yarn.lock 48 | 49 | .DS_Store 50 | 51 | #camel-jbang 52 | **/.camel-jbang -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | nodejs 12.18.3 2 | yarn 1.22.5 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | The sources of this tutorial docs is split across multiple repositories: 4 | 5 | - The root repository which integrates all other module repositories to build the tutorial site: 6 | 7 | 8 | ## Tutorial Modules 9 | 10 | - [Setup](https://github.com/redhat-developer-demos/knative-tutorial/tree/master/documentation/modules/setup) 11 | 12 | - [Knative Serving](https://github.com/redhat-developer-demos/knative-tutorial/tree/master/documentation/modules/serving) 13 | 14 | - [Knative Eventing](https://github.com/redhat-developer-demos/knative-tutorial/tree/master/documentation/modules/eventing) 15 | 16 | - [Camel-K](https://github.com/redhat-developer-demos/knative-tutorial/tree/master/documentation/modules/camelk) 17 | 18 | - [Advanced Topics](https://github.com/redhat-developer-demos/knative-tutorial/tree/master/documentation/modules/advanced) 19 | 20 | ## Running site in development mode 21 | 22 | To run the site in development mode you need to have [yarn](https://yarnpkg.com) or [npm](https://nodejs.org/en/) installed with [nodejs](https://nodejs.org) v12.x or above. 23 | 24 | After cloning the repositories, you can run the `yarn install` or `npm install` from the `knative-tutorial` repository to install needed nodejs packages. 25 | 26 | Start the development site using `gulp -s $PWD` that should make the a local development site available at . 27 | 28 | Making any changes to your local repositories above cloned earlier, will be automatically built and the development site gets reloaded automatically. 29 | 30 | ## Send your contribution 31 | 32 | Now you are all set, 33 | 34 | - Open an Issue in 35 | - Prepare your changes in the respective documentation repository 36 | - Send the PR to respective repositories listed above 37 | 38 | We try to follow the Git commit messages using and thats not a hard rule ;) 39 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/antora/antora as builder 2 | 3 | ADD . /antora/ 4 | 5 | RUN antora generate --stacktrace site.yml 6 | 7 | FROM registry.access.redhat.com/rhscl/httpd-24-rhel7 8 | 9 | COPY --from=builder /antora/gh-pages/ /var/www/html/ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Knative Tutorial - Introduction to Knative 2 | 3 | ![Knative Tutorial](https://github.com/redhat-developer-demos/knative-tutorial/workflows/Knative%20Tutorial/badge.svg) [![Knative Serving v1.1.0](https://img.shields.io/badge/Knative%20Serving-v1.1.0-blue)](https://knative.dev/docs/serving/) 4 | [![Knative Eventing v1.1.0](https://img.shields.io/badge/Knative%20Eventing-v1.1.0-blue)](https://knative.dev/docs/eventing/) 5 | [![Strimzi Kafka](https://img.shields.io/badge/Strimzi%20Kafka-v0.26.1-blue)](https://strimzi.io) 6 | [![Apache Camel K](https://img.shields.io/badge/Apache%20Camel--K-v1.8.0-blue)](https://camel.apache.org/camel-k/latest/) 7 | [![OpenShift Serverless](https://img.shields.io/badge/OpenShift%20Serverless-v1.19.0-blue)](https://www.openshift.com/learn/topics/serverless) 8 | 9 | ## Documentation 10 | 11 | Start your serverless journey today with 12 | 13 | ## What is Serverless 14 | 15 | Serverless epitomize the very benefits of what cloud platforms promise: offload the management of infrastructure while taking advantage of a consumption model for the actual utilization of services. While there are a number of server frameworks out there, [Knative](https://knative.dev) is the first serverless platform specifically designed for Kubernetes and OpenShift. 16 | 17 | This tutorial will act as step-by-step guide in helping you to understand Knative starting with setup, understanding fundamentals concepts such as service, configuration, revision etc., and finally deploying some use cases which could help deploying serverless applications. 18 | 19 | This content is brought to you by [Red Hat Developer Program](http://developers.redhat.com) - Register today! 20 | 21 | ## Devlopment Site 22 | 23 | If you like to try the latest development updates,check the [staging site](https://redhat-developer-docs.github.io/knative-tutorial-staging). 24 | 25 | ## Contributing 26 | 27 | Please refer to the [how to contribute?](./CONTRIBUTING.md) on how you can contribute to the tutorial 28 | -------------------------------------------------------------------------------- /advanced/camel-k/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = false 8 | insert_final_newline = false -------------------------------------------------------------------------------- /advanced/camel-k/channels.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1alpha1 2 | kind: KafkaChannel 3 | metadata: 4 | name: cartoon-genres 5 | spec: 6 | numPartitions: 1 7 | replicationFactor: 1 8 | --- 9 | apiVersion: messaging.knative.dev/v1alpha1 10 | kind: KafkaChannel 11 | metadata: 12 | name: genre-comedy 13 | spec: 14 | numPartitions: 1 15 | replicationFactor: 1 16 | --- 17 | apiVersion: messaging.knative.dev/v1alpha1 18 | kind: KafkaChannel 19 | metadata: 20 | name: genre-others 21 | spec: 22 | numPartitions: 1 23 | replicationFactor: 1 24 | --- 25 | apiVersion: messaging.knative.dev/v1alpha1 26 | kind: KafkaChannel 27 | metadata: 28 | name: camel-test-channel 29 | spec: 30 | numPartitions: 1 31 | replicationFactor: 1 32 | -------------------------------------------------------------------------------- /advanced/camel-k/eip/fruits-processor-to-knative.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: camel.apache.org/v1alpha1 2 | kind: KameletBinding 3 | metadata: 4 | name: fruits-processor-to-knative 5 | spec: 6 | source: 7 | ref: 8 | kind: Kamelet 9 | apiVersion: camel.apache.org/v1alpha1 10 | name: fruits-processor 11 | properties: 12 | topic: "fruits" 13 | brokers: "my-cluster-kafka-bootstrap.kafka:9092" 14 | sink: 15 | ref: 16 | kind: Broker 17 | apiVersion: eventing.knative.dev/v1 18 | name: default -------------------------------------------------------------------------------- /advanced/camel-k/eip/fruits-processor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1alpha1 2 | kind: CamelSource 3 | metadata: 4 | name: fruits-processor 5 | spec: 6 | source: 7 | integration: 8 | dependencies: 9 | - camel:log 10 | - camel:kafka 11 | - camel:jackson 12 | - camel:bean 13 | flow: 14 | from: 15 | uri: "kafka:fruits?brokers=my-cluster-kafka-bootstrap.kafka:9092" 16 | steps: 17 | - log: 18 | message: "Received Body ${body}" 19 | - unmarshal: 20 | json: {} 21 | - choice: 22 | when: 23 | - simple: "${body[nutritions][sugar]} <= 5" 24 | steps: 25 | - remove-headers: "*" 26 | - marshal: 27 | json: {} 28 | - set-header: 29 | name: ce-type 30 | constant: low-sugar 31 | - set-header: 32 | name: fruit-sugar-level 33 | constant: low 34 | - to: "log:low?showAll=true&multiline=true" 35 | - simple: "${body[nutritions][sugar]} > 5 && ${body[nutritions][sugar]} <= 10" 36 | steps: 37 | - remove-headers: "*" 38 | - marshal: 39 | json: {} 40 | - set-header: 41 | name: ce-type 42 | constant: medium-sugar 43 | - set-header: 44 | name: fruit-sugar-level 45 | constant: medium 46 | - to: "log:medium?showAll=true&multiline=true" 47 | otherwise: 48 | steps: 49 | - remove-headers: "*" 50 | - marshal: 51 | json: {} 52 | - set-header: 53 | name: ce-type 54 | constant: high-sugar 55 | - set-header: 56 | name: fruit-sugar-level 57 | constant: high 58 | - to: "log:high?showAll=true&multiline=true" 59 | sink: 60 | ref: 61 | apiVersion: eventing.knative.dev/v1 62 | kind: Broker 63 | name: default 64 | -------------------------------------------------------------------------------- /advanced/camel-k/eip/fruits-producer.yaml: -------------------------------------------------------------------------------- 1 | - from: 2 | uri: timer:tick 3 | parameters: 4 | period: 5000 5 | steps: 6 | - set-header: 7 | name: CamelHttpMethod 8 | constant: GET 9 | - to: "https://fruityvice.com/api/fruit/all" 10 | - split: 11 | jsonpath: "$.[*]" 12 | - marshal: 13 | json: {} 14 | - log: 15 | message: "${body}" 16 | - to: "kafka:fruits?brokers=my-cluster-kafka-bootstrap.kafka:9092" 17 | -------------------------------------------------------------------------------- /advanced/camel-k/eip/sugary-fruits.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1 2 | kind: Trigger 3 | metadata: 4 | name: sugary-fruits 5 | spec: 6 | broker: default 7 | filter: 8 | attributes: 9 | type: low-sugar 10 | #type: medium-sugar 11 | #type: high-sugar 12 | # uncomment this if you don't want event message filtering 13 | #type: "" 14 | subscriber: 15 | ref: 16 | apiVersion: v1 17 | kind: Service 18 | name: fruit-events-display 19 | -------------------------------------------------------------------------------- /advanced/camel-k/get-started/echoer.yaml: -------------------------------------------------------------------------------- 1 | - from: 2 | uri: "knative:endpoint/echoer" 3 | steps: 4 | - log: 5 | message: "Got Message: ${body}" 6 | - convert-body-to: "java.lang.String" 7 | - choice: 8 | when: 9 | - simple: "${body} != null && ${body.trim().length} > 0" 10 | steps: 11 | - set-body: 12 | simple: "${body.toUpperCase()}" 13 | - set-header: 14 | name: ContentType 15 | simple: text/plain 16 | - log: 17 | message: "${body}" 18 | otherwise: 19 | steps: 20 | - set-body: 21 | constant: "no body received" 22 | - set-header: 23 | name: ContentType 24 | simple: text/plain 25 | - log: 26 | message: "Otherwise::${body}" 27 | -------------------------------------------------------------------------------- /advanced/camel-k/get-started/timed-greeter-binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: camel.apache.org/v1alpha1 2 | kind: KameletBinding 3 | metadata: 4 | name: timed-greeter-binding 5 | spec: 6 | source: 7 | ref: 8 | kind: Kamelet 9 | apiVersion: camel.apache.org/v1alpha1 10 | name: timed-greeter 11 | properties: 12 | period: 5000 13 | message: Welcome to Apache Camel K 14 | sink: 15 | uri: http://event-display-knativetutorial..com -------------------------------------------------------------------------------- /advanced/camel-k/get-started/timed-greeter-kamelet.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: camel.apache.org/v1alpha1 2 | kind: Kamelet 3 | metadata: 4 | name: timed-greeter 5 | spec: 6 | definition: 7 | title: Timed Greeter Source 8 | description: Produces periodic events with a custom payload. 9 | required: 10 | - message 11 | type: object 12 | properties: 13 | period: 14 | title: Period 15 | description: The interval between two events in milliseconds 16 | type: integer 17 | default: 1000 18 | message: 19 | title: Message 20 | description: The message to generate 21 | type: string 22 | example: hello world 23 | contentType: 24 | title: Content Type 25 | description: The content type of the message being generated 26 | type: string 27 | default: text/plain 28 | dependencies: 29 | - "camel:core" 30 | - "camel:timer" 31 | - "camel:kamelet" 32 | template: 33 | from: 34 | uri: timer:tick 35 | parameters: 36 | period: 10000 37 | steps: 38 | - set-body: 39 | constant: "{{message}}" 40 | - set-header: 41 | name: "Content-Type" 42 | constant: "{{contentType}}" 43 | - transform: 44 | simple: "${body.toUpperCase()}" 45 | - log: 46 | message: "Sending Body: ${body}" 47 | - to: "kamelet:sink" -------------------------------------------------------------------------------- /advanced/camel-k/get-started/timed-greeter-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1alpha1 2 | kind: CamelSource 3 | metadata: 4 | name: timed-greeter 5 | spec: 6 | integration: 7 | dependencies: 8 | - camel:log 9 | source: 10 | flow: 11 | from: 12 | uri: "timer:tick" 13 | parameters: 14 | # time in milliseconds 15 | period: 10000 16 | steps: 17 | - set-body: 18 | constant: "Welcome to Apache Camel K" 19 | - set-header: 20 | name: ContentType 21 | simple: text/plain 22 | - transform: 23 | simple: "${body.toUpperCase()}" 24 | - log: 25 | message: "${body}" 26 | sink: 27 | ref: 28 | apiVersion: serving.knative.dev/v1 29 | kind: Service 30 | name: event-display 31 | -------------------------------------------------------------------------------- /advanced/camel-k/get-started/timed-greeter.yaml: -------------------------------------------------------------------------------- 1 | - from: 2 | uri: "timer:tick" 3 | parameters: 4 | # time in milliseconds 5 | period: 10000 6 | steps: 7 | - set-body: 8 | constant: "Welcome to Apache Camel K" 9 | - set-header: 10 | name: ContentType 11 | simple: text/plain 12 | - transform: 13 | simple: "${body.toUpperCase()}" 14 | - to: 15 | uri: "log:info?multiline=true&showAll=true" 16 | -------------------------------------------------------------------------------- /advanced/observability/config-observability-patch.yaml: -------------------------------------------------------------------------------- 1 | data: 2 | metrics.request-metrics-backend-destination: prometheus 3 | -------------------------------------------------------------------------------- /advanced/observability/customer.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: customer 5 | spec: 6 | template: 7 | metadata: 8 | annotations: 9 | autoscaling.knative.dev/minScale: "1" 10 | spec: 11 | containers: 12 | - image: quay.io/rhdevelopers/istio-tutorial-customer:v1 13 | env: 14 | - name: COM_REDHAT_DEVELOPER_DEMOS_CUSTOMER_REST_PREFERENCESERVICE_MP_REST_URL 15 | value: "http://preference.knativetutorial.svc.cluster.local" 16 | livenessProbe: 17 | httpGet: 18 | path: /health 19 | readinessProbe: 20 | httpGet: 21 | path: /health 22 | -------------------------------------------------------------------------------- /advanced/observability/preference.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: preference 5 | labels: 6 | serving.knative.dev/visibility: "cluster-local" 7 | spec: 8 | template: 9 | metadata: 10 | annotations: 11 | autoscaling.knative.dev/target: "10" 12 | spec: 13 | containers: 14 | - image: quay.io/rhdevelopers/istio-tutorial-preference:v1 15 | env: 16 | - name: COM_REDHAT_DEVELOPER_DEMOS_CUSTOMER_REST_RECOMMENDATIONSERVICE_MP_REST_URL 17 | value: "http://recommendation.knativetutorial.svc.cluster.local" 18 | # livenessProbe: 19 | # httpGet: 20 | # path: /health 21 | # readinessProbe: 22 | # httpGet: 23 | # path: /health 24 | -------------------------------------------------------------------------------- /advanced/observability/recommendation-v2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: recommendation 5 | labels: 6 | serving.knative.dev/visibility: "cluster-local" 7 | spec: 8 | template: 9 | spec: 10 | containers: 11 | - image: quay.io/rhdevelopers/istio-tutorial-recommendation:v2 12 | # livenessProbe: 13 | # httpGet: 14 | # path: /health 15 | # readinessProbe: 16 | # httpGet: 17 | # path: /health 18 | -------------------------------------------------------------------------------- /advanced/observability/recommendation.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: recommendation 5 | labels: 6 | serving.knative.dev/visibility: "cluster-local" 7 | spec: 8 | template: 9 | spec: 10 | containers: 11 | - image: quay.io/rhdevelopers/istio-tutorial-recommendation:v1 12 | # livenessProbe: 13 | # httpGet: 14 | # path: /health 15 | # readinessProbe: 16 | # httpGet: 17 | # path: /health 18 | -------------------------------------------------------------------------------- /apps/apache-artemis/skaffold.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: apache-artemis-web 6 | spec: 7 | type: NodePort 8 | selector: 9 | app: apache-artemis 10 | ports: 11 | - name: admin-console 12 | port: 8161 13 | targetPort: 8161 14 | --- 15 | apiVersion: v1 16 | kind: Service 17 | metadata: 18 | name: apache-artemis-amqp 19 | spec: 20 | type: NodePort 21 | selector: 22 | app: apache-artemis 23 | ports: 24 | - name: amqp 25 | port: 5672 26 | targetPort: 5672 27 | --- 28 | apiVersion: apps/v1 29 | kind: Deployment 30 | metadata: 31 | name: apache-artemis 32 | spec: 33 | selector: 34 | matchLabels: 35 | app: apache-artemis 36 | template: 37 | metadata: 38 | labels: 39 | app: apache-artemis 40 | spec: 41 | containers: 42 | - name: broker 43 | image: quay.io/rhdevelopers/apache-artemis:2.6.4 44 | ports: 45 | - containerPort: 8161 46 | protocol: TCP 47 | name: admin-console 48 | - containerPort: 5672 49 | protocol: TCP 50 | name: amqp 51 | -------------------------------------------------------------------------------- /apps/eventinghello/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /apps/eventinghello/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /apps/eventinghello/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/eventinghello/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /apps/eventinghello/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /apps/eventinghello/1_jvmbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mvn clean package -------------------------------------------------------------------------------- /apps/eventinghello/1_nativebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export GRAALVM_HOME=~/tools/graalvm-ce-19.2.1/Contents/Home/ 4 | 5 | mvn clean package -Pnative -Dquarkus.native.container-build=true -------------------------------------------------------------------------------- /apps/eventinghello/2_dockerbuild_jvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t dev.local/rhdevelopers/eventinghello:0.0.1 -f src/main/docker/Dockerfile.jvm . -------------------------------------------------------------------------------- /apps/eventinghello/2_dockerbuild_native.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t dev.local/rhdevelopers/eventinghello:0.0.1 -f src/main/docker/Dockerfile.native . -------------------------------------------------------------------------------- /apps/eventinghello/3_dockerbuild_push_jvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION=0.0.2 4 | APP=eventinghello 5 | 6 | docker build -t dev.local/rhdevelopers/$APP:$VERSION -f src/main/docker/Dockerfile.jvm . 7 | 8 | docker login quay.io 9 | 10 | docker tag dev.local/rhdevelopers/$APP:$VERSION quay.io/rhdevelopers/$APP:$VERSION 11 | docker push quay.io/rhdevelopers/$APP:$VERSION 12 | 13 | -------------------------------------------------------------------------------- /apps/eventinghello/3_dockerbuild_push_native.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION=0.0.2 4 | APP=eventinghello 5 | 6 | docker build -t dev.local/rhdevelopers/$APP:$VERSION -f src/main/docker/Dockerfile.native . 7 | 8 | docker login quay.io 9 | 10 | docker tag dev.local/rhdevelopers/$APP:$VERSION quay.io/burrsutter/$APP:$VERSION 11 | docker push quay.io/rhdevelopers/$APP:$VERSION 12 | 13 | -------------------------------------------------------------------------------- /apps/eventinghello/README.md: -------------------------------------------------------------------------------- 1 | # knativetutorial-eventinghello project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ``` 11 | ./mvnw quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application can be packaged using `./mvnw package`. 17 | It produces the `knativetutorial-eventinghello-1.0.0-SNAPSHOT-runner.jar` file in the `/target` directory. 18 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 19 | 20 | The application is now runnable using `java -jar target/knativetutorial-eventinghello-1.0.0-SNAPSHOT-runner.jar`. 21 | 22 | ## Creating a native executable 23 | 24 | You can create a native executable using: `./mvnw package -Pnative`. 25 | 26 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`. 27 | 28 | You can then execute your native executable with: `./target/knativetutorial-eventinghello-1.0.0-SNAPSHOT-runner` 29 | 30 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image. -------------------------------------------------------------------------------- /apps/eventinghello/src/main/docker/Dockerfile.jvm: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/openjdk-11:latest 2 | 3 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. 4 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 5 | 6 | COPY target/lib/* /deployments/lib/ 7 | COPY target/*-runner.jar /deployments/app.jar 8 | -------------------------------------------------------------------------------- /apps/eventinghello/src/main/docker/Dockerfile.native: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode 3 | # 4 | # Before building the docker image run: 5 | # 6 | # mvn package -Pnative -Dquarkus.native.container-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/knativetutorial-eventinghello . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/knativetutorial-eventinghello 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | 21 | # set up permissions for user `1001` 22 | RUN chmod 775 /work /work/application \ 23 | && chown -R 1001 /work \ 24 | && chmod -R "g+rwX" /work \ 25 | && chown -R 1001:root /work 26 | 27 | EXPOSE 8080 28 | USER 1001 29 | 30 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /apps/eventinghello/src/main/java/com/redhat/developers/LoggerResource.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developers; 2 | 3 | import java.util.Map; 4 | import java.util.logging.Logger; 5 | 6 | import javax.ws.rs.Consumes; 7 | import javax.ws.rs.GET; 8 | import javax.ws.rs.POST; 9 | import javax.ws.rs.Path; 10 | import javax.ws.rs.Produces; 11 | import javax.ws.rs.core.Context; 12 | import javax.ws.rs.core.HttpHeaders; 13 | import javax.ws.rs.core.MediaType; 14 | import javax.ws.rs.core.Response; 15 | import javax.ws.rs.core.Response.Status; 16 | 17 | @Path("/") 18 | public class LoggerResource { 19 | 20 | private static final Logger LOGGER = Logger.getLogger("eventing-hello"); 21 | 22 | @GET 23 | @Consumes(MediaType.APPLICATION_JSON) 24 | @Produces(MediaType.APPLICATION_JSON) 25 | @Path("/") 26 | public String servingEndpoint() { 27 | LOGGER.info("ExampleResource's @GET method invoked."); 28 | outputEnv(); 29 | return "{\"hello\":\"world\"}"; 30 | } 31 | 32 | @POST 33 | @Path("/") 34 | public Response eventingEndpoint(@Context HttpHeaders httpHeaders, 35 | String cloudEventJSON) { 36 | LOGGER.info("ExampleResource's @POST method invoked."); 37 | 38 | outputEnv(); 39 | 40 | 41 | LOGGER.info("ce-id=" + httpHeaders.getHeaderString("ce-id")); 42 | LOGGER.info( 43 | "ce-source=" + httpHeaders.getHeaderString("ce-source")); 44 | LOGGER.info("ce-specversion=" 45 | + httpHeaders.getHeaderString("ce-specversion")); 46 | LOGGER.info("ce-time=" + httpHeaders.getHeaderString("ce-time")); 47 | LOGGER.info("ce-type=" + httpHeaders.getHeaderString("ce-type")); 48 | LOGGER.info( 49 | "content-type=" + httpHeaders.getHeaderString("content-type")); 50 | LOGGER.info("content-length=" 51 | + httpHeaders.getHeaderString("content-length")); 52 | 53 | LOGGER.info("POST:" + cloudEventJSON); 54 | 55 | return Response.status(Status.OK) 56 | .build(); 57 | } 58 | 59 | private void outputEnv() { 60 | Map env = System.getenv(); 61 | for (String envName : env.keySet()) { 62 | System.out.format("%s=%s%n", envName, env.get(envName)); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /apps/eventinghello/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value -------------------------------------------------------------------------------- /apps/eventinghello/src/test/java/com/redhat/developers/LoggerResourceTest.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developers; 2 | 3 | import io.quarkus.test.junit.QuarkusTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static io.restassured.RestAssured.given; 7 | import static org.hamcrest.CoreMatchers.is; 8 | 9 | @QuarkusTest 10 | public class LoggerResourceTest { 11 | 12 | @Test 13 | public void testHelloEndpoint() { 14 | given() 15 | .when().get("/hello") 16 | .then() 17 | .statusCode(200) 18 | .body(is("hello")); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /apps/eventinghello/src/test/java/com/redhat/developers/NativeLoggerResourceIT.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developers; 2 | 3 | import io.quarkus.test.junit.NativeImageTest; 4 | 5 | @NativeImageTest 6 | public class NativeLoggerResourceIT extends LoggerResourceTest { 7 | 8 | // Execute the same tests but in native mode. 9 | } -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/fruits-events-display-ui/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=http://localhost:8081/repository/maven-public//org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip 2 | wrapperUrl=http://localhost:8081/repository/maven-public//io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/README.adoc: -------------------------------------------------------------------------------- 1 | = Fruits Events Display 2 | 3 | A https://quarkus.io[Quarkus] application that will handle the https://cloudevents.io[CloudEvents] data and report the same to connected web applications using https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events[Server Sent Events]. 4 | 5 | Since there will no streaming data in this case, we shall use Emitter to produce the events as and when they receive form the source application. This application could be used a the event sink for the Knative Event sources. 6 | 7 | == Build and Run 8 | 9 | You can run the application in development mode as shown, 10 | 11 | [source,bash] 12 | ---- 13 | mvn clean compile quarkus:dev 14 | ---- 15 | 16 | Once the application is running you can open the URL http://localhost:8080 17 | 18 | Open a new terminal and send a sample cloud event data to the service: 19 | 20 | [source,bash] 21 | ---- 22 | cat src/test/sample.json |\ 23 | http -v POST :8080 \ 24 | ce-specversion:0.3 \ 25 | ce-type:low-sugar \ 26 | ce-time:2019-12-23T12:30:14.128Z \ 27 | ce-id:ID-fruits-processor-glmls-7fb9bff9cd-5k65g-1577104083727-0-45 \ 28 | ce-source:camel-source:knativetutorial/fruits-processor 29 | ---- 30 | 31 | This should return you an HTTP 200 response and you will also notice the web ui is updated with data from CloudEvent JSON with some extra details. 32 | 33 | == Application Container Image 34 | 35 | The application container image is available at `quay.io/rhdevelopers/fruits-events-display-ui:v0.0.1` 36 | 37 | == Customization 38 | 39 | Though this application is meant for Fruits application demo, but it an can be customized. Check the FruitResource class to see the possible customizations. 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/buildLocal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | set -o pipefail 6 | 7 | _CURR_DIR="$( cd "$(dirname "$0")" ; pwd -P )" 8 | 9 | ARTIFACT_NAME=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.build.finalName -q -DforceStdout) 10 | ARTIFACT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.version -q -DforceStdout) 11 | 12 | #mvn -DskipTests clean package -Pnative -Dnative-image.docker-build=true 13 | mvn -DskipTests clean package 14 | 15 | 16 | IMAGE_NAME="rhdevelopers/knative-tutorial-fruit-events-display:jvm-$ARTIFACT_VERSION" 17 | 18 | IMAGE="$(minikube ip):5000/$IMAGE_NAME" 19 | 20 | docker build -t $IMAGE -f src/main/docker/Dockerfile.jvm $_CURR_DIR 21 | 22 | docker push --tls-verify=false $IMAGE 23 | 24 | yq w "$_CURR_DIR/kubernetes/app.yaml" -d1 'spec.template.spec.containers[0].image' "dev.local/$IMAGE_NAME" |\ 25 | yq w - -d1 'spec.template.spec.containers[0].resources.limits.memory' "128Mi" |\ 26 | kubectl apply -f - -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/buildRemote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | set -o pipefail 6 | 7 | _CURR_DIR="$( cd "$(dirname "$0")" ; pwd -P )" 8 | 9 | ARTIFACT_NAME=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.build.finalName -q -DforceStdout) 10 | ARTIFACT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.version -q -DforceStdout) 11 | 12 | mvn -DskipTests clean package -Pnative -Dnative-image.docker-build=true 13 | #mvn -DskipTests clean package -Dnative-image.docker-build=true 14 | 15 | IMAGE=${1:-"quay.io/rhdevelopers/knative-tutorial-fruit-events-display:$ARTIFACT_VERSION"} 16 | 17 | docker build -t $IMAGE -f src/main/docker/Dockerfile.native $_CURR_DIR 18 | 19 | docker push $IMAGE -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/kubernetes/app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: fruit-events-display 5 | spec: 6 | selector: 7 | app: fruit-events-display 8 | ports: 9 | - port: 80 10 | targetPort: 8080 11 | type: NodePort 12 | --- 13 | apiVersion: apps/v1 14 | kind: Deployment 15 | metadata: 16 | name: fruit-events-display 17 | spec: 18 | selector: 19 | matchLabels: 20 | app: fruit-events-display 21 | template: 22 | metadata: 23 | labels: 24 | app: fruit-events-display 25 | spec: 26 | containers: 27 | - name: fruit-events-display 28 | image: update to your image name 29 | imagePullPolicy: Always 30 | resources: 31 | limits: 32 | memory: "64Mi" 33 | cpu: "500m" 34 | ports: 35 | - containerPort: 8080 36 | -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/main/docker/Dockerfile.jvm: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode 3 | # 4 | # Before building the docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/fruits-ui-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/fruits-ui-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | EXPOSE 8080 23 | 24 | # run with user 1001 and be prepared for be running in OpenShift too 25 | RUN adduser -G root --no-create-home --disabled-password 1001 \ 26 | && chown -R 1001 /deployments \ 27 | && chmod -R "g+rwX" /deployments \ 28 | && chown -R 1001:root /deployments 29 | USER 1001 30 | 31 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/main/docker/Dockerfile.native: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode 3 | # 4 | # Before building the docker image run: 5 | # 6 | # mvn package -Pnative -Dquarkus.native.container-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/fruits-ui . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/fruits-ui 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/main/java/com/redhat/developers/demos/FruitsEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developers.demos; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | 5 | import org.eclipse.microprofile.reactive.messaging.Incoming; 6 | import org.eclipse.microprofile.reactive.messaging.Outgoing; 7 | import org.jboss.logging.Logger; 8 | 9 | import io.smallrye.reactive.messaging.annotations.Broadcast; 10 | 11 | /** 12 | * FruitsEventProcessor 13 | */ 14 | @ApplicationScoped 15 | public class FruitsEventProcessor { 16 | 17 | Logger logger = Logger.getLogger(FruitsEventProcessor.class); 18 | 19 | @Incoming("fruit-events") 20 | @Outgoing("fruit-events-stream") 21 | @Broadcast 22 | public String processFruitEvent(String feJson ) { 23 | logger.info("SSE Data:" + feJson); 24 | return feJson; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fruit Events 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |

Fruits

20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
NameSugar LevelCategoryEvent Time
31 |
32 | 33 | 34 | 71 | 72 | -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | kubernetes.group=quay.io/rhdevelopers 2 | quarkus.application.name=knative-tutorial-fruit-events-display -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/test/java/com/redhat/developers/demos/FruitsResourceTest.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developers.demos; 2 | 3 | import io.quarkus.test.junit.QuarkusTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static io.restassured.RestAssured.given; 7 | import static org.hamcrest.CoreMatchers.is; 8 | 9 | @QuarkusTest 10 | public class FruitsResourceTest { 11 | 12 | @Test 13 | public void testHelloEndpoint() { 14 | given() 15 | .when().get("/") 16 | .then() 17 | .statusCode(200) 18 | .body(is("hello")); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/test/java/com/redhat/developers/demos/NativeFruitsResourceIT.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developers.demos; 2 | 3 | import io.quarkus.test.junit.NativeImageTest; 4 | 5 | @NativeImageTest 6 | public class NativeFruitsResourceIT extends FruitsResourceTest { 7 | 8 | // Execute the same tests but in native mode. 9 | } -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/test/sample-ce-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "genus": "Fragaria", 4 | "name": "Strawberry", 5 | "id": 3, 6 | "family": "Rosaceae", 7 | "order": "Rosales", 8 | "nutritions": { 9 | "carbohydrates": 5.5, 10 | "protein": 0.8, 11 | "fat": 0.4, 12 | "calories": 29, 13 | "sugar": 5.4 14 | } 15 | }, 16 | "specversion": "0.3", 17 | "type": "low-sugar", 18 | "time": "2019-12-23T12:30:14.128Z", 19 | "id": "ID-fruits-processor-glmls-7fb9bff9cd-5k65g-1577104083727-0-45", 20 | "source": "camel-source:knativetutorial/fruits-processor" 21 | } -------------------------------------------------------------------------------- /apps/fruits-events-display-ui/src/test/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "genus": "Fragaria", 3 | "name": "Strawberry", 4 | "id": 3, 5 | "family": "Rosaceae", 6 | "order": "Rosales", 7 | "nutritions": { 8 | "carbohydrates": 5.5, 9 | "protein": 0.8, 10 | "fat": 0.4, 11 | "calories": 29, 12 | "sugar": 5.4 13 | } 14 | } -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = false 8 | insert_final_newline = false -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/greeter/java/quarkus/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=http://repo2.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | wrapperUrl=http://repo2.maven.org/maven2/io/takari/maven-wrapper/0.5.4/maven-wrapper-0.5.4.jar 3 | -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.fedoraproject.org/fedora-minimal 2 | 3 | WORKDIR /work/ 4 | 5 | COPY target/*-runner /work/application 6 | RUN chmod 775 /work 7 | EXPOSE 8080 8 | 9 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/Dockerfile.jvm: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode 3 | # 4 | # Before building the docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/fruits-app-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/fruits-app-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/README.adoc: -------------------------------------------------------------------------------- 1 | = Quarkus Greeter 2 | 3 | The Greeter application based on https://quarkus.io[QuarkusIO], that can be deployed as Knative service. 4 | 5 | Please check the https://redhat-developer-demos.github.io/knative-tutorial/knative-tutorial/0.4.0/05-build/build.html[Knative Tutorial] on how to build and deploy the application -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/src/main/java/com/redhat/developer/demos/GreeterResource.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developer.demos; 2 | 3 | import org.eclipse.microprofile.config.inject.ConfigProperty; 4 | 5 | import javax.inject.Inject; 6 | import javax.ws.rs.*; 7 | import javax.ws.rs.core.MediaType; 8 | 9 | @Path("/") 10 | public class GreeterResource { 11 | 12 | @Inject 13 | GreetingService greetingService; 14 | 15 | @Inject 16 | @ConfigProperty(name = "MESSAGE_PREFIX", defaultValue = "Hi") 17 | String messagePrefix; 18 | 19 | @GET 20 | @Produces(MediaType.TEXT_PLAIN) 21 | @Path("/") 22 | public String greet() { 23 | return greetingService.greet(messagePrefix); 24 | } 25 | 26 | @POST 27 | @Consumes(MediaType.APPLICATION_JSON) 28 | @Produces(MediaType.TEXT_PLAIN) 29 | @Path("/") 30 | public String eventGreet(String cloudEventJson) { 31 | return greetingService.eventGreet(cloudEventJson); 32 | } 33 | 34 | @GET 35 | @Produces(MediaType.TEXT_PLAIN) 36 | @Path("/healthz") 37 | public String health() { 38 | return "OK"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /apps/greeter/java/quarkus/src/main/java/com/redhat/developer/demos/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.redhat.developer.demos; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import javax.enterprise.context.ApplicationScoped; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | 11 | @ApplicationScoped 12 | public class GreetingService { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger(GreetingService.class); 15 | 16 | private final SimpleDateFormat SDF = new SimpleDateFormat("HH:mm:ss"); 17 | 18 | private static final String RESPONSE_STRING_FORMAT = "%s %s greeter => '%s' : %d\n"; 19 | 20 | private static final String HOSTNAME = 21 | parseContainerIdFromHostname(System.getenv().getOrDefault("HOSTNAME", "unknown")); 22 | 23 | static String parseContainerIdFromHostname(String hostname) { 24 | return hostname.replaceAll("greeter-v\\d+-", "").trim(); 25 | } 26 | 27 | /** 28 | * Counter to help us see the lifecycle 29 | */ 30 | private int count = 0; 31 | 32 | public String greet(String prefix) { 33 | count++; 34 | return String.format(RESPONSE_STRING_FORMAT, prefix, "", HOSTNAME, count); 35 | } 36 | 37 | String eventGreet(String cloudEventJson) { 38 | count++; 39 | String greeterHost = String.format(RESPONSE_STRING_FORMAT, ""," Event ", HOSTNAME, count); 40 | JsonObject response = new JsonObject(cloudEventJson) 41 | .put("host", greeterHost.replace("\n", "").trim()) 42 | .put("time", SDF.format(new Date())); 43 | LOGGER.info("Event Message Received \n {}", response.encodePrettily()); 44 | return response.encode(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /apps/greeter/java/springboot/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/greeter/java/springboot/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /apps/greeter/java/springboot/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip -------------------------------------------------------------------------------- /apps/greeter/java/springboot/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fabric8/java-jboss-openjdk8-jdk:1.5.4 2 | USER jboss 3 | ENV JAVA_APP_DIR=/deployments 4 | EXPOSE 8080 5 | COPY target/greeter.jar /deployments/ 6 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /apps/greeter/java/springboot/Dockerfile.all: -------------------------------------------------------------------------------- 1 | FROM gcr.io/cloud-builders/mvn as builder 2 | COPY . /project 3 | WORKDIR /project 4 | RUN mvn -Duser.home=/builder/home -B -DskipTests install 5 | 6 | FROM fabric8/java-jboss-openjdk8-jdk:1.5.4 7 | USER jboss 8 | ENV JAVA_APP_DIR=/deployments 9 | EXPOSE 8080 10 | COPY --from=builder /project/target/greeter.jar /deployments/ 11 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /apps/greeter/java/springboot/README.adoc: -------------------------------------------------------------------------------- 1 | = SpringBoot Greeter 2 | 3 | The Greeter application based on SpringBoot, that can be deployed as Knative service. 4 | 5 | Please check the https://redhat-developer-demos.github.io/knative-tutorial/knative-tutorial/0.4.0/05-build/build.html[Knative Tutorial] on how to build and deploy the application -------------------------------------------------------------------------------- /apps/greeter/java/springboot/buildImage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./mvnw clean install 4 | 5 | _NAME=$(xml sel -N ns="http://maven.apache.org/POM/4.0.0" -t -v "//ns:project/ns:artifactId/text()" ./pom.xml) 6 | _VERSION=$(xml sel -N ns="http://maven.apache.org/POM/4.0.0" -t -v "//ns:project/ns:version/text()" ./pom.xml) 7 | 8 | docker build -t ${DOCKER_USER:-dev.local/rhdevelopers}/${_NAME}:${_VERSION} -f Dockerfile.all . 9 | -------------------------------------------------------------------------------- /apps/greeter/java/springboot/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /apps/greeter/java/springboot/src/main/java/com/example/demo/GreeterController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import java.text.SimpleDateFormat; 10 | import java.util.Date; 11 | 12 | /** 13 | * GreeterController 14 | */ 15 | @RestController 16 | public class GreeterController { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(GreeterController.class); 19 | 20 | private static final String RESPONSE_STRING_FORMAT = "%s %s greeter => '%s' : %d\n"; 21 | 22 | private final SimpleDateFormat SDF = new SimpleDateFormat("HH:mm:ss"); 23 | 24 | private static final String HOSTNAME = 25 | parseContainerIdFromHostname(System.getenv().getOrDefault("HOSTNAME", "unknown")); 26 | 27 | static String parseContainerIdFromHostname(String hostname) { 28 | return hostname.replaceAll("greeter-v\\d+-", ""); 29 | } 30 | 31 | @Value("${MESSAGE_PREFIX:Hi}") 32 | private String prefix; 33 | 34 | /** 35 | * Counter to help us see the lifecycle 36 | */ 37 | private int count = 0; 38 | 39 | 40 | @GetMapping("/") 41 | public String greet() { 42 | count++; 43 | return String.format(RESPONSE_STRING_FORMAT, prefix, "", HOSTNAME, count); 44 | } 45 | 46 | @PostMapping("/") 47 | public @ResponseBody 48 | String eventGreet(@RequestBody String cloudEventJson) { 49 | count++; 50 | String greeterHost = String.format(RESPONSE_STRING_FORMAT, ""," Event ", HOSTNAME, count); 51 | JsonObject response = new JsonObject(cloudEventJson) 52 | .put("host",greeterHost.replace("\n","").trim()) 53 | .put("time",SDF.format(new Date())); 54 | LOGGER.info("Event Message Received \n {}",response.encodePrettily()); 55 | return response.encode(); 56 | } 57 | 58 | @GetMapping("/healthz") 59 | public String health() { 60 | return "OK"; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /apps/greeter/java/springboot/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/greeter/java/springboot/src/main/resources/application.properties -------------------------------------------------------------------------------- /apps/minikube-registry-helper/kubectl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/minikube-registry-helper/kubectl -------------------------------------------------------------------------------- /apps/minikube-registry-helper/node-etc-hosts-update.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: DaemonSet 3 | metadata: 4 | name: registry-aliases-hosts-update 5 | namespace: kube-system 6 | spec: 7 | selector: 8 | matchLabels: 9 | app: registry-aliases-hosts-update 10 | template: 11 | metadata: 12 | labels: 13 | app: registry-aliases-hosts-update 14 | spec: 15 | initContainers: 16 | - name: update 17 | image: registry.fedoraproject.org/fedora 18 | volumeMounts: 19 | - name: etchosts 20 | mountPath: /host-etc/hosts 21 | readOnly: false 22 | env: 23 | - name: REGISTRY_ALIASES 24 | valueFrom: 25 | configMapKeyRef: 26 | name: registry-aliases 27 | key: registryAliases 28 | command: 29 | - bash 30 | - -ce 31 | - | 32 | NL=$'\n' 33 | TAB=$'\t' 34 | HOSTS="$(cat /host-etc/hosts)" 35 | [ -z "$REGISTRY_SERVICE_HOST" ] && echo "Failed to get hosts entry for default registry" && exit 1; 36 | for H in $REGISTRY_ALIASES; do 37 | echo "$HOSTS" | grep "$H" || HOSTS="$HOSTS$NL$REGISTRY_SERVICE_HOST$TAB$H"; 38 | done; 39 | echo "$HOSTS" | diff -u /host-etc/hosts - || echo "$HOSTS" > /host-etc/hosts 40 | echo "Done." 41 | containers: 42 | - name: pause-for-update 43 | image: gcr.io/google_containers/pause-amd64:3.1 44 | terminationGracePeriodSeconds: 30 45 | volumes: 46 | - name: etchosts 47 | hostPath: 48 | path: /etc/hosts 49 | -------------------------------------------------------------------------------- /apps/minikube-registry-helper/patch-coredns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A script that wil be used to patch the core dns aliases 3 | # e.g say i want dev.local to be mapped to default registry registry.kube-system.cluster.svc.local 4 | # 5 | set -eu 6 | 7 | set -o pipefail 8 | 9 | # clean up old files if they exist 10 | rm -f /tmp/coredns-alias-patch.yaml 11 | rm -f /tmp/coredns-alias-prepatch.yaml 12 | 13 | REGISTRY_ALIASES=$(kubectl get cm registry-aliases -n kube-system -oyaml | yq r - data.registryAliases) 14 | REGISTRY_SVC=$(kubectl get cm registry-aliases -n kube-system -oyaml | yq r - data.registrySvc) 15 | ALIASES_ENTRIES="" 16 | NL_DELIMITER='~' 17 | SPACES=' ' 18 | RW_RULE='rewrite name ' 19 | 20 | OLDIFS=$IFS 21 | 22 | IFS= 23 | 24 | # store the previous value for further processing 25 | kubectl get cm coredns -n kube-system -oyaml | yq r - data.Corefile | tee /tmp/coredns-alias-prepatch.yaml > /dev/null 26 | 27 | nStart=$(grep -n -m 1 "$REGISTRY_SVC" /tmp/coredns-alias-prepatch.yaml | head -n1 | cut -d: -f1 || true ) 28 | nEnd=$(grep -n "$REGISTRY_SVC" /tmp/coredns-alias-prepatch.yaml | tail -n1 | cut -d: -f1 || true ) 29 | 30 | #echo "Pattern Start line: $nStart Ending line : $nEnd" 31 | 32 | # remove old entries 33 | if [ -n "$nStart" ] && [ -n "$nEnd" ]; 34 | then 35 | sed -i "$nStart,${nEnd}d" /tmp/coredns-alias-prepatch.yaml > /dev/null 36 | fi 37 | 38 | IFS=$OLDIFS 39 | 40 | for H in $REGISTRY_ALIASES; 41 | do 42 | [ -n "$ALIASES_ENTRIES" ] && ALIASES_ENTRIES="$ALIASES_ENTRIES$NL_DELIMITER" 43 | ALIASES_ENTRIES="$ALIASES_ENTRIES$RW_RULE$H$SPACES$REGISTRY_SVC" 44 | done 45 | 46 | ALIASES_ENTRIES="$ALIASES_ENTRIES$NL_DELIMITER" 47 | 48 | IFS= 49 | 50 | if [ -n "$ALIASES_ENTRIES" ]; 51 | then 52 | # Add the rename rewrites after string health 53 | sed "/health/a\\ 54 | $ALIASES_ENTRIES" < /tmp/coredns-alias-prepatch.yaml| tr '~' '\n' | tee /tmp/coredns-alias-patch.yaml > /dev/null 55 | yq w -i /tmp/coredns-alias-patch.yaml data.Corefile "$(cat /tmp/coredns-alias-patch.yaml)" 56 | # echo "Patch to be applied" 57 | #cat /tmp/coredns-alias-patch.yaml 58 | kubectl patch cm coredns -n kube-system --patch "$(cat /tmp/coredns-alias-patch.yaml)" 59 | else 60 | echo "No Aliass entries found, skipping patch" 61 | fi 62 | -------------------------------------------------------------------------------- /apps/minikube-registry-helper/registry-aliases-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | # Add additonal hosts seperated by new-line 4 | registryAliases: >- 5 | dev.local 6 | example.com 7 | # default registry address in minikube when enabled via minikube addons enable registry 8 | registrySvc: registry.kube-system.svc.cluster.local 9 | kind: ConfigMap 10 | metadata: 11 | name: registry-aliases 12 | namespace: kube-system 13 | -------------------------------------------------------------------------------- /apps/minio-s3-server/skaffold.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Secret 4 | type: Opaque 5 | metadata: 6 | annotations: {} 7 | name: minio-access-secrets 8 | stringData: 9 | minioSecret: demosecretkey 10 | minioAccessKey: demoaccesskey 11 | --- 12 | kind: PersistentVolumeClaim 13 | apiVersion: v1 14 | metadata: 15 | name: home-claim 16 | spec: 17 | accessModes: 18 | - ReadWriteOnce 19 | resources: 20 | requests: 21 | storage: 8Gi 22 | --- 23 | kind: PersistentVolumeClaim 24 | apiVersion: v1 25 | metadata: 26 | name: minio-config-claim 27 | spec: 28 | accessModes: 29 | - ReadWriteOnce 30 | resources: 31 | requests: 32 | storage: 8Gi 33 | --- 34 | apiVersion: v1 35 | kind: Service 36 | metadata: 37 | name: minio-server 38 | spec: 39 | type: NodePort 40 | selector: 41 | app: minio-server 42 | ports: 43 | - name: web 44 | port: 80 45 | targetPort: 9000 46 | --- 47 | apiVersion: apps/v1 48 | kind: Deployment 49 | metadata: 50 | name: minio-server 51 | spec: 52 | selector: 53 | matchLabels: 54 | app: minio-server 55 | template: 56 | metadata: 57 | labels: 58 | app: minio-server 59 | spec: 60 | containers: 61 | - name: minio 62 | env: 63 | - name: MINIO_ACCESS_KEY 64 | valueFrom: 65 | secretKeyRef: 66 | name: minio-access-secrets 67 | key: minioAccessKey 68 | - name: MINIO_SECRET_KEY 69 | valueFrom: 70 | secretKeyRef: 71 | name: minio-access-secrets 72 | key: minioSecret 73 | image: minio/minio 74 | args: 75 | - server 76 | - /data 77 | ports: 78 | - containerPort: 9000 79 | protocol: TCP 80 | name: web 81 | volumeMounts: 82 | - name: home 83 | mountPath: /data 84 | - name: config 85 | mountPath: /root/.minio 86 | volumes: 87 | - name: home 88 | persistentVolumeClaim: 89 | claimName: home-claim 90 | - name: config 91 | persistentVolumeClaim: 92 | claimName: minio-config-claim 93 | -------------------------------------------------------------------------------- /apps/nexus/app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nexus 5 | spec: 6 | type: NodePort 7 | selector: 8 | app: nexus 9 | ports: 10 | - port: 8081 11 | targetPort: 8081-tcp 12 | --- 13 | apiVersion: apps/v1 14 | kind: Deployment 15 | metadata: 16 | name: nexus 17 | spec: 18 | selector: 19 | matchLabels: 20 | app: nexus 21 | template: 22 | metadata: 23 | labels: 24 | app: nexus 25 | spec: 26 | containers: 27 | - name: nexus 28 | image: sonatype/nexus 29 | resources: 30 | limits: 31 | memory: "512Mi" 32 | cpu: "500m" 33 | volumeMounts: 34 | - mountPath: /sonatype-work 35 | name: sonatype-work 36 | ports: 37 | - containerPort: 8081 38 | name: 8081-tcp 39 | volumes: 40 | - name: sonatype-work 41 | emptyDir: {} 42 | -------------------------------------------------------------------------------- /apps/prime-generator/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = false 8 | insert_final_newline = false -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/.dockerignore: -------------------------------------------------------------------------------- 1 | target 2 | .vscode 3 | *.iml 4 | .settings -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/prime-generator/quarkus/.gitignore -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/apps/prime-generator/quarkus/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=http://localhost:8081/nexus/content/groups/public/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | wrapperUrl=http://localhost:8081/nexus/content/groups/public/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar 3 | -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/rhdevelopers/quarkus-java-builder:graal-1.0.0-rc15 as builder 2 | COPY . /project 3 | 4 | # uncomment this to set the MAVEN_MIRROR_URL of your choice, to make faster builds 5 | # ARG MAVEN_MIRROR_URL= 6 | # e.g. 7 | # ARG MAVEN_MIRROR_URL=http://192.168.0.105:8081/nexus/content/groups/public 8 | 9 | RUN /usr/local/bin/entrypoint-run.sh mvn -DskipTests clean package -Pnative 10 | 11 | FROM registry.fedoraproject.org/fedora-minimal 12 | 13 | COPY --from=builder /project/target/prime-generator-runner /app 14 | 15 | ENTRYPOINT [ "/app" ] 16 | CMD [ "-Dquarkus.http.host=0.0.0.0","-Dquarkus.http.port=8080" ] 17 | -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/src/main/docker/Dockerfile.jvm: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode 3 | # 4 | # Before building the docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/prime-generator-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/prime-generator-jvm 15 | # 16 | ### 17 | FROM fabric8/java-jboss-openjdk8-jdk 18 | ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 19 | COPY target/lib/* /deployments/lib/ 20 | COPY target/*-runner.jar /deployments/app.jar 21 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/src/main/java/org/workspace7/primegen/PrimeGenerateResource.java: -------------------------------------------------------------------------------- 1 | package org.workspace7.primegen; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import javax.inject.Inject; 6 | import javax.ws.rs.*; 7 | import javax.ws.rs.core.MediaType; 8 | import javax.ws.rs.core.Response; 9 | import static java.util.concurrent.TimeUnit.SECONDS; 10 | 11 | @Path("/") 12 | public class PrimeGenerateResource { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger(PrimeGenerateResource.class); 15 | 16 | 17 | @Inject 18 | PrimeService primeService; 19 | 20 | @GET 21 | @Produces(MediaType.TEXT_PLAIN) 22 | @Path("/") 23 | public Response getPrimes(@QueryParam("upto") int upto, @QueryParam("sleep") int sleepInSeconds, 24 | @QueryParam("memload") int memLoad) { 25 | 26 | LOGGER.info("Query Parameters Upto {} Sleep in seconds {} Memory Load {} ", upto, 27 | sleepInSeconds, memLoad); 28 | 29 | if (sleepInSeconds != 0) { 30 | sleepInSeconds(sleepInSeconds); 31 | } 32 | 33 | if (memLoad != 0) { 34 | loadMemory(memLoad); 35 | } 36 | 37 | if (upto <= 1) { 38 | return Response.serverError() 39 | .entity(String.format("Value should be greater than 1 but recevied %d", upto)).build(); 40 | } 41 | 42 | int bigPrime = primeService.biggestPrime(upto); 43 | 44 | return Response.ok(bigPrime).build(); 45 | } 46 | 47 | @GET 48 | @Produces(MediaType.TEXT_PLAIN) 49 | @Path("/healthz") 50 | public Response hello() { 51 | return Response.ok().build(); 52 | } 53 | 54 | /** 55 | * @param size 56 | */ 57 | private void loadMemory(int size) { 58 | byte[] b = new byte[size]; 59 | b[0] = 1; 60 | b[b.length - 1] = 1; 61 | LOGGER.info("Allocated memory {} mb", size); 62 | } 63 | 64 | /** 65 | * @param seconds 66 | */ 67 | private void sleepInSeconds(int seconds) { 68 | try { 69 | SECONDS.sleep(seconds); 70 | LOGGER.info("Slept for {} seconds", seconds); 71 | } catch (InterruptedException e) { 72 | 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/src/main/java/org/workspace7/primegen/PrimeService.java: -------------------------------------------------------------------------------- 1 | package org.workspace7.primegen; 2 | 3 | import java.util.*; 4 | import javax.enterprise.context.ApplicationScoped; 5 | 6 | /** 7 | * PrimeService 8 | * Generate biggest prime number based on https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes 9 | */ 10 | @ApplicationScoped 11 | public class PrimeService { 12 | 13 | /** 14 | * 15 | * @param within 16 | * @return 17 | */ 18 | public Integer biggestPrime(int within) { 19 | double sqrtN = Math.sqrt(within); 20 | 21 | // Prime booleans 22 | boolean[] isPrime = new boolean[within]; 23 | 24 | for (int i = 2; i < within; i++) { 25 | isPrime[i] = true; 26 | } 27 | 28 | for (int i = 2; i <= sqrtN; i++) { 29 | if (isPrime[i]) { 30 | int j = i * i; 31 | while (j < within) { 32 | isPrime[j] = false; 33 | j += i; 34 | } 35 | } 36 | } 37 | 38 | isPrime[2] = true; 39 | isPrime[3] = true; 40 | 41 | final List primes = new ArrayList<>(); 42 | 43 | for (int i = 2; i < isPrime.length; i++) { 44 | if (isPrime[i]) { 45 | primes.add(i); 46 | } 47 | } 48 | 49 | Optional optBig = primes.stream().max(Comparator.naturalOrder()); 50 | 51 | return optBig.get(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value 3 | -------------------------------------------------------------------------------- /apps/prime-generator/quarkus/src/test/java/demo/Demo.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | import java.util.stream.IntStream; 7 | 8 | /** 9 | * https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes 10 | */ 11 | public class Demo { 12 | 13 | public static void main(String[] args) { 14 | 15 | // Start 16 | int n = 30; 17 | 18 | double sqrtN = Math.sqrt(n); 19 | 20 | // Prime booleans 21 | boolean[] isPrime = new boolean[n]; 22 | 23 | for (int i = 2; i < n; i++) { 24 | isPrime[i] = true; 25 | } 26 | 27 | for (int i = 2; i <= sqrtN; i++) { 28 | if (isPrime[i]) { 29 | int j = i * i; 30 | while (j < n) { 31 | isPrime[j] = false; 32 | j += i; 33 | } 34 | } 35 | } 36 | 37 | isPrime[2] = true; 38 | isPrime[3] = true; 39 | 40 | List primes = new ArrayList<>(); 41 | 42 | for (int i = 2; i < isPrime.length; i++) { 43 | if (isPrime[i]) { 44 | primes.add(i); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /apps/prime-generator/springboot/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/rhdevelopers/quarkus-java-builder:graal-1.0.0-rc15 as builder 2 | COPY . /project 3 | 4 | # uncomment this to set the MAVEN_MIRROR_URL of your choice, to make faster builds 5 | # ARG MAVEN_MIRROR_URL= 6 | # e.g. 7 | # ARG MAVEN_MIRROR_URL=http://192.168.0.105:8081/nexus/content/groups/public 8 | 9 | RUN /usr/local/bin/entrypoint-run.sh mvn -DskipTests clean package 10 | 11 | FROM fabric8/java-jboss-openjdk8-jdk:1.5.4 12 | USER jboss 13 | ENV JAVA_APP_DIR=/deployments 14 | EXPOSE 8080 15 | COPY --from=builder /project/target/prime-generator.jar /deployments/ 16 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /apps/prime-generator/springboot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | org.workspce7.primegen 5 | prime-generator 6 | 0.0.1-SNAPSHOT 7 | prime-generator 8 | Demo project for Spring Boot 9 | 10 | 1.8 11 | 2.1.4.RELEASE 12 | 1.8 13 | 1.8 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-dependencies 20 | ${spring-boot.version} 21 | pom 22 | import 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-webflux 30 | 31 | 32 | org.slf4j 33 | slf4j-log4j12 34 | 35 | 36 | 37 | ${project.artifactId} 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | ${spring-boot.version} 43 | 44 | 45 | 46 | repackage 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /apps/prime-generator/springboot/src/main/java/org/workspce7/primegen/primegenerator/PrimeGenerateController.java: -------------------------------------------------------------------------------- 1 | package org.workspce7.primegen.primegenerator; 2 | 3 | import static java.util.concurrent.TimeUnit.SECONDS; 4 | import java.util.Optional; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | @RestController 15 | public class PrimeGenerateController { 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(PrimeGenerateController.class); 18 | 19 | 20 | @Autowired 21 | PrimeService primeService; 22 | 23 | @GetMapping("/") 24 | public ResponseEntity getPrimes(@RequestParam("upto") int upto, 25 | @RequestParam(name = "sleep", required = false) Optional sleepInSeconds, 26 | @RequestParam(name = "memload", required = false) Optional memLoad) { 27 | 28 | LOGGER.info("Query Parameters Upto {} Sleep in seconds {} Memory Load {} ", upto, 29 | sleepInSeconds, memLoad); 30 | 31 | if (sleepInSeconds.isPresent()) { 32 | sleepInSeconds(sleepInSeconds.get()); 33 | } 34 | 35 | if (memLoad.isPresent()) { 36 | loadMemory(memLoad.get()); 37 | } 38 | 39 | if (upto <= 1) { 40 | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) 41 | .body(String.format("Value should be greater than 1 but recevied %d", upto)); 42 | } 43 | 44 | int bigPrime = primeService.biggestPrime(upto); 45 | 46 | return ResponseEntity.ok().body(String.valueOf(bigPrime)); 47 | } 48 | 49 | @GetMapping("/healthz") 50 | public ResponseEntity healthz() { 51 | return ResponseEntity.ok().body("OK"); 52 | } 53 | 54 | /** 55 | * @param size 56 | */ 57 | private void loadMemory(int size) { 58 | byte[] b = new byte[size]; 59 | b[0] = 1; 60 | b[b.length - 1] = 1; 61 | LOGGER.info("Allocated memory {} mb", size); 62 | } 63 | 64 | /** 65 | * @param seconds 66 | */ 67 | private void sleepInSeconds(int seconds) { 68 | try { 69 | SECONDS.sleep(seconds); 70 | LOGGER.info("Slept for {} seconds", seconds); 71 | } catch (InterruptedException e) { 72 | 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /apps/prime-generator/springboot/src/main/java/org/workspce7/primegen/primegenerator/PrimeGeneratorApplication.java: -------------------------------------------------------------------------------- 1 | package org.workspce7.primegen.primegenerator; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PrimeGeneratorApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PrimeGeneratorApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /apps/prime-generator/springboot/src/main/java/org/workspce7/primegen/primegenerator/PrimeService.java: -------------------------------------------------------------------------------- 1 | package org.workspce7.primegen.primegenerator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Comparator; 5 | import java.util.List; 6 | import java.util.Optional; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * PrimeService Generate biggest prime number based on 11 | * https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes 12 | */ 13 | @Service 14 | public class PrimeService { 15 | 16 | /** 17 | * 18 | * @param within 19 | * @return 20 | */ 21 | public Integer biggestPrime(int within) { 22 | double sqrtN = Math.sqrt(within); 23 | 24 | // Prime booleans 25 | boolean[] isPrime = new boolean[within]; 26 | 27 | for (int i = 2; i < within; i++) { 28 | isPrime[i] = true; 29 | } 30 | 31 | for (int i = 2; i <= sqrtN; i++) { 32 | if (isPrime[i]) { 33 | int j = i * i; 34 | while (j < within) { 35 | isPrime[j] = false; 36 | j += i; 37 | } 38 | } 39 | } 40 | 41 | isPrime[2] = true; 42 | isPrime[3] = true; 43 | 44 | final List primes = new ArrayList<>(); 45 | 46 | for (int i = 2; i < isPrime.length; i++) { 47 | if (isPrime[i]) { 48 | primes.add(i); 49 | } 50 | } 51 | 52 | Optional optBig = primes.stream().max(Comparator.naturalOrder()); 53 | 54 | return optBig.get(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /apps/prime-generator/springboot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bin/call.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | set -o pipefail 5 | 6 | KSVC_NAME=${1:-'greeter'} 7 | 8 | CURR_CTX=$(kubectl config current-context) 9 | 10 | CURR_NS="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${CURR_CTX}\")].context.namespace}")" \ 11 | || exit_err "error getting current namespace" 12 | 13 | if [[ -z "${CURR_NS}" ]]; 14 | then 15 | CURR_NS='default' 16 | else 17 | CURR_NS="${CURR_NS}" 18 | fi 19 | 20 | # HOST_HEADER="Host:$KSVC_NAME.$CURR_NS.example.com" 21 | #KSVC_HOST="$KSVC_NAME.$CURR_NS.$(minikube -p knativetutorial ip).nip.io" 22 | KSVC_HOST="$(kubectl get ksvc $KSVC_NAME -o jsonpath='{.status.url}')" 23 | 24 | if [ $# -le 1 ] 25 | then 26 | http GET "$KSVC_HOST" 27 | else 28 | echo "$2" | http --body POST "$KSVC_HOST" 29 | fi 30 | 31 | exit_err() { 32 | echo >&2 "${1}" 33 | exit 1 34 | } 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /bin/clean-completed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Deleting completed pods" 4 | kubectl delete pods --field-selector=status.phase=Succeeded 5 | 6 | echo "Deleting failed pods" 7 | kubectl delete pods --field-selector=status.phase=Failed 8 | -------------------------------------------------------------------------------- /bin/kafka-consumer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | trap '{ echo "" ; exit 1; }' INT 5 | 6 | KAFKA_TOPIC=${1:-'my-topic'} 7 | KAFKA_CLUSTER_NS=${2:-'kafka'} 8 | KAFKA_CLUSTER_NAME=${3:-'my-cluster'} 9 | 10 | kubectl -n $KAFKA_CLUSTER_NS run kafka-consumer -ti \ 11 | --image=quay.io/strimzi/kafka:0.26.1-kafka-3.0.0 \ 12 | --rm=true --restart=Never \ 13 | -- bin/kafka-console-consumer.sh \ 14 | --bootstrap-server $KAFKA_CLUSTER_NAME-$KAFKA_CLUSTER_NS-bootstrap:9092 \ 15 | --topic $KAFKA_TOPIC --from-beginning 16 | -------------------------------------------------------------------------------- /bin/kafka-list-topics.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | trap '{ echo "" ; exit 1; }' INT 5 | 6 | KAFKA_CLUSTER_NS=${1:-'kafka'} 7 | KAFKA_CLUSTER_NAME=${2:-'my-cluster'} 8 | 9 | #pod_number=$(shuf -i 0-1 -n 1) 10 | kubectl exec -it "$KAFKA_CLUSTER_NAME-kafka-0" \ 11 | -n $KAFKA_CLUSTER_NS \ 12 | -- ./bin/kafka-topics.sh \ 13 | --list \ 14 | --bootstrap-server localhost:9092 15 | -------------------------------------------------------------------------------- /bin/kafka-producer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | trap '{ echo "" ; exit 1; }' INT 5 | 6 | KAFKA_TOPIC=${1:-'my-topic'} 7 | KAFKA_CLUSTER_NS=${2:-'kafka'} 8 | KAFKA_CLUSTER_NAME=${3:-'my-cluster'} 9 | 10 | 11 | kubectl -n $KAFKA_CLUSTER_NS run kafka-producer -ti \ 12 | --image=quay.io/strimzi/kafka:0.26.1-kafka-3.0.0 \ 13 | --rm=true --restart=Never \ 14 | -- bin/kafka-console-producer.sh\ 15 | --broker-list $KAFKA_CLUSTER_NAME-$KAFKA_CLUSTER_NS-bootstrap:9092 \ 16 | --topic $KAFKA_TOPIC 17 | -------------------------------------------------------------------------------- /bin/kind-cluster-config.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | - role: worker 6 | extraPortMappings: 7 | - containerPort: 80 8 | hostPort: 80 9 | listenAddress: 0.0.0.0 10 | - containerPort: 443 11 | hostPort: 443 12 | listenAddress: 0.0.0.0 13 | containerdConfigPatches: 14 | - |- 15 | [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${CONTAINER_REGISTRY_PORT}"] 16 | endpoint = ["http://${CONTAINER_REGISTRY_NAME}:${CONTAINER_REGISTRY_PORT}"] 17 | [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${CONTAINER_REGISTRY_NAME}:${CONTAINER_REGISTRY_PORT}"] 18 | endpoint = ["http://${CONTAINER_REGISTRY_NAME}:${CONTAINER_REGISTRY_PORT}"] 19 | -------------------------------------------------------------------------------- /bin/load.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | KSVC_NAME=${1:-'prime-generator'} 4 | 5 | IP_ADDRESS="$(minikube ip):$(kubectl get svc kourier-external --namespace kourier-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')" 6 | 7 | CURR_CTX=$(kubectl config current-context) 8 | 9 | CURR_NS="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${CURR_CTX}\")].context.namespace}")" \ 10 | || exit_err "error getting current namespace" 11 | 12 | if [[ -z "${CURR_NS}" ]]; 13 | then 14 | CURR_NS="default" 15 | else 16 | CURR_NS="${CURR_NS}" 17 | fi 18 | 19 | HOST_HEADER="$KSVC_NAME.$CURR_NS.example.com" 20 | 21 | # Call the Knative prime-generator service with a load of 50 concurrent requests 22 | # to find biggest prime with 10000 23 | # allow each operation to sleep for 3 seconds 24 | # and each requests add a load of 100m 25 | hey -c 50 -z 10s \ 26 | -host "$HOST_HEADER" \ 27 | "http://$IP_ADDRESS/?sleep=3&upto=10000&memload=100" 28 | 29 | # Find the c#urrent namespace 30 | exit_err() { 31 | echo >&2 "${1}" 32 | exit 1 33 | } 34 | 35 | exit 0 -------------------------------------------------------------------------------- /bin/poll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | set -o pipefail 4 | 5 | trap '{ echo "" ; exit 1; }' INT 6 | 7 | KSVC_NAME=${1:-'greeter'} 8 | 9 | 10 | CURR_CTX=$(kubectl config current-context) 11 | 12 | CURR_NS="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${CURR_CTX}\")].context.namespace}")" \ 13 | || exit_err "error getting current namespace" 14 | 15 | if [[ -z "${CURR_NS}" ]]; 16 | then 17 | CURR_NS="default" 18 | else 19 | CURR_NS="${CURR_NS}" 20 | fi 21 | 22 | # HOST_HEADER="Host:$KSVC_NAME.$CURR_NS.example.com" 23 | KSVC_HOST="$KSVC_NAME.$CURR_NS.$(minikube -p knativetutorial ip).nip.io" 24 | 25 | 26 | while true 27 | do 28 | curl "$KSVC_HOST" 29 | sleep .5 30 | done 31 | 32 | exit_err() { 33 | echo >&2 "${1}" 34 | exit 1 35 | } 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /bin/start-kind-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | set -o errexit 5 | 6 | export CLUSTER_NAME=${CLUSTER_NAME:-knativetutorial} 7 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | 9 | # create registry container unless it already exists 10 | export CONTAINER_REGISTRY_NAME='kind-registry' 11 | export CONTAINER_REGISTRY_PORT='5000' 12 | 13 | running="$(docker inspect -f '{{.State.Running}}' "${CONTAINER_REGISTRY_NAME}" 2>/dev/null || true)" 14 | if [ "${running}" != 'true' ]; then 15 | docker run \ 16 | -d --restart=always -p "${CONTAINER_REGISTRY_PORT}:5000" --name "${CONTAINER_REGISTRY_NAME}" \ 17 | registry:2 18 | fi 19 | 20 | # create a cluster with the local registry enabled in containerd 21 | envsubst < ${CURRENT_DIR}/kind-cluster-config.yaml | kind create cluster \ 22 | --name="${CLUSTER_NAME}" --config=- 23 | 24 | # connect the registry to the cluster network only for new 25 | if [ "${running}" != 'true' ]; then 26 | docker network connect "kind" "${CONTAINER_REGISTRY_NAME}" 27 | fi 28 | 29 | ## Label nodes for using registry 30 | # tell https://tilt.dev to use the registry 31 | # https://docs.tilt.dev/choosing_clusters.html#discovering-the-registry 32 | for node in $(kind get nodes --name="$CLUSTER_NAME"); do 33 | kubectl annotate node "${node}" \ 34 | "tilt.dev/registry=localhost:${CONTAINER_REGISTRY_PORT}" \ 35 | "tilt.dev/registry-from-cluster=${CONTAINER_REGISTRY_NAME}:${CONTAINER_REGISTRY_PORT}"; 36 | done 37 | 38 | ## Label worker nodes 39 | kubectl get nodes --no-headers -l '!node-role.kubernetes.io/master' -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}' | xargs -I{} kubectl label node {} node-role.kubernetes.io/worker='' 40 | 41 | ## Setup helm 42 | 43 | helm repo add stable https://kubernetes-charts.storage.googleapis.com/ 44 | helm repo update 45 | 46 | 47 | ################################### 48 | # Nginx Ingress 49 | ################################### 50 | 51 | ## Label Worker nodes as nginx ingress 52 | kubectl get nodes --no-headers -l '!node-role.kubernetes.io/master' -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}' | xargs -I{} kubectl label node {} nginx=ingresshost 53 | 54 | kubectl create ns ingress-nginx 55 | 56 | helm install ingress-nginx stable/nginx-ingress --namespace ingress-nginx \ 57 | --set controller.nodeSelector.nginx="ingresshost" \ 58 | --set rbac.create=true --set controller.image.pullPolicy="Always" \ 59 | --set controller.extraArgs.enable-ssl-passthrough="" \ 60 | --set controller.stats.enabled=true --set controller.service.type="ClusterIP" \ 61 | --set controller.kind="DaemonSet" --set controller.daemonset.useHostPort=true 62 | 63 | kubectl rollout status ds ingress-nginx-nginx-ingress-controller -n ingress-nginx 64 | kubectl rollout status deploy ingress-nginx-nginx-ingress-default-backend -n ingress-nginx -------------------------------------------------------------------------------- /bin/start-minikube.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | PROFILE_NAME=${PROFILE_NAME:-knativetutorial} 6 | MEMORY=${MEMORY:-8192} 7 | CPUS=${CPUS:-6} 8 | 9 | unamestr=$(uname) 10 | 11 | if [ "$unamestr" == "Darwin" ]; 12 | then 13 | minikube start -p "$PROFILE_NAME" \ 14 | --memory="$MEMORY" \ 15 | --driver=hyperkit \ 16 | --cpus="$CPUS" \ 17 | --kubernetes-version=v1.23.0 \ 18 | --disk-size=50g \ 19 | --insecure-registry='10.0.0.0/24' 20 | else 21 | minikube start -p "$PROFILE_NAME" \ 22 | --memory="$MEMORY" \ 23 | --cpus="$CPUS" \ 24 | --kubernetes-version=v1.23.0 \ 25 | --disk-size=50g \ 26 | --insecure-registry='10.0.0.0/24' 27 | fi 28 | -------------------------------------------------------------------------------- /dev-site.yml: -------------------------------------------------------------------------------- 1 | runtime: 2 | cache_dir: ./.cache/antora 3 | 4 | site: 5 | title: Knative Tutorial 6 | url: https://redhat-developer-demos.github.io/knative-tutorial 7 | start_page: knative-tutorial::index.adoc 8 | 9 | content: 10 | sources: 11 | - url: . 12 | branches: HEAD 13 | start_path: documentation 14 | asciidoc: 15 | attributes: 16 | tutorial-namespace: knativetutorial 17 | branch: master 18 | workshop-domain: guru.devx.red 19 | minikube-version: v1.28.0 20 | openshift-version: v4.8 21 | kubernetes-version: v1.23.0 22 | knative-version: v1.8.1 23 | knative-serving-version: v1.8.3 24 | net-kourier-version: v1.8.1 25 | knative-eventing-version: v1.8.5 26 | knative-sources-version: v1.1.0 27 | kn-client-version: v1.8.1 28 | camel-source-version: v0.24.0 29 | kafka-source-version: v1.8.1 30 | kamel-version: 1.11.0 31 | kubernetes-cli: kubectl 32 | release-version: master 33 | page-pagination: true 34 | openshift-console-url: https://console-openshift-console.apps.example.com 35 | etherpad-url: http://example.com 36 | repo-base: https://github.com/redhat-developer-demos/knative-tutorial 37 | extensions: 38 | - ./lib/remote-include-processor.js 39 | - ./lib/tab-block.js 40 | ui: 41 | bundle: 42 | url: https://github.com/redhat-developer-demos/rhd-tutorial-ui/releases/download/v0.1.9/ui-bundle.zip 43 | snapshot: true 44 | supplemental_files: ./supplemental-ui 45 | output: 46 | dir: ./gh-pages 47 | -------------------------------------------------------------------------------- /documentation/antora.yml: -------------------------------------------------------------------------------- 1 | name: knative-tutorial 2 | title: Knative Tutorial 3 | version: master 4 | nav: 5 | - modules/ROOT/nav.adoc 6 | start_page: ROOT:index.adoc 7 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/assets/images/knative-cookbook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/ROOT/assets/images/knative-cookbook.png -------------------------------------------------------------------------------- /documentation/modules/ROOT/nav.adoc: -------------------------------------------------------------------------------- 1 | .xref:setup:setup.adoc[Setup] 2 | include::ROOT:partial$setup-nav.adoc[] 3 | 4 | .xref:serving:index.adoc[Knative Serving] 5 | include::ROOT:partial$serving-nav.adoc[] 6 | 7 | .xref:eventing:index.adoc[Knative Eventing] 8 | include::ROOT:partial$eventing-nav.adoc[] 9 | 10 | .xref:camelk:index.adoc[Apache Camel K] 11 | include::ROOT:partial$camelk-nav.adoc[] 12 | 13 | .xref:advanced:index.adoc[Advanced] 14 | include::ROOT:partial$advanced-nav.adoc[] 15 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/advanced-nav.adoc: -------------------------------------------------------------------------------- 1 | * Knative Eventing 2 | ** xref:advanced:deploy-apache-kafka.adoc[Deploy Apache Kafka] 3 | *** xref:advanced:deploy-apache-kafka.adoc#create-kafka-topic[Create Topic] 4 | *** xref:advanced:deploy-apache-kafka.adoc#kafka-producer[Run Producer] 5 | *** xref:advanced:deploy-apache-kafka.adoc#kafka-consumer[Run Consumer] 6 | ** xref:advanced:eventing-with-kafka.adoc[Knative Eventing with Apache Kafka] 7 | *** xref:advanced:eventing-with-kafka.adoc#kn-eventing-kafka-source[Deploy KafkaSource] 8 | *** xref:advanced:eventing-with-kafka.adoc#kn-eventing-adv-default-knative-channel[Kafka Knative Channel] 9 | *** xref:advanced:eventing-with-kafka.adoc#kn-eventing-kafka-source-to-sink[Kafka Source to Sink] 10 | *** xref:advanced:eventing-with-kafka.adoc#kn-eventing-kafka-auto-scaling[Auto Scaling with Kafka] 11 | ** xref:advanced:eventing-with-kafka.adoc#kn-kafka-src-cleanup[Cleanup] 12 | * EIP with Apache Camel K 13 | ** xref:advanced:camel-k-cbr.adoc[Content Based Routing] 14 | *** xref:advanced:camel-k-cbr.adoc#cbr-app-overview[Application Overview] 15 | *** xref:advanced:camel-k-cbr.adoc#label-namespace-for-default-broker[Create Broker] 16 | *** xref:advanced:camel-k-cbr.adoc#camel-k-cbr-data-producer[Deploy Data Producer] 17 | *** xref:advanced:camel-k-cbr.adoc#camel-k-cbr-data-processor[Deploy Data Processor] 18 | *** xref:advanced:camel-k-cbr.adoc#camel-k-cbr-event-subscriber[Deploy Event Subscriber] 19 | *** xref:advanced:camel-k-cbr.adoc#camel-k-cbr-event-filter[Apply Knative Filter] 20 | *** xref:advanced:camel-k-cbr.adoc#verify-e2e[Verify End to End] 21 | *** xref:advanced:camel-k-cbr.adoc#kamel-cbr-cleanup[Cleanup] 22 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/camelk-nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:camelk:setup.adoc[Setup] 2 | ** xref:camelk:setup.adoc#install-camel-k[Install Apache Camel K ] 3 | * xref:camelk:camel-k-basics.adoc[Camel K with Knative Serving] 4 | ** xref:camelk:camel-k-basics.adoc#deploy-camel-k-integration[Deploy Camel K integration] 5 | ** xref:camelk:camel-k-basics.adoc#deploy-camel-k-kn-integration[Deploy Camel K Knative Integration] 6 | ** xref:camelk:camel-k-basics.adoc#camelk-gs-cleanup[Cleanup] 7 | * xref:camelk:camel-k-eventing.adoc[Camel K with Knative Eventing] 8 | ** xref:camelk:camel-k-eventing.adoc#deploy-camel-k-source[Install the kn kamelet source plugin] 9 | ** xref:camelk:camel-k-eventing.adoc#logging-ce-messages[View CloudEvents Messages] 10 | ** xref:camelk:camel-k-eventing.adoc#camel-k-es-sink[Kamelet as source for a Knative Eventing Sink] 11 | ** xref:camelk:camel-k-eventing.adoc#camelk-eventing-cleanup[Cleanup] 12 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/deploy-knative-resources.adoc: -------------------------------------------------------------------------------- 1 | ifndef::workshop[] 2 | ===== 3 | 4 | [tabs] 5 | ==== 6 | kubectl:: 7 | + 8 | -- 9 | [#{doc-sec}-kn-resources-apply] 10 | [source,bash,subs="+macros,+attributes"] 11 | ---- 12 | kubectl apply -n {tutorial-namespace} -f link:{url}[{url-alt-text}] 13 | ---- 14 | copyToClipboard::{doc-sec}-kn-resources-apply[] 15 | -- 16 | oc:: 17 | + 18 | -- 19 | endif::[] 20 | [#{doc-sec}-oc-kn-resources-apply] 21 | [source,bash,subs="+macros,+attributes"] 22 | ---- 23 | oc apply -n {tutorial-namespace} -f link:{url}[{url-alt-text}] 24 | ---- 25 | copyToClipboard::{doc-sec}-oc-kn-resources-apply[] 26 | ifndef::workshop[] 27 | -- 28 | ==== 29 | 30 | ===== 31 | endif::[] -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/eventing-nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:eventing:eventing.adoc#eventing-prerequisite[Prerequisites] 2 | * xref:eventing:eventing.adoc#eventing-watch-logs[Watching Logs] 3 | * xref:eventing:eventing-src-to-sink.adoc[Source to Sink] 4 | ** xref:eventing:eventing-src-to-sink.adoc#eventing-source[Event Source] 5 | ** xref:eventing:eventing-src-to-sink.adoc#eventing-sink-service[Sink Service] 6 | ** xref:eventing:eventing-src-to-sink.adoc#eventing-create-event-source[Create Event Source] 7 | ** xref:eventing:eventing-src-to-sink.adoc#eventing-verify-event-source[Verify] 8 | ** xref:eventing:eventing-src-to-sink.adoc#eventing-see-what-you-have-deployed[See What You Have Deployed] 9 | ** xref:eventing:eventing-src-to-sink.adoc#eventing-cleanup[Cleanup] 10 | 11 | * xref:eventing:channel-and-subscribers.adoc[Channel and Subscribers] 12 | ** xref:eventing:channel-and-subscribers.adoc#eventing-channel[Channel] 13 | *** xref:eventing:channel-and-subscribers.adoc#eventing-create-event-channel[Create Event Channel] 14 | *** xref:eventing:channel-and-subscribers.adoc#eventing-verify-event-channel[Verify] 15 | ** xref:eventing:channel-and-subscribers.adoc#eventing-source[Event Source] 16 | *** xref:eventing:channel-and-subscribers.adoc#eventing-create-event-source[Create Event Source] 17 | *** xref:eventing:channel-and-subscribers.adoc#eventing-verify-event-source[Verify] 18 | ** xref:eventing:channel-and-subscribers.adoc#eventing-subscriber[Event Subscriber] 19 | *** xref:eventing:channel-and-subscribers.adoc#eventing-create-subscriber[Create Event Subscriber] 20 | *** xref:eventing:channel-and-subscribers.adoc#eventing-verify-subscriber[Verify] 21 | ** xref:eventing:channel-and-subscribers.adoc#eventing-see-what-you-have-deployed[See What You Have Deployed] 22 | ** xref:eventing:channel-and-subscribers.adoc#eventing-cleanup[Cleanup] 23 | 24 | * xref:eventing:eventing-trigger-broker.adoc[Brokers and Triggers] 25 | ** xref:eventing:eventing-trigger-broker.adoc#events-triggers-brokers[Events, Triggers and Brokers] 26 | ** xref:eventing:eventing-trigger-broker.adoc#broker[Broker] 27 | ** xref:eventing:eventing-trigger-broker.adoc#eventing-service[Service] 28 | ** xref:eventing:eventing-trigger-broker.adoc#eventing-event-source[Event Source] 29 | ** xref:eventing:eventing-trigger-broker.adoc#eventing-trigger[Trigger] 30 | ** xref:eventing:eventing-trigger-broker.adoc#eventing-trigger-verification[Verification] 31 | ** xref:eventing:eventing-trigger-broker.adoc#eventing-cleanup[Cleanup] -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/invoke-service.adoc: -------------------------------------------------------------------------------- 1 | [k8s-env=''] 2 | [k8s-cli=''] 3 | [doc-sec=''] 4 | 5 | #tag::env[] 6 | 7 | [#{doc-sec}-{k8s-cli}-svc-gateway-env] 8 | [source,bash,subs="+macros,+attributes"] 9 | ---- 10 | IP_ADDRESS="$({k8s-env} ip):$({k8s-cli} get svc istio-ingressgateway --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')" 11 | ---- 12 | copyToClipboard::{doc-sec}-{k8s-cli}-svc-gateway-env[] 13 | 14 | #end::env[] 15 | 16 | #tag::call[] 17 | 18 | [#{doc-sec}-{k8s-cli}-svc-call] 19 | [source,bash,subs="+macros,+attributes"] 20 | ---- 21 | http $IP_ADDRESS 'Host:greeter.knativetutorial.example.com' 22 | ---- 23 | 24 | copyToClipboard::{doc-sec}-{k8s-cli}-svc-call[] 25 | 26 | #end::call[] 27 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/prereq-cli.adoc: -------------------------------------------------------------------------------- 1 | 2 | The following checks ensure that each chapter exercises are done with the right environment settings. 3 | 4 | [tabs] 5 | ==== 6 | Minikube:: 7 | + 8 | -- 9 | * Set your local docker to use minikube docker daemon 10 | 11 | [source,bash,subs="+macros,+attributes"] 12 | ---- 13 | eval $(minikube docker-env) 14 | ---- 15 | 16 | * Kubernetes should be `{kubernetes-version}` 17 | 18 | [#kubectl-version] 19 | [source,bash,subs="+macros,+attributes"] 20 | ---- 21 | kubectl version 22 | ---- 23 | copyToClipboard::kubectl-version[] 24 | -- 25 | Minishift:: 26 | + 27 | -- 28 | * Set your local docker to use minishift docker daemon 29 | 30 | [#minishift-set-env] 31 | [source,bash,subs="+macros,+attributes"] 32 | ---- 33 | eval $(minishift docker-env) 34 | ---- 35 | copyToClipboard::minishift-set-env[] 36 | 37 | * OpenShift CLI should be v3.11.0+ 38 | 39 | [#oc-version] 40 | [source,bash,subs="+macros,+attributes"] 41 | ---- 42 | eval $(minishift oc-env) 43 | oc version 44 | ---- 45 | copyToClipboard::oc-version[] 46 | 47 | * Make sure to be on `knativetutorial` OpenShift project 48 | 49 | [#right-openshift-project] 50 | [source,bash,subs="+macros,+attributes"] 51 | ---- 52 | oc project -q 53 | ---- 54 | copyToClipboard::right-openshift-project[] 55 | 56 | If you are not on `{tutorial-namespace}` project, then run following command to change to `{tutorial-namespace}` project: 57 | 58 | [#change-to-openshift-project] 59 | [source,bash,subs="+macros,+attributes"] 60 | ---- 61 | oc project {tutorial-namespace} 62 | ---- 63 | copyToClipboard::change-to-openshift-project[] 64 | -- 65 | ==== 66 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/set-env-vars.adoc: -------------------------------------------------------------------------------- 1 | .Environment Variables 2 | 3 | [cols="4*^,4*."] 4 | |=== 5 | |**Variable** |**Description** |**Default Value** | **e.g.** 6 | 7 | |REGISTRY_USERNAME 8 | |The Container Registry User Id that will be used to authenticate against the container registry `$REGISTRY_URL` 9 | | 10 | |demo 11 | 12 | |REGISTRY_PASSWORD 13 | |The Container Registry User Password that will be used to authenticate against the container registry `$REGISTRY_URL` 14 | | 15 | |demopassword 16 | 17 | |REGISTRY_URL 18 | |The Container Registry URL, defaults to https://index.docker.io 19 | |https://index.docker.io 20 | |https://quay.io/v2 21 | 22 | |DESTINATION_IMAGE_NAME 23 | |The fully qualified image name that will be built 24 | | 25 | | quay.io/foo/bar:v1.0 26 | |=== -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/setup-nav.adoc: -------------------------------------------------------------------------------- 1 | ** xref:setup:setup.adoc#download-tutorial-sources[Tutorial Sources] 2 | ** xref:setup:setup.adoc#tools[Tutorial Tools] 3 | ** xref:setup:kubernetes-cluster.adoc#kubernetes-cluster[Choose your Kubernetes Cluster] 4 | *** xref:setup:minikube.adoc[Minikube] 5 | **** xref:setup:minikube.adoc#start-minikube[Configure and Start Minikube] 6 | **** xref:setup:minikube.adoc#minikube-deploy-registry[Deploy Registry] 7 | **** xref:setup:minikube.adoc#install-knative-serving[Install Knative Serving] 8 | **** xref:setup:minikube.adoc#install-kourier-ingress-gateway[Install Kourier Ingress Gateway] 9 | **** xref:setup:minikube.adoc#install-ingress-controller[Install Ingress Controller] 10 | **** xref:setup:minikube.adoc#install-knative-eventing[Install Knative Eventing] 11 | **** xref:setup:minikube.adoc#create-tutorial-namespace[Create Tutorial Namespace] 12 | *** xref:setup:openshift.adoc[OpenShift] -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/_partials/watching-logs.adoc: -------------------------------------------------------------------------------- 1 | [kube-ns='knativetutorial'] 2 | [kube-svc=''] 3 | 4 | Since a Cron job source is used in this section of the tutorial, it would emit events every minute. We can watch the logs of the service to see the messages delivered. 5 | 6 | The logs could be watched using the command: 7 | [tabs] 8 | ==== 9 | kubectl:: 10 | + 11 | -- 12 | [source,bash,subs="+macros,+attributes"] 13 | ---- 14 | kubectl logs -n {kube-ns} -f -c user-container 15 | ---- 16 | -- 17 | oc:: 18 | + 19 | -- 20 | 21 | [source,bash,subs="+macros,+attributes"] 22 | ---- 23 | oc logs -n {kube-ns} -f -c user-container 24 | ---- 25 | -- 26 | ==== 27 | 28 | [TIP] 29 | ==== 30 | * Using stern with the command `stern -n {kube-ns} {kube-svc}`, to filter the logs further add `-c user-container` to the stern command. 31 | 32 | [source,bash,subs="+macros,+attributes"] 33 | ---- 34 | stern -n {kube-ns} -c user-container {kube-svc} 35 | ---- 36 | ==== 37 | -------------------------------------------------------------------------------- /documentation/modules/ROOT/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Knative Tutorial 2 | :page-layout: home 3 | :!sectids: 4 | 5 | [cols="3a,2a"] 6 | |=== 7 | a|**** 8 | Deploying applications as Serverless services is becoming a popular architectural style. It seems like many organizations assume that _Functions as a Service (FaaS)_ is serverless. But we think it is more accurate to say that FaaS is one way to do serverless, not the only way. This raises a super critical question for enterprises that may have applications which could be monolith or a microservice: What is the easiest path to serverless application deployment? 9 | 10 | The answer is a platform that can run serverless workloads, while enabling you to have complete control how to configure, build, deploy and run. Ideally, the platform that supports deploying the applications as linux containers. In this chapter we introduce you to one such platform -- https://knative.dev[Knative] --, that helps you to run the serverless workloads in a Kubernetes-native way. 11 | **** 12 | a|[caption="Knative Cookbook",link="https://developers.redhat.com/books/knative-cookbook/"] 13 | image::knative-cookbook.png[Knative Cookbook,300,300] 14 | | 15 | |=== 16 | 17 | == Get started with your serverless journey 18 | [cols="3a,3a",frame=none,grid=rows,stripe] 19 | |=== 20 | a| 21 | [.tile] 22 | .xref:setup:setup.adoc[Setup] 23 | * xref:setup:setup.adoc[Deploy] 24 | * xref:serving:knative-client.adoc[Knative Client] 25 | a| 26 | [.tile] 27 | .xref:serving:index.adoc[Knative Serving] 28 | * xref:serving:basic-fundas.adoc[Serving] 29 | * xref:serving:scaling.adoc[Auto Scaling] 30 | * xref:serving:traffic-distribution.adoc[Traffic Distribution] 31 | a| 32 | [.tile] 33 | .xref:eventing:index.adoc[Knative Eventing] 34 | *** xref:eventing:eventing-src-to-sink.adoc[Source to Sink] 35 | *** xref:eventing:channel-and-subscribers.adoc[Channel and Subscribers] 36 | *** xref:eventing:eventing-trigger-broker.adoc[Brokers and Triggers] 37 | | 38 | ifndef::workshop[] 39 | a| 40 | [.tile] 41 | .xref:camelk:index.adoc[Apache Camel K] 42 | * xref:camelk:setup.adoc[Setup] 43 | * xref:camelk:camel-k-basics.adoc#deploy-camel-k-kn-integration[Camel K with Knative Serving] 44 | * xref:camelk:camel-k-eventing.adoc[Camel K with Knative Eventing] 45 | * xref:camelk:camel-k-eventing.adoc#camel-k-es-sink[CamelSource to Sink] 46 | a| 47 | [.tile] 48 | .xref:advanced:index.adoc[Advanced] 49 | * xref:advanced:deploy-apache-kafka.adoc[Deploy Apache Kafka] 50 | * xref:advanced:eventing-with-kafka.adoc[Knative Eventing with Apache Kafka] 51 | * xref:advanced:camel-k-cbr.adoc[Content Based Routing with Camel K] 52 | endif::[] 53 | |=== -------------------------------------------------------------------------------- /documentation/modules/_attributes.adoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/_attributes.adoc -------------------------------------------------------------------------------- /documentation/modules/advanced/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :icons: font 2 | :stem: latexmath 3 | :source-highlighter: coderay 4 | :imagesdir: {moduledir}/assets/images 5 | -------------------------------------------------------------------------------- /documentation/modules/advanced/assets/images/cbr_app_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/advanced/assets/images/cbr_app_overview.png -------------------------------------------------------------------------------- /documentation/modules/advanced/assets/images/cbr_app_ui_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/advanced/assets/images/cbr_app_ui_empty.png -------------------------------------------------------------------------------- /documentation/modules/advanced/assets/images/cbr_app_ui_with_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/advanced/assets/images/cbr_app_ui_with_data.png -------------------------------------------------------------------------------- /documentation/modules/advanced/examples/kafka-topic-my-topic.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kafka.strimzi.io/v1beta1 2 | kind: KafkaTopic 3 | metadata: 4 | name: my-topic 5 | labels: 6 | strimzi.io/cluster: my-cluster 7 | spec: 8 | partitions: 10 9 | replicas: 1 10 | -------------------------------------------------------------------------------- /documentation/modules/advanced/nav.adoc: -------------------------------------------------------------------------------- 1 | * Knative Eventing 2 | ** xref:deploy-apache-kafka.adoc[Deploy Apache Kafka] 3 | *** xref:deploy-apache-kafka.adoc#create-kafka-topic[Create Topic] 4 | *** xref:deploy-apache-kafka.adoc#kafka-producer[Run Producer] 5 | *** xref:deploy-apache-kafka.adoc#kafka-consumer[Run Consumer] 6 | ** xref:eventing-with-kafka.adoc[Knative Eventing with Apache Kafka] 7 | *** xref:eventing-with-kafka.adoc#kn-eventing-kafka-source[Deploy KafkaSource] 8 | *** xref:eventing-with-kafka.adoc#kn-eventing-adv-default-knative-channel[Kafka Knative Channel] 9 | *** xref:eventing-with-kafka.adoc#kn-eventing-kafka-source-to-sink[Kafka Source to Sink] 10 | *** xref:eventing-with-kafka.adoc#kn-eventing-kafka-auto-scaling[Auto Scaling with Kafka] 11 | ** xref:eventing-with-kafka.adoc#kn-kafka-src-cleanup[Cleanup] 12 | * EIP with Apache Camel K 13 | ** xref:camel-k-cbr.adoc[Content Based Routing] 14 | *** xref:camel-k-cbr.adoc#cbr-app-overview[Application Overview] 15 | *** xref:camel-k-cbr.adoc#label-namespace-for-default-broker[Create Broker] 16 | *** xref:camel-k-cbr.adoc#camel-k-cbr-data-producer[Deploy Data Producer] 17 | *** xref:camel-k-cbr.adoc#camel-k-cbr-data-processor[Deploy Data Processor] 18 | *** xref:camel-k-cbr.adoc#camel-k-cbr-event-subscriber[Deploy Event Subscriber] 19 | *** xref:camel-k-cbr.adoc#camel-k-cbr-event-filter[Apply Knative Filter] 20 | *** xref:camel-k-cbr.adoc#verify-e2e[Verify End to End] 21 | *** xref:camel-k-cbr.adoc#kamel-cbr-cleanup[Cleanup] 22 | -------------------------------------------------------------------------------- /documentation/modules/advanced/pages/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :moduledir: .. 2 | :github-repo: https://github.com/redhat-developer-demos/knative-tutorial/blob/{branch} 3 | :advanced-module-github-repo-uri: https://github.com/redhat-developer-demos/knative-tutorial-advanced 4 | :advanced-github-repo-uri: https://github.com/redhat-developer-demos/knative-tutorial-advanced 5 | :advanced-github-re17po: {advanced-module-github-repo-uri}/blob/{branch} 6 | :kamel-version: 1.8.0 7 | :experimental: 8 | :maven-version: 3.6.3+ 9 | :strimzi-version: 0.32.0 10 | :camelk-repo: advanced/camel-k 11 | :eventing-repo: eventing 12 | :observability-repo: advanced/observability 13 | :minikube-nip-io: 192.168.64.13.nip.io 14 | :knative-kafka-repo: https://github.com/knative-sandbox/eventing-kafka 15 | -------------------------------------------------------------------------------- /documentation/modules/advanced/pages/_partials/adv-kubectl-queries.adoc: -------------------------------------------------------------------------------- 1 | #tag::kgpow[] 2 | [.console-input] 3 | [source,bash,subs="+quotes,+attributes,+macros"] 4 | ---- 5 | watch kubectl -n {tutorial-namespace} get pods 6 | ---- 7 | #end::kgpow[] 8 | 9 | #tag::kgksvc[] 10 | [.console-input] 11 | [source,bash,subs="+quotes,+attributes,+macros"] 12 | ---- 13 | kn -n {tutorial-namespace} service ls 14 | ---- 15 | #end::kgksvc[] -------------------------------------------------------------------------------- /documentation/modules/advanced/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Advanced 2 | include::_attributes.adoc[] 3 | 4 | This tutorial helps in undertanding some advanced concepts and application with Knative Serving, Eventing and Apache Camel-k 5 | 6 | [#camelk-tutorial-prerequisite] 7 | == Prerequisite 8 | As pre-requisite to this tutorial, its highly recommended that you have completed: 9 | 10 | * xref:ROOT:index.adoc[Knative Tutorial Basics] 11 | * xref:camelk:index.adoc[Integrations with Apache Camel K] 12 | 13 | -------------------------------------------------------------------------------- /documentation/modules/camelk/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :icons: font 2 | :stem: latexmath 3 | :source-highlighter: coderay 4 | :imagesdir: {moduledir}/assets/images 5 | -------------------------------------------------------------------------------- /documentation/modules/camelk/assets/images/kamelet-binding-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/camelk/assets/images/kamelet-binding-simple.png -------------------------------------------------------------------------------- /documentation/modules/camelk/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:camelk:setup.adoc[Setup] 2 | * xref:camelk:camel-k-basics.adoc[Camel K with Knative Serving] 3 | ** xref:camelk:camel-k-basics.adoc#deploy-camel-k-integration[Deploy Camel K integration] 4 | ** xref:camelk:camel-k-basics.adoc#deploy-camel-k-kn-integration[Deploy Camel K Knative Integration] 5 | ** xref:camelk:camel-k-basics.adoc#camelk-gs-cleanup[Cleanup] 6 | * xref:camelk:camel-k-eventing.adoc[Camel K with Knative Eventing] 7 | ** xref:camelk:camel-k-eventing.adoc#install-camel-k-plugin[Install the kn kamelet source plugin] 8 | ** xref:camelk:camel-k-eventing.adoc#logging-ce-messages[View CloudEvents Messages] 9 | ** xref:camelk:camel-k-eventing.adoc#camel-k-es-sink[Custom Kamelet as source for a Knative Eventing Sink] 10 | ** xref:camelk:camel-k-eventing.adoc#camelk-eventing-cleanup[Cleanup] 11 | -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :moduledir: .. 2 | :github-repo: https://github.com/redhat-developer-demos/knative-tutorial/blob/{branch} 3 | :camelk-module-github-repo-uri: https://github.com/redhat-developer-demos/knative-tutorial-module-camelk 4 | :camelk-demos-github-repo-uri: https://github.com/redhat-developer-demos/knative-tutorial-camelk 5 | :camelk-demos-github-repo: {camelk-demos-github-repo-uri}/blob/{branch} 6 | :camelk-repo: advanced/camel-k 7 | :kamel-version: 1.11.0 8 | :experimental: 9 | :maven-version: 3.6.0+ 10 | :camel-source-version: v0.19.0 11 | :eventing-camel-repo: https://github.com/knative-sandbox/eventing-camel -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_partials/camel-k-k8s-objects.adoc: -------------------------------------------------------------------------------- 1 | #tag::integrations[] 2 | [tabs] 3 | ==== 4 | kubectl:: 5 | + 6 | -- 7 | [.console-input] 8 | [source,bash,subs="+macros,+attributes"] 9 | ---- 10 | kubectl -n {tutorial-namespace} get integrations.camel.apache.org 11 | ---- 12 | -- 13 | oc:: 14 | + 15 | -- 16 | [.console-input] 17 | [source,bash,subs="+macros,+attributes"] 18 | ----- 19 | oc -n {tutorial-namespace} get get integrations.camel.apache.org 20 | ----- 21 | -- 22 | ==== 23 | #end::integrations[] 24 | 25 | #tag::svc[] 26 | [tabs] 27 | ==== 28 | kubectl:: 29 | + 30 | -- 31 | [.console-input] 32 | [source,bash,subs="+macros,+attributes"] 33 | ---- 34 | kubectl -n {tutorial-namespace} get svc 35 | ---- 36 | -- 37 | oc:: 38 | + 39 | -- 40 | [.console-input] 41 | [source,bash,subs="+macros,+attributes"] 42 | ---- 43 | oc -n {tutorial-namespace} get svc 44 | ---- 45 | copyToClipboard::camelk-oc-get-k8s-svc[] 46 | -- 47 | ==== 48 | #end::svc[] 49 | 50 | #tag::deployments[] 51 | [tabs] 52 | ==== 53 | kubectl:: 54 | + 55 | -- 56 | [.console-input] 57 | [source,bash,subs="+macros,+attributes"] 58 | ---- 59 | kubectl -n {tutorial-namespace} get deployments 60 | ---- 61 | -- 62 | oc:: 63 | + 64 | -- 65 | [.console-input] 66 | [source,bash,subs="+macros,+attributes"] 67 | ---- 68 | oc -n {tutorial-namespace} get get deployments 69 | ---- 70 | -- 71 | ==== 72 | #end::deployments[] 73 | -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_partials/extras.adoc: -------------------------------------------------------------------------------- 1 | [k8s-cli=''] 2 | 3 | #tag::config-k8s-local-registry[] 4 | 5 | [.console-input] 6 | [source,bash,subs="+macros,+attributes"] 7 | ---- 8 | K8S_LOCAL_REGISTRY=`{k8s-cli} get svc -n kube-system registry -ojsonpath='{.spec.clusterIP}'` && \ 9 | val="pass:[${K8S_LOCAL_REGISTRY}]" && \ 10 | {k8s-cli} -n knative-serving get cm config-controller -oyaml \ 11 | | yq w - data.registriesSkippingTagResolving $val \ 12 | | {k8s-cli} apply -f - 13 | ---- 14 | 15 | #end::config-k8s-local-registry[] 16 | -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_partials/invoke-service.adoc: -------------------------------------------------------------------------------- 1 | [svc-name=''] 2 | [file-name=''] 3 | 4 | #tag::set-svc-url[] 5 | 6 | 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`: 7 | 8 | [tabs] 9 | ==== 10 | kubectl:: 11 | + 12 | -- 13 | [.console-input] 14 | [source,bash,subs="+macros,+attributes"] 15 | ---- 16 | SVC_URL=`kubectl -n {tutorial-namespace} get ksvc {svc-name} -o jsonpath='{.status.domain}'` 17 | ---- 18 | -- 19 | oc:: 20 | + 21 | -- 22 | [.console-input] 23 | [source,bash,subs="+macros,+attributes"] 24 | ---- 25 | SVC_URL=`oc -n {tutorial-namespace} get ksvc {svc-name} -o jsonpath='{.status.domain}'` 26 | ---- 27 | -- 28 | ==== 29 | #end::set-svc-url[] 30 | 31 | #tag::invoke-svc[] 32 | [.console-input] 33 | [source,bash,subs="+macros,+attributes"] 34 | ---- 35 | curl -v -H pass:["Host:${SVC_URL}"] -H 'fileName: {file-name}' $IP_ADDRESS 36 | ---- 37 | #end::invoke-svc[] -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_partials/kamel-objects-status.adoc: -------------------------------------------------------------------------------- 1 | [kube-ns=''] 2 | [it-name=''] 3 | 4 | #tag::integration-status[] 5 | [.console-input] 6 | [source,bash,subs="+macros,+attributes"] 7 | ---- 8 | {k8s-cli} -n {kube-ns} get integrations.camel.apache.org {it-name} 9 | ---- 10 | #end::integration-status[] 11 | -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_partials/source-code.adoc: -------------------------------------------------------------------------------- 1 | #tag::camel-k-demos[] 2 | All the demo sources that will be used in the chapters of this module are available under `pass:[$TUTORIAL_HOME]/{camelk-repo}` folder. 3 | 4 | [.console-input] 5 | [source,bash,subs="+macros,+attributes"] 6 | ----- 7 | cp pass:[$TUTORIAL_HOME]/{camelk-repo} 8 | ----- 9 | #end::camel-k-demos[] 10 | -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/_partials/wait-for-pods.adoc: -------------------------------------------------------------------------------- 1 | [kube-ns=''] 2 | 3 | #tag::wait-with-kubectl[] 4 | 5 | [NOTE] 6 | ==== 7 | It may take few minutes for pods to come up, you can watch the status of the pods as shown below. 8 | You can use kbd:[CTRL + c ] to terminate the watch 9 | ==== 10 | 11 | [tabs] 12 | ==== 13 | kubectl:: 14 | + 15 | -- 16 | [.console-input] 17 | [source,bash,subs="+macros,+attributes"] 18 | ---- 19 | kubectl -n {kube-ns} get pods -w 20 | ---- 21 | -- 22 | oc:: 23 | + 24 | -- 25 | [.console-input] 26 | [source,bash,subs="+macros,+attributes"] 27 | ---- 28 | oc -n {kube-ns} get pods -w 29 | ---- 30 | -- 31 | ==== 32 | 33 | #end::wait-with-kubectl[] 34 | 35 | #tag::wait-with-timeout[] 36 | 37 | Wait for the pods to be running: 38 | 39 | [source,bash,subs="+macros,+attributes"] 40 | ---- 41 | timeout 300 "kubectl get pods -n {kube-ns} 2>&1 | grep -v -E '(Running|Completed|STATUS)'" 42 | ---- 43 | 44 | **(OR)** 45 | 46 | [source,bash,subs="+macros,+attributes"] 47 | ---- 48 | timeout 300 "oc get pods -n {kube-ns} 2>&1 | grep -v -E '(Running|Completed|STATUS)'" 49 | ---- 50 | #end::wait-with-timeout[] 51 | 52 | -------------------------------------------------------------------------------- /documentation/modules/camelk/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Apache Camel K 2 | include::_attributes.adoc[] 3 | 4 | Within the average large IT organization, it is very rare that you would ever build a new application that would live in total isolation, one that would be completely detached from all other old or new systems. Many real time use cases demands, that the old and new systems share and exchange data. 5 | 6 | https://camel.apache.org[Apache Camel] is open source framework that helps you integrate systems. Apache Camel allows the integrated system to produce and consume data between them. It provides over 300 components that include https://camel.apache.org/components/latest/index.html[integration connectors] to sources such as TCP, ActiveMQ, FTP, Salesforce.com, which makes it easier to integrate heterogenous systems . https://www.enterpriseintegrationpatterns.com/[Enterprise Integration Patterns(EIP)] provides solutions to many common integration problems, Apache Camel provides implementations of these patterns via its rich https://camel.apache.org/manual/latest/dsl.html[Domain Specific Language(DSL)], thereby making it easier for the developers to apply the EIP easily. 7 | 8 | https://camel.apache.org/camel-k/latest/index.html[Apache Camel K] aims at simplifying the programming and deployment model for Apache Camel integrations. By working with Apache Camel K, the integration developers can now focus on writing their integrations using Camel DSL in Java,JavaScript,Groovy,XML or YAML, without the need to worry about how package and deploy them. 9 | 10 | Apache Camel K will enable you to craft a Kubernetes-native integration application. It also leverages serverless capabilities via Knative. 11 | 12 | [#camelk-tutorial-prerequisite] 13 | == Prerequisite 14 | As pre-requisite to this tutorial, its highly recommended that you have completed: 15 | 16 | * xref:serving:index.adoc[Knative Serving] 17 | * xref:eventing:index.adoc[Knative Eventing] 18 | 19 | == Camel K and Knative Serving 20 | 21 | With Camel K we can deploy Apache Camel Routes as Knative Serving services i.e. the Apache Camel routes will then be auto scalable with the ability to automatically scale down to zero when not needed. 22 | 23 | == Camel K and Knative Eventing 24 | With Camel K we can also exchange Knative Eventing events via Apache Camel endpoints;where the exchange messages (event payloads) are automatically transformed into https://cloudevents.io[ Cloud Events] format and exchanged with other consumers. -------------------------------------------------------------------------------- /documentation/modules/eventing/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :icons: font 2 | :stem: latexmath 3 | :source-highlighter: coderay 4 | :imagesdir: {moduledir}/assets/images 5 | -------------------------------------------------------------------------------- /documentation/modules/eventing/assets/images/brokers-triggers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/eventing/assets/images/brokers-triggers.png -------------------------------------------------------------------------------- /documentation/modules/eventing/assets/images/channels-subs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/eventing/assets/images/channels-subs.png -------------------------------------------------------------------------------- /documentation/modules/eventing/assets/images/che_env_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/eventing/assets/images/che_env_overview.png -------------------------------------------------------------------------------- /documentation/modules/eventing/assets/images/source-sink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/eventing/assets/images/source-sink.png -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/channel-subscriber.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghelloa 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghelloa-v1 #<1> 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.1 -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1beta1 2 | kind: Channel 3 | metadata: 4 | name: eventinghello-ch -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/curler.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | labels: 5 | run: curler 6 | name: curler 7 | spec: 8 | containers: 9 | - name: curler 10 | image: fedora:29 11 | tty: true -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/default-channel-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: default-ch-webhook 5 | namespace: knative-eventing 6 | data: 7 | default-ch-config: | 8 | clusterDefault: 9 | apiVersion: messaging.knative.dev/v1alpha1 10 | kind: InMemoryChannel 11 | namespaceDefaults: 12 | knativetutorial: 13 | apiVersion: messaging.knative.dev/v1alpha1 14 | kind: KafkaChannel 15 | spec: 16 | numPartitions: 2 17 | replicationFactor: 1 18 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/default-kafka-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: default-ch-webhook 5 | namespace: knative-eventing 6 | data: 7 | default-ch-config: | 8 | clusterDefault: 9 | apiVersion: messaging.knative.dev/v1alpha1 10 | kind: InMemoryChannel 11 | namespaceDefaults: 12 | chapter-4: 13 | apiVersion: messaging.knative.dev/v1alpha1 14 | kind: KafkaChannel 15 | spec: 16 | numPartitions: 1 17 | replicationFactor: 1 -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/event-source-broker.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.eventing.knative.dev/v1alpha1 2 | kind: ContainerSource 3 | metadata: 4 | name: heartbeat-event-source 5 | spec: 6 | image: quay.io/openshift-knative/knative-eventing-sources-heartbeats:v0.5.0 7 | args: 8 | - '--label="Thanks for doing Knative Tutorial"' 9 | - '--period=1' 10 | env: 11 | - name: POD_NAME 12 | valueFrom: 13 | fieldRef: 14 | fieldPath: metadata.name 15 | - name: POD_NAMESPACE 16 | valueFrom: 17 | fieldRef: 18 | fieldPath: metadata.namespace 19 | sink: 20 | apiVersion: eventing.knative.dev/v1alpha1 21 | kind: Broker 22 | name: default 23 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/event-source-svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.eventing.knative.dev/v1alpha1 2 | kind: CronJobSource 3 | metadata: 4 | name: event-greeter-cronjob-source 5 | spec: 6 | schedule: "* * * * *" 7 | data: '{"message": "Thanks for doing Knative Tutorial"}' 8 | sink: 9 | apiVersion: serving.knative.dev/v1 10 | kind: Service 11 | name: event-greeter 12 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/event-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1alpha2 2 | kind: PingSource 3 | metadata: 4 | name: event-greeter-ping-source 5 | spec: 6 | schedule: "*/2 * * * *" 7 | jsonData: '{"message": "Thanks for doing Knative Tutorial"}' 8 | sink: 9 | ref: 10 | apiVersion: messaging.knative.dev/v1beta1 11 | kind: Channel 12 | name: eventinghello-ch 13 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-aloha-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventingaloha 5 | spec: 6 | template: 7 | metadata: 8 | name: eventingaloha-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-bonjour-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventingbonjour 5 | spec: 6 | template: 7 | metadata: 8 | name: eventingbonjour-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-hello-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghello 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghello-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-helloa-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghelloa 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghelloa-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-helloa-sub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1beta1 2 | kind: Subscription 3 | metadata: 4 | name: eventinghelloa-sub 5 | spec: 6 | channel: 7 | apiVersion: messaging.knative.dev/v1beta1 8 | kind: Channel 9 | name: eventinghello-ch 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventinghelloa -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-hellob-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghellob 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghellob-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventing-hellob-sub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1beta1 2 | kind: Subscription 3 | metadata: 4 | name: eventinghellob-sub 5 | spec: 6 | channel: 7 | apiVersion: messaging.knative.dev/v1beta1 8 | kind: Channel 9 | name: eventinghello-ch 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventinghellob -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventinghello-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1alpha1 2 | kind: Channel 3 | metadata: 4 | name: eventinghello-ch -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventinghello-source-ch.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.eventing.knative.dev/v1alpha1 2 | kind: CronJobSource 3 | metadata: 4 | name: my-cjs 5 | spec: 6 | schedule: "*/2 * * * *" 7 | data: '{"key": "from CronJobSource"}' 8 | sink: 9 | ref: 10 | apiVersion: messaging.knative.dev/v1alpha1 11 | kind: Channel 12 | name: eventinghello-ch 13 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/eventinghello-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1alpha2 2 | kind: PingSource 3 | metadata: 4 | name: eventinghello-ping-source 5 | spec: 6 | jsonData: '{"message": "Thanks for doing Knative Tutorial"}' 7 | schedule: '*/2 * * * *' 8 | sink: 9 | ref: 10 | apiVersion: serving.knative.dev/v1 11 | kind: Service 12 | name: eventinghello 13 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/kafka-broker-my-cluster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kafka.strimzi.io/v1beta1 2 | kind: Kafka 3 | metadata: 4 | name: my-cluster 5 | spec: 6 | kafka: 7 | version: 2.4.0 8 | replicas: 1 9 | listeners: 10 | plain: {} 11 | tls: {} 12 | config: 13 | offsets.topic.replication.factor: 1 14 | transaction.state.log.replication.factor: 1 15 | transaction.state.log.min.isr: 1 16 | log.message.format.version: "2.4" 17 | storage: 18 | type: jbod 19 | volumes: 20 | - id: 0 21 | type: persistent-claim 22 | size: 100Gi 23 | deleteClaim: false 24 | zookeeper: 25 | replicas: 1 26 | storage: 27 | type: persistent-claim 28 | size: 100Gi 29 | deleteClaim: false 30 | entityOperator: 31 | topicOperator: {} 32 | userOperator: {} 33 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/kafka-topic-my-topic.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kafka.strimzi.io/v1alpha1 2 | kind: KafkaTopic 3 | metadata: 4 | name: my-topic 5 | labels: 6 | strimzi.io/cluster: my-cluster 7 | spec: 8 | partitions: 10 9 | replicas: 1 -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/mykafka-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1alpha1 2 | kind: KafkaSource 3 | metadata: 4 | name: mykafka-source 5 | spec: 6 | consumerGroup: knative-group 7 | bootstrapServers: my-cluster-kafka-bootstrap.kafka:9092 8 | topics: my-topic 9 | sink: 10 | ref: 11 | apiVersion: serving.knative.dev/v1 12 | kind: Service 13 | name: eventinghello -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: event-greeter 5 | spec: 6 | template: 7 | metadata: 8 | name: event-greeter-v1 9 | annotations: 10 | # disable istio-proxy injection 11 | sidecar.istio.io/inject: "false" 12 | spec: 13 | containers: 14 | - image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 15 | livenessProbe: 16 | httpGet: 17 | path: /healthz 18 | readinessProbe: 19 | httpGet: 20 | path: /healthz 21 | -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/trigger-helloaloha.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1beta1 2 | kind: Trigger 3 | metadata: 4 | name: helloaloha 5 | spec: 6 | broker: default 7 | filter: 8 | attributes: 9 | type: aloha 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventingaloha -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/trigger-hellobonjour.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1 2 | kind: Trigger 3 | metadata: 4 | name: hellobonjour 5 | spec: 6 | broker: default 7 | filter: 8 | attributes: 9 | type: bonjour 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventingbonjour -------------------------------------------------------------------------------- /documentation/modules/eventing/examples/eventing/trigger.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1alpha1 2 | kind: Trigger 3 | metadata: 4 | name: event-greeter-trigger 5 | spec: 6 | filter: 7 | sourceAndType: 8 | type: dev.knative.eventing.samples.heartbeat 9 | subscriber: 10 | ref: 11 | apiVersion: serving.knative.dev/v1 12 | kind: Service 13 | name: event-greeter 14 | -------------------------------------------------------------------------------- /documentation/modules/eventing/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:eventing.adoc#eventing-prerequisite[Prerequisites] 2 | * xref:eventing-src-to-sink.adoc[Source to Sink] 3 | ** xref:eventing-src-to-sink.adoc#eventing-source[Event Source] 4 | ** xref:eventing-src-to-sink.adoc#eventing-sink-service[Sink Service] 5 | ** xref:eventing-src-to-sink.adoc#eventing-create-event-source[Create Event Source] 6 | ** xref:eventing-src-to-sink.adoc#eventing-verify-event-source[Verify] 7 | ** xref:eventing-src-to-sink.adoc#eventing-cleanup[Cleanup] 8 | 9 | * xref:channel-and-subscribers.adoc[Channel and Subscribers] 10 | ** xref:channel-and-subscribers.adoc#eventing-channel[Channel] 11 | *** xref:channel-and-subscribers.adoc#eventing-create-event-channel[Create Event Channel] 12 | *** xref:channel-and-subscribers.adoc#eventing-verify-event-channel[Verify] 13 | ** xref:channel-and-subscribers.adoc#eventing-source[Event Source] 14 | *** xref:channel-and-subscribers.adoc#eventing-create-event-source[Create Event Source] 15 | *** xref:channel-and-subscribers.adoc#eventing-verify-event-source[Verify] 16 | ** xref:channel-and-subscribers.adoc#eventing-subscriber[Event Subscriber] 17 | *** xref:channel-and-subscribers.adoc#eventing-create-subscriber[Create Event Subscriber] 18 | *** xref:channel-and-subscribers.adoc#eventing-verify-subscriber[Verify] 19 | ** xref:channel-and-subscribers.adoc#eventing-see-what-you-have-deployed[See What You Have Deployed] 20 | ** xref:channel-and-subscribers.adoc#eventing-cleanup[Cleanup] 21 | 22 | * xref:eventing-trigger-broker.adoc[Brokers and Triggers] 23 | ** xref:eventing-trigger-broker.adoc#events-triggers-brokers[Events, Triggers and Brokers] 24 | ** xref:eventing-trigger-broker.adoc#broker[Broker] 25 | ** xref:eventing-trigger-broker.adoc#eventing-service[Service] 26 | ** xref:eventing-trigger-broker.adoc#eventing-event-source[Event Source] 27 | ** xref:eventing-trigger-broker.adoc#eventing-trigger[Trigger] 28 | ** xref:eventing-trigger-broker.adoc#eventing-trigger-verification[Verification] 29 | ** xref:eventing-trigger-broker.adoc#eventing-cleanup[Cleanup] 30 | * xref:eventing.adoc#eventing-watch-logs[Watching Logs] 31 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :moduledir: .. 2 | :github-repo: {repo-base}/blob/{branch} 3 | :basics-repo: serving 4 | :configs-and-routes-repo: configs-and-routes 5 | :scaling-repo: scaling 6 | :eventing-repo: eventing 7 | :experimental: 8 | 9 | :knative-serving-repo: https://github.com/knative/serving/releases/download 10 | :knative-sources-repo: https://github.com/knative/eventing-sources/releases/download 11 | :knative-eventing-repo: https://github.com/knative/eventing/releases/download -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_partials/eventing-snippets.adoc: -------------------------------------------------------------------------------- 1 | 2 | # tag::eventing-nav-folder[] 3 | 4 | Before beginning to run the exercises, navigate to the tutorial chapter's `eventing` folder: 5 | 6 | [#eventing-navigate-to-folder] 7 | [.console-input] 8 | [source,bash,subs="+macros,+attributes"] 9 | ---- 10 | cd $TUTORIAL_HOME/{eventing-repo} 11 | ---- 12 | 13 | # end::eventing-nav-folder[] 14 | 15 | # tag::ping-source[] 16 | 17 | The ping source also creates a service pod, 18 | 19 | [#eventing-run-get-pods] 20 | [.console-input] 21 | [source,bash,subs="+macros,+attributes"] 22 | ---- 23 | kubectl -n {tutorial-namespace} get pods 24 | ---- 25 | 26 | The above command will return an output like, 27 | 28 | [.console-output] 29 | [source,bash] 30 | ---- 31 | NAME READY STATUS RESTARTS AGE 32 | cronjob-event-greeter-cronjob-source-4v9vq-6bff96b58f-tgrhj 2/2 Running 0 6m 33 | ---- 34 | 35 | #end::ping-source[] 36 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_partials/invoke-service.adoc: -------------------------------------------------------------------------------- 1 | #tag::env[] 2 | 3 | [#{doc-sec}-{k8s-cli}-svc-gateway-env] 4 | [source,bash,subs="+macros,+attributes"] 5 | ---- 6 | IP_ADDRESS="$(minikube ip):$(kubectl get svc kourier-external --namespace kourier-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')" 7 | ---- 8 | copyToClipboard::{doc-sec}-{k8s-cli}-svc-gateway-env[] 9 | 10 | #end::env[] 11 | 12 | #tag::call[] 13 | 14 | [#{doc-sec}-{k8s-cli}-svc-call] 15 | [source,bash,subs="+macros,+attributes"] 16 | ---- 17 | http $IP_ADDRESS 'Host:greeter.knativetutorial.example.com' 18 | ---- 19 | 20 | copyToClipboard::{doc-sec}-{k8s-cli}-svc-call[] 21 | 22 | #end::call[] 23 | 24 | 25 | #tag::workshop-call[] 26 | 27 | [#{doc-sec}-{k8s-env}-{k8s-cli}-svc-call] 28 | [source,bash,subs="+macros,+attributes"] 29 | ---- 30 | export SVC_URL=`oc get rt greeter -o jsonpath={.status.url} && \ 31 | http $SVC_URL 32 | ---- 33 | 34 | copyToClipboard::{doc-sec}-{k8s-env}-{k8s-cli}-svc-call[] 35 | 36 | #end::workshop-call[] 37 | 38 | #tag::workshop-call-params[] 39 | 40 | [#{doc-sec}-{k8s-cli}-svc-call-params] 41 | [source,bash,subs="+macros,+attributes"] 42 | ---- 43 | export SVC_URL=`oc get rt greeter -o jsonpath={.status.url} && \ 44 | http $SVC_URL/{svc-params} 45 | ---- 46 | 47 | copyToClipboard::{doc-sec}-{k8s-cli}-svc-call-params[] 48 | 49 | #end::workshop-call-params[] -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_partials/prereq-cli.adoc: -------------------------------------------------------------------------------- 1 | 2 | The following checks ensure that each chapter exercises are done with the right environment settings. 3 | 4 | [tabs] 5 | ==== 6 | Minikube:: 7 | + 8 | -- 9 | * Set your local docker to use minikube docker daemon 10 | 11 | [.console-input] 12 | [source,bash,subs="+macros,+attributes"] 13 | ---- 14 | eval $(minikube docker-env) 15 | ---- 16 | 17 | * Kubernetes should be `{kubernetes-version}` 18 | 19 | [.console-input] 20 | [source,bash,subs="+macros,+attributes"] 21 | ---- 22 | kubectl version --short 23 | ---- 24 | 25 | The output should be as shown 26 | 27 | [source,bash,subs="+macros,+attributes"] 28 | [.console-output] 29 | ---- 30 | Client Version: {kubernetes-version} 31 | Server Version: {kubernetes-version} 32 | ---- 33 | -- 34 | OpenShift:: 35 | + 36 | -- 37 | * OpenShift CLI should be v4.6+ 38 | 39 | [#oc-version] 40 | [.console-input] 41 | [source,bash,subs="+macros,+attributes"] 42 | ---- 43 | oc version 44 | ---- 45 | 46 | The output should be like 47 | 48 | [source,bash,subs="+macros,+attributes"] 49 | [.console-output] 50 | ---- 51 | oc version 52 | Client Version: 4.6.1 53 | Kubernetes Version: `{kubernetes-version}` 54 | ---- 55 | 56 | * Make sure to be on `knativetutorial` OpenShift project 57 | 58 | [#right-openshift-project] 59 | [.console-input] 60 | [source,bash,subs="+macros,+attributes"] 61 | ---- 62 | oc project -q 63 | ---- 64 | 65 | If you are not on `{tutorial-namespace}` project, then run following command to change to `{tutorial-namespace}` project: 66 | 67 | [#change-to-openshift-project] 68 | [.console-input] 69 | [source,bash,subs="+macros,+attributes"] 70 | ---- 71 | oc project {tutorial-namespace} 72 | ---- 73 | -- 74 | ==== 75 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_partials/watch-scaling-pods.adoc: -------------------------------------------------------------------------------- 1 | [k8s-cli=''] 2 | [doc-sec=''] 3 | 4 | [#{doc-sec}-{k8s-cli}-watch-scale] 5 | [source,bash,subs="+macros,+attributes"] 6 | ---- 7 | watch '{k8s-cli} get pods -n {tutorial-namespace}' 8 | ---- 9 | copyToClipboard::{doc-sec}-{k8s-cli}-watch-scale[] 10 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_partials/watching-build-logs.adoc: -------------------------------------------------------------------------------- 1 | The Knative build creates an init container for each build step. The init containers will be named like `build-step-` e.g. if the build step is named "foo" then there will be an init container named "build-step-foo" added to the build pod. 2 | 3 | The following command can be used to watch the log of a specific container within a pod, 4 | 5 | [tabs] 6 | ==== 7 | kubectl:: 8 | + 9 | -- 10 | [source,bash,subs="+macros,+attributes"] 11 | ---- 12 | kubectl logs -n {tutorial-namespace} -c 13 | ---- 14 | 15 | (e.g.) 16 | 17 | To watch the container logs of container `docker-push` within the build pod called `event-greeter-build-pod-2a271e`: 18 | 19 | [source,bash] 20 | ---- 21 | kubectl logs -n {tutorial-namespace} event-greeter-build-pod-2a271e -c build-step-docker-push 22 | ---- 23 | -- 24 | oc:: 25 | + 26 | -- 27 | [source,bash,subs="+macros,+attributes"] 28 | ---- 29 | oc logs -n {tutorial-namespace} -c 30 | ---- 31 | 32 | (e.g.) 33 | 34 | To watch the container logs of container `docker-push` within the build pod called `event-greeter-build-pod-2a271e`: 35 | 36 | [source,bash,subs="+macros,+attributes"] 37 | ---- 38 | oc logs -n {tutorial-namespace} event-greeter-build-pod-2a271e -c build-step-docker-push 39 | ---- 40 | -- 41 | ==== 42 | 43 | [TIP] 44 | ==== 45 | * You can use the following command to list names of all the init containers within a pod . 46 | 47 | (e.g.) the following command lists all the init container names of the pod `event-greeter-build-pod-2986f2` 48 | 49 | [tabs] 50 | ===== 51 | kubectl:: 52 | + 53 | -- 54 | [source,bash,subs="+macros,+attributes"] 55 | ---- 56 | kubectl -n {tutorial-namespace} get pods event-greeter-build-pod-2986f2 -o yaml |\ 57 | yq r - spec.initContainers[*].name 58 | ---- 59 | -- 60 | oc:: 61 | + 62 | -- 63 | [source,bash,subs="+macros,+attributes"] 64 | ---- 65 | oc -n {tutorial-namespace} get pods event-greeter-build-pod-2986f2 -o yaml |\ 66 | yq r - spec.initContainers[*].name 67 | ---- 68 | -- 69 | ===== 70 | 71 | * Using `stern` you can watch logs of all the container of the build pod using the command `stern event-greeter-build-pod` 72 | ==== 73 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/_partials/watching-logs.adoc: -------------------------------------------------------------------------------- 1 | 2 | :kube-svc: eventing-hello 3 | 4 | In the eventing related subsections of this tutorial, event sources are configured to emit events every minute with a `PingSource` or with a `ContainerSource`. 5 | 6 | The logs could be watched using the command: 7 | 8 | [source,yaml,subs="+attributes,+macros"] 9 | ---- 10 | {kubernetes-cli} logs -n {tutorial-namespace} -f -c user-container 11 | ---- 12 | 13 | [TIP] 14 | ==== 15 | * Using stern with the command `stern -n {kube-ns} {kube-svc}`, to filter the logs further add `-c user-container` to the stern command. 16 | 17 | [.console-input] 18 | [source,bash,subs="+macros,+attributes"] 19 | ---- 20 | stern -n {tutorial-namespace} -c user-container {kube-svc} 21 | ---- 22 | ==== 23 | 24 | The logs will have the output like below printing every 2 minutes. 25 | 26 | [.console-output] 27 | [source] 28 | ---- 29 | INFO [com.red.dev.dem.GreetingService] (XNIO-1 task-1) Event Message Received 30 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container { 31 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container "message" : "Thanks for doing Knative Tutorial", 32 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container "host" : "Event greeter => 'event-greeter-5cbh5-pod-52d8fb' : 1", 33 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container "time" : "13:50:07" 34 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container } 35 | ---- 36 | (OR) 37 | [.console-output] 38 | [source] 39 | ---- 40 | INFO [com.red.dev.dem.GreetingService] (XNIO-1 task-1) Event Message Received 41 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container { 42 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container "message" : "Thanks for doing Knative Tutorial", 43 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container "host" : "Event greeter => 'event-greeter-5cbh5-pod-52d8fb' : 2", 44 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container "time" : "13:52:07" 45 | event-greeter-g94kp-deployment-89f66cb58-wjl2v user-container } 46 | ---- 47 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/eventing.adoc: -------------------------------------------------------------------------------- 1 | = Eventing 2 | include::_attributes.adoc[] 3 | 4 | At the end of this chapter you will know and understand: 5 | 6 | * What is an event source? 7 | * What is a channel? 8 | * What is a subscriber? 9 | * What is a trigger? 10 | * What is a broker? 11 | * How to make a Knative serving service receive an event? 12 | * How to make a service a subscriber of an event? 13 | 14 | ifndef::workshop[] 15 | [#eventing-prerequisite] 16 | == Prerequisite 17 | include::eventing:partial$prereq-cli.adoc[] 18 | endif::[] 19 | 20 | include::eventing:partial$eventing-snippets.adoc[tag=eventing-nav-folder] 21 | 22 | [#eventing-watch-logs] 23 | == Watching Logs 24 | 25 | :kube-ns: knativetutorial 26 | :kube-svc: event-greeter 27 | include::eventing:partial$watching-logs.adoc[] 28 | -------------------------------------------------------------------------------- /documentation/modules/eventing/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Knative Eventing 2 | 3 | .CloudEvents 4 | **** 5 | https://cloudevents.io/[CloudEvents] is a specification for describing event data in a common way. An event might be produced by any number of sources (e.g. Kafka, S3, GCP PubSub, MQTT) and as a software developer, you want a common abstraction for all event inputs. 6 | **** 7 | 8 | [[usage-patterns]] 9 | == Usage Patterns 10 | 11 | There are three primary usage patterns with Knative Eventing: 12 | 13 | Source to Sink:: 14 | Source to Service provides the simplest getting started experience with Knative Eventing. It provides single _Sink_ -- that is, event receiving service --, with no queuing, backpressure, and filtering. The Source to Service does not support replies, which means the response from the _Sink_ service is ignored. As shown in the Figure 1, the responsibility of the Event Source it just to deliver the message without waiting for the response from the Sink, hence I think it will be apt to compare Source to Sink to _fire and forget_ messaging pattern. 15 | 16 | .Source to Sink 17 | image::source-sink.png[Source to Sink,align="center"] 18 | 19 | Channel and Subscription:: 20 | With the _Channel_ and _Subscription_, the Knative Eventing system defines a _Channel_, which can connect to various backends such as In-Memory, Kafka and GCP PubSub for sourcing the events. Each Channel can have one or more subscribers in the form of _Sink_ services as shown in Figure 2, which can receive the event messages and process them as needed. Each message from the Channel is formatted as _CloudEvent_ and sent further up in the chain to other Subscribers for further processing. The Channels and Subscription usage pattern does not have the ability to filter messages. 21 | 22 | .Channels and Subscriptions 23 | image::channels-subs.png[Channels and Subscriptions,align="center"] 24 | 25 | Broker and Trigger:: 26 | The _Broker_ and _Trigger_ are similar to Channel and Subscription, except that they support filtering of events. Event filtering is a method that allows the subscribers to show an interest on certain set of messages that flows into the Broker. For each Broker, Knative Eventing will implicitly create a Knative Eventing Channel. As shown in Figure 3, the Trigger gets itself subscribed to the Broker and applies the filter on the messages on its subscribed broker. The filters are applied on the on the Cloud Event attributes of the messages, before delivering it to the interested Sink Services(subscribers). 27 | 28 | .Brokers and Triggers 29 | image::brokers-triggers.png[Brokers and Triggers,align="center"] 30 | -------------------------------------------------------------------------------- /documentation/modules/serving/_attributes.adoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/serving/_attributes.adoc -------------------------------------------------------------------------------- /documentation/modules/serving/examples/kn/kn_ksvc_desc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | annotations: 5 | serving.knative.dev/creator: minikube-user 6 | serving.knative.dev/lastModifier: minikube-user 7 | creationTimestamp: "2019-08-05T12:51:40Z" 8 | generation: 2 9 | name: greeter 10 | namespace: knativetutorial 11 | resourceVersion: "35193" 12 | selfLink: /apis/serving.knative.dev/v1/namespaces/knativetutorial/services/greeter 13 | uid: c4ee1f47-b77f-11e9-96b1-22e0f431a3ed 14 | spec: 15 | template: 16 | metadata: 17 | creationTimestamp: null 18 | spec: 19 | containers: 20 | - env: 21 | - name: MESSAGE_PREFIX 22 | value: '''Namaste''' 23 | image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 24 | name: user-container 25 | resources: {} 26 | timeoutSeconds: 300 27 | traffic: 28 | - latestRevision: true 29 | percent: 100 30 | status: 31 | address: 32 | url: http://greeter.knativetutorial.svc.cluster.local 33 | conditions: 34 | - lastTransitionTime: "2019-08-05T13:03:33Z" 35 | status: "True" 36 | type: ConfigurationsReady 37 | - lastTransitionTime: "2019-08-05T13:03:33Z" 38 | status: "True" 39 | type: Ready 40 | - lastTransitionTime: "2019-08-05T13:03:33Z" 41 | status: "True" 42 | type: RoutesReady 43 | latestCreatedRevisionName: greeter-578mv 44 | latestReadyRevisionName: greeter-578mv 45 | observedGeneration: 2 46 | traffic: 47 | - latestRevision: true 48 | percent: 100 49 | revisionName: greeter-578mv 50 | url: http://greeter.knativetutorial.example.com -------------------------------------------------------------------------------- /documentation/modules/serving/examples/kn/kn_rev_desc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Revision 3 | metadata: 4 | annotations: 5 | serving.knative.dev/lastPinned: "1565062128" 6 | creationTimestamp: "2019-08-06T03:28:42Z" 7 | generateName: greeter- 8 | generation: 1 9 | labels: 10 | serving.knative.dev/configuration: greeter 11 | serving.knative.dev/configurationGeneration: "2" 12 | serving.knative.dev/service: greeter 13 | name: greeter-7cqzq 14 | namespace: knativetutorial 15 | ownerReferences: 16 | - apiVersion: serving.knative.dev/v1 17 | blockOwnerDeletion: true 18 | controller: true 19 | kind: Configuration 20 | name: greeter 21 | uid: 2f89f930-b7fa-11e9-96b1-22e0f431a3ed 22 | resourceVersion: "40312" 23 | selfLink: /apis/serving.knative.dev/v1/namespaces/knativetutorial/revisions/greeter-7cqzq 24 | uid: 49e30221-b7fa-11e9-96b1-22e0f431a3ed 25 | spec: 26 | containers: 27 | - env: 28 | - name: MESSAGE_PREFIX 29 | value: Namaste 30 | image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 31 | name: user-container 32 | resources: {} 33 | timeoutSeconds: 300 34 | status: 35 | conditions: 36 | - lastTransitionTime: "2019-08-06T03:29:51Z" 37 | message: The target is not receiving traffic. 38 | reason: NoTraffic 39 | severity: Info 40 | status: "False" 41 | type: Active 42 | - lastTransitionTime: "2019-08-06T03:28:48Z" 43 | status: "True" 44 | type: ContainerHealthy 45 | - lastTransitionTime: "2019-08-06T03:28:48Z" 46 | status: "True" 47 | type: Ready 48 | - lastTransitionTime: "2019-08-06T03:28:48Z" 49 | status: "True" 50 | type: ResourcesAvailable 51 | imageDigest: quay.io/rhdevelopers/knative-tutorial-greeter@sha256:767e2f4b37d29de3949c8c695d3285739829c348df1dd703479bbae6dc86aa5a 52 | logUrl: http://localhost:8001/api/v1/namespaces/knative-monitoring/services/kibana-logging/proxy/app/kibana#/discover?_a=(query:(match:(kubernetes.labels.knative-dev%2FrevisionUID:(query:'49e30221-b7fa-11e9-96b1-22e0f431a3ed',type:phrase)))) 53 | observedGeneration: 1 54 | serviceName: greeter-7cqzq -------------------------------------------------------------------------------- /documentation/modules/serving/examples/scaling/service-10.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: prime-generator 5 | spec: 6 | template: 7 | metadata: 8 | annotations: 9 | # Target 10 in-flight-requests per pod. 10 | autoscaling.knative.dev/target: "10" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/prime-generator:v27-quarkus 14 | livenessProbe: 15 | httpGet: 16 | path: /healthz 17 | readinessProbe: 18 | httpGet: 19 | path: /healthz 20 | -------------------------------------------------------------------------------- /documentation/modules/serving/examples/scaling/service-min-max-scale.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: prime-generator 5 | spec: 6 | template: 7 | metadata: 8 | annotations: 9 | # the minimum number of pods to scale down to 10 | autoscaling.knative.dev/minScale: "2" 11 | # Target 10 in-flight-requests per pod. 12 | autoscaling.knative.dev/target: "10" 13 | spec: 14 | containers: 15 | - image: quay.io/rhdevelopers/prime-generator:v27-quarkus 16 | livenessProbe: 17 | httpGet: 18 | path: /healthz 19 | readinessProbe: 20 | httpGet: 21 | path: /healthz -------------------------------------------------------------------------------- /documentation/modules/serving/examples/serving/colors-service-blue.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: blue-green-canary 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/blue-green-canary 10 | env: 11 | - name: BLUE_GREEN_CANARY_COLOR 12 | value: "#6bbded" 13 | - name: BLUE_GREEN_CANARY_MESSAGE 14 | value: "Hello" 15 | -------------------------------------------------------------------------------- /documentation/modules/serving/examples/serving/colors-service-canary.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: blue-green-canary 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/blue-green-canary 10 | env: 11 | - name: BLUE_GREEN_CANARY_COLOR 12 | value: "#f2f25e" 13 | - name: BLUE_GREEN_CANARY_MESSAGE 14 | value: "Bonjour" 15 | -------------------------------------------------------------------------------- /documentation/modules/serving/examples/serving/colors-service-green.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: blue-green-canary 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/blue-green-canary 10 | env: 11 | - name: BLUE_GREEN_CANARY_COLOR 12 | value: "#5bbf45" 13 | - name: BLUE_GREEN_CANARY_MESSAGE 14 | value: "Namaste" 15 | -------------------------------------------------------------------------------- /documentation/modules/serving/examples/serving/service-pinned.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: greeter 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 10 | env: 11 | - name: MESSAGE_PREFIX 12 | value: Namaste 13 | # livenessProbe: 14 | # httpGet: 15 | # path: /healthz 16 | # readinessProbe: 17 | # httpGet: 18 | # path: /healthz 19 | traffic: 20 | - tag: v1 21 | revisionName: greeter-v1 22 | percent: 100 23 | - tag: v2 24 | revisionName: greeter-v2 25 | percent: 0 26 | - tag: latest 27 | latestRevision: true 28 | percent: 0 29 | -------------------------------------------------------------------------------- /documentation/modules/serving/examples/serving/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: greeter 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 10 | livenessProbe: 11 | httpGet: 12 | path: /healthz 13 | readinessProbe: 14 | httpGet: 15 | path: /healthz 16 | -------------------------------------------------------------------------------- /documentation/modules/serving/images/blue-green-canary-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/serving/images/blue-green-canary-blue.png -------------------------------------------------------------------------------- /documentation/modules/serving/images/blue-green-canary-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/serving/images/blue-green-canary-green.png -------------------------------------------------------------------------------- /documentation/modules/serving/images/blue-green-canary.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/serving/images/blue-green-canary.gif -------------------------------------------------------------------------------- /documentation/modules/serving/images/che_env_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/serving/images/che_env_overview.png -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :icons: font 2 | :moduledir: .. 3 | :github-repo: https://github.com/redhat-developer-demos/knative-tutorial/blob/{branch} 4 | :basics-repo: serving 5 | :configs-and-routes-repo: configs-and-routes 6 | :scaling-repo: scaling 7 | :eventing-repo: eventing 8 | :experimental: 9 | :minikube-nip-io: 192.168.64.13.nip.io 10 | 11 | :knative-serving-repo: https://github.com/knative/serving/releases/download 12 | :knative-sources-repo: https://github.com/knative/eventing-sources/releases/download 13 | :knative-eventing-repo: https://github.com/knative/eventing/releases/download -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/build-containers.adoc: -------------------------------------------------------------------------------- 1 | # tag::greeter[] 2 | 3 | [NOTE] 4 | ==== 5 | If you have already cloned the repo and built the `greeter` service you can skip this step. 6 | ==== 7 | 8 | * Navigate to `greeter` app folder in pass:[$TUTORIAL_HOME] 9 | 10 | [#navigate-to-greeter-app-folder] 11 | [source,bash,subs="+macros,+attributes"] 12 | ---- 13 | cd $TUTORIAL_HOME/apps/greeter 14 | ---- 15 | copyToClipboard::navigate-to-greeter-app-folder[] 16 | 17 | * Build the application and container image 18 | 19 | [#build-greeter] 20 | [source,bash,subs="+macros,+attributes"] 21 | ---- 22 | cd java/quarkus && \ 23 | ./mvnw clean package && \ 24 | docker build -t dev.local/rhdevelopers/greeter:0.0.1 -f Dockerfile.all . 25 | ---- 26 | copyToClipboard::build-greeter[] 27 | 28 | * Check if images are built and available: 29 | 30 | [#check-greeter-images] 31 | [source,bash,subs="+macros,+attributes"] 32 | ---- 33 | docker images | grep dev.local 34 | ---- 35 | copyToClipboard::check-greeter-images[] 36 | 37 | The above command should return something like as shown below: 38 | [source,bash] 39 | ---- 40 | dev.local/rhdevelopers/greeter 0.0.1 6aa8771da8dd 2 hours ago 456MB 41 | ---- 42 | 43 | # end::greeter[] 44 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/deploy-knative-resources.adoc: -------------------------------------------------------------------------------- 1 | #tag::tab-1[] 2 | [tabs] 3 | ==== 4 | kn:: 5 | + 6 | -- 7 | #end::tab-1[] 8 | #tag::basic[] 9 | [.console-input] 10 | [source,bash,subs="+macros,+attributes"] 11 | ---- 12 | kn service create greeter \ 13 | --image={greeter-image} 14 | ---- 15 | #end::basic[] 16 | #tag::env[] 17 | [.console-input] 18 | [source,bash,subs="+macros,+attributes"] 19 | ---- 20 | kn service update greeter \ 21 | --env MESSAGE_PREFIX=Namaste \ 22 | --image={greeter-image} 23 | ---- 24 | #end::env[] 25 | #tag::td-rev1[] 26 | [.console-input] 27 | [source,bash,subs="+macros,+attributes"] 28 | ---- 29 | kn service create blue-green-canary \ 30 | --image=quay.io/rhdevelopers/blue-green-canary \ 31 | --env BLUE_GREEN_CANARY_COLOR="#6bbded" \ 32 | --env BLUE_GREEN_CANARY_MESSAGE="Hello" 33 | ---- 34 | #end::td-rev1[] 35 | #tag::td-rev2[] 36 | [.console-input] 37 | [source,bash,subs="+macros,+attributes"] 38 | ---- 39 | kn service update blue-green-canary \ 40 | --image=quay.io/rhdevelopers/blue-green-canary \ 41 | --env BLUE_GREEN_CANARY_COLOR="#5bbf45" \ 42 | --env BLUE_GREEN_CANARY_MESSAGE="Namaste" 43 | ---- 44 | #end::td-rev2[] 45 | #tag::td-rev3[] 46 | [.console-input] 47 | [source,bash,subs="+macros,+attributes"] 48 | ---- 49 | kn service update blue-green-canary \ 50 | --image=quay.io/rhdevelopers/blue-green-canary \ 51 | --env BLUE_GREEN_CANARY_COLOR="#f2f25e" \ 52 | --env BLUE_GREEN_CANARY_MESSAGE="Bonjour" 53 | ---- 54 | #end::td-rev3[] 55 | #tag::td-pinned[] 56 | .Route all traffic to v1 57 | [.console-input] 58 | [source,bash,subs="+macros,+attributes"] 59 | ---- 60 | kn service update greeter --traffic blue=100,green=0,latest=0 61 | ---- 62 | #end::td-pinned[] 63 | #tag::td-canary[] 64 | [.console-input] 65 | [source,bash,subs="+macros,+attributes"] 66 | ---- 67 | kn service update greeter --traffic v1=80,v2=20,latest=0 68 | ---- 69 | #end::td-canary[] 70 | #tag::scaling-10[] 71 | [.console-input] 72 | [source,bash,subs="+macros,+attributes"] 73 | ---- 74 | kn service create prime-generator \ 75 | --concurrency-target=10 \ 76 | --image=quay.io/rhdevelopers/prime-generator:v27-quarkus 77 | ---- 78 | #end::scaling-10[] 79 | #tag::scaling-min[] 80 | [.console-input] 81 | [source,bash,subs="+macros,+attributes"] 82 | ---- 83 | kn service create prime-generator \ 84 | --concurrency-target=10 \ 85 | --scale-min=2 \ 86 | --image=quay.io/rhdevelopers/prime-generator:v27-quarkus 87 | ---- 88 | #end::scaling-min[] 89 | #tag::tab-2[] 90 | -- 91 | {kubernetes-cli}:: 92 | + 93 | -- 94 | [.console-input] 95 | [source,bash,subs="+macros,+attributes"] 96 | ---- 97 | {kubernetes-cli} apply -f link:{github-repo}/{basics-repo}/{service-file}[pass:[$TUTORIAL_HOME]/{basics-repo}/{service-file}] 98 | ---- 99 | -- 100 | ==== 101 | #end::tab-2[] 102 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/invoke-service.adoc: -------------------------------------------------------------------------------- 1 | #tag::env[] 2 | // [.console-input] 3 | // [source,bash,subs="+macros,+attributes"] 4 | // ---- 5 | // export IP_ADDRESS="$(minikube -p {tutorial-namespace} ip):$(kubectl get svc kourier --namespace kourier-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')" 6 | // ---- 7 | #end::env[] 8 | 9 | #tag::call[] 10 | 11 | [.console-input] 12 | [source,bash,subs="+macros,+attributes"] 13 | ---- 14 | http $(kn service describe greeter -o url) 15 | ---- 16 | 17 | #end::call[] 18 | 19 | #tag::workshop-call[] 20 | 21 | [.console-input] 22 | [source,bash,subs="+macros,+attributes"] 23 | ---- 24 | export SVC_URL=`{kubernetes-cli} get rt greeter -o jsonpath={.status.url}` && \ 25 | http $SVC_URL 26 | ---- 27 | 28 | #end::workshop-call[] 29 | 30 | #tag::workshop-call-params[] 31 | 32 | [.console-input] 33 | [source,bash,subs="+macros,+attributes"] 34 | ---- 35 | export SVC_URL=`{kubernetes-cli} get rt greeter -o jsonpath={.status.url} && \ 36 | http $SVC_URL/{svc-params} 37 | ---- 38 | 39 | #end::workshop-call-params[] 40 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/prereq-cli.adoc: -------------------------------------------------------------------------------- 1 | 2 | The following checks ensure that each chapter exercises are done with the right environment settings. 3 | 4 | [tabs] 5 | ==== 6 | Minikube:: 7 | + 8 | -- 9 | * Set your local docker to use minikube docker daemon 10 | 11 | [#minikube-set-env] 12 | [.console-input] 13 | [source,bash,subs="+macros,+attributes"] 14 | ---- 15 | eval $(minikube docker-env) 16 | ---- 17 | 18 | * Kubernetes should be {kubernetes-version}+ 19 | 20 | [#kubectl-version] 21 | [.console-input] 22 | [source,bash,subs="+macros,+attributes"] 23 | ---- 24 | kubectl version --short 25 | ---- 26 | 27 | The output should be as shown 28 | 29 | [source,bash,subs="attributes+"] 30 | [.console-output] 31 | ---- 32 | Client Version: {kubernetes-version} 33 | Server Version: {kubernetes-version} 34 | ---- 35 | -- 36 | OpenShift:: 37 | + 38 | -- 39 | * OpenShift CLI should be {openshift-version}+ 40 | 41 | [#oc-version] 42 | [.console-input] 43 | [source,bash,subs="+macros,+attributes"] 44 | ---- 45 | oc version 46 | ---- 47 | 48 | The output should be like 49 | 50 | [source,bash,subs="+macros,+attributes"] 51 | [.console-output] 52 | ---- 53 | Client Version: 4.6.9 54 | Kubernetes Version: {kubernetes-version} 55 | ---- 56 | 57 | * Make sure to be on `knativetutorial` OpenShift project 58 | 59 | [#right-openshift-project] 60 | [.console-input] 61 | [source,bash,subs="+macros,+attributes"] 62 | ---- 63 | oc project -q 64 | ---- 65 | 66 | If you are not on `{tutorial-namespace}` project, then run following command to change to `{tutorial-namespace}` project: 67 | 68 | [#change-to-openshift-project] 69 | [.console-input] 70 | [source,bash,subs="+macros,+attributes"] 71 | ---- 72 | oc project {tutorial-namespace} 73 | ---- 74 | -- 75 | ==== 76 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/watch-scaling-pods.adoc: -------------------------------------------------------------------------------- 1 | [.console-input] 2 | [source,bash,subs="+macros,+attributes"] 3 | ---- 4 | watch 'kubectl get pods -n {tutorial-namespace}' 5 | ---- 6 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/watching-build-logs.adoc: -------------------------------------------------------------------------------- 1 | The Knative build creates an init container for each build step. The init containers will be named like `build-step-` e.g. if the build step is named "foo" then there will be an init container named "build-step-foo" added to the build pod. 2 | 3 | The following command can be used to watch the log of a specific container within a pod, 4 | 5 | [tabs] 6 | ==== 7 | kubectl:: 8 | + 9 | -- 10 | [source,bash,subs="+macros,+attributes"] 11 | ---- 12 | kubectl logs -n {tutorial-namespace} -c 13 | ---- 14 | 15 | (e.g.) 16 | 17 | To watch the container logs of container `docker-push` within the build pod called `event-greeter-build-pod-2a271e`: 18 | 19 | [source,bash] 20 | ---- 21 | kubectl logs -n {tutorial-namespace} event-greeter-build-pod-2a271e -c build-step-docker-push 22 | ---- 23 | -- 24 | oc:: 25 | + 26 | -- 27 | [source,bash,subs="+macros,+attributes"] 28 | ---- 29 | oc logs -n {tutorial-namespace} -c 30 | ---- 31 | 32 | (e.g.) 33 | 34 | To watch the container logs of container `docker-push` within the build pod called `event-greeter-build-pod-2a271e`: 35 | 36 | [source,bash,subs="+macros,+attributes"] 37 | ---- 38 | oc logs -n {tutorial-namespace} event-greeter-build-pod-2a271e -c build-step-docker-push 39 | ---- 40 | -- 41 | ==== 42 | 43 | [TIP] 44 | ==== 45 | * You can use the following command to list names of all the init containers within a pod . 46 | 47 | (e.g.) the following command lists all the init container names of the pod `event-greeter-build-pod-2986f2` 48 | 49 | [tabs] 50 | ===== 51 | kubectl:: 52 | + 53 | -- 54 | [source,bash,subs="+macros,+attributes"] 55 | ---- 56 | kubectl -n {tutorial-namespace} get pods event-greeter-build-pod-2986f2 -o yaml |\ 57 | yq r - spec.initContainers[*].name 58 | ---- 59 | -- 60 | oc:: 61 | + 62 | -- 63 | [source,bash,subs="+macros,+attributes"] 64 | ---- 65 | oc -n {tutorial-namespace} get pods event-greeter-build-pod-2986f2 -o yaml |\ 66 | yq r - spec.initContainers[*].name 67 | ---- 68 | -- 69 | ===== 70 | 71 | * Using `stern` you can watch logs of all the container of the build pod using the command `stern event-greeter-build-pod` 72 | ==== 73 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/_partials/watching-logs.adoc: -------------------------------------------------------------------------------- 1 | ifndef::workshop[] 2 | [kube-ns='knativetutorial'] 3 | [kube-svc=''] 4 | 5 | In the eventing related subsections of this tutorial, event sources are configured to emit events every minute with a `CronJobSource` or with a `ContainerSource`. 6 | 7 | The logs could be watched using the command: 8 | [tabs] 9 | ==== 10 | kubectl:: 11 | + 12 | -- 13 | [source,bash,subs="+macros,+attributes"] 14 | ---- 15 | kubectl logs -n {kube-ns} -f -c user-container 16 | ---- 17 | -- 18 | oc:: 19 | + 20 | -- 21 | endif::[] 22 | 23 | [source,bash,subs="+macros,+attributes"] 24 | ---- 25 | oc logs -n {kube-ns} -f -c user-container 26 | ---- 27 | ifndef::workshop[] 28 | -- 29 | ==== 30 | endif::[] 31 | 32 | [TIP] 33 | ==== 34 | * Using stern with the command `stern -n {kube-ns} {kube-svc}`, to filter the logs further add `-c user-container` to the stern command. 35 | 36 | [source,bash,subs="+macros,+attributes"] 37 | ---- 38 | stern -n {kube-ns} -c user-container {kube-svc} 39 | ---- 40 | ==== 41 | -------------------------------------------------------------------------------- /documentation/modules/serving/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Knative Serving 2 | 3 | Knative Serving is ideal for running your application services inside Kubernetes by providing a more simplified deployment syntax with automated scale-to-zero and scale-out based on HTTP load. The Knative platform will manage your service’s deployments, revisions, networking and scaling. 4 | Knative Serving exposes your service via an HTTP URL and has a lot of sane defaults for its configurations. For many practical use cases you might need to tweak the defaults to your needs and might also need to adjust the traffic distribution amongst the service revisions. As the Knative Serving Service has the built in ability to automatically scale down to zero when not in use, it is apt to call it as “serverless service”. 5 | 6 | In this chapter, we are going to deploy a Knative Serving service, see its use of Configuration and Revision, and practice a blue-green deployment and canary release. 7 | 8 | ifdef::workshop[] 9 | .Some useful workshop links and information: 10 | * OpenShift Console: {openshift-console-url} 11 | * Etherpad: {etherpad-url} 12 | endif::[] -------------------------------------------------------------------------------- /documentation/modules/setup/_attributes.adoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/documentation/modules/setup/_attributes.adoc -------------------------------------------------------------------------------- /documentation/modules/setup/pages/_attributes.adoc: -------------------------------------------------------------------------------- 1 | :moduledir: .. 2 | :github-repo: {repo-base}/blob/{branch} 3 | :basics-repo: serving 4 | :configs-and-routes-repo: configs-and-routes 5 | :scaling-repo: scaling 6 | :eventing-repo: eventing 7 | :experimental: 8 | 9 | :knative-serving-repo: https://github.com/knative/serving/releases/download 10 | :knative-sources-repo: https://github.com/knative/eventing-sources/releases/download 11 | :knative-eventing-repo: https://github.com/knative/eventing/releases/download -------------------------------------------------------------------------------- /documentation/modules/setup/pages/kubernetes-cluster.adoc: -------------------------------------------------------------------------------- 1 | [#kubernetes-cluster] 2 | == Choose your Kubernetes Cluster 3 | 4 | Knative can be installed only on Kubernetes cluster. The following section shows how to install Knative on vanilla https://kubernetes.io[Kubernetes] or on Red Hat https://www.openshift.com[Openshift] -- an enterprise grade Kubernetes platform -- -------------------------------------------------------------------------------- /documentation/modules/setup/pages/openshift.adoc: -------------------------------------------------------------------------------- 1 | [#install-knative-openshift] 2 | = OpenShift 3 | include::_attributes.adoc[] 4 | :hardbreaks-option: 5 | 6 | Knative Serving and Eventing install needs OpenShift4, you need to have one provisioned using https://try.openshift.com[try.openshift.com] or can use any existing OpenShift4 cluster. 7 | 8 | Once you have your cluster, you can download the latest OpenShift client(oc) from https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/[here] and add to your path. 9 | 10 | 11 | [.console-input] 12 | [source,bash,subs="+macros,+attributes"] 13 | ---- 14 | oc version 15 | ---- 16 | 17 | The output should show oc version >= {openshift-version} 18 | 19 | [.console-output] 20 | [source,bash,subs="+macros,+attributes"] 21 | ---- 22 | Client Version: 4.6.9 23 | Kubernetes Version: {kubernetes-version} 24 | ---- 25 | 26 |   27 | 28 | video::eOwJjC9u4aM[youtube,width=640,height=480] 29 | 30 | For more information on OpenShift Servertless, consult the https://docs.openshift.com/container-platform/4.9/serverless/install/install-serverless-operator.html[OpenShift^] documentation. 31 | 32 | **Navigate to tutorial project** 33 | 34 | [#nav-to-tutorial-project] 35 | [source,bash,subs="+macros,+attributes"] 36 | ---- 37 | oc new-project knativetutorial 38 | ---- 39 | -------------------------------------------------------------------------------- /documentation/modules/setup/pages/tutorial-dev-env.adoc: -------------------------------------------------------------------------------- 1 | = All In One 2 | include::_attributes.adoc[] 3 | 4 | include::setup:partial$tutorial-dev-env.adoc[] 5 | -------------------------------------------------------------------------------- /documentation/modules/workshop/pages/_partials/openshift-setup.adoc: -------------------------------------------------------------------------------- 1 | [#kubernetes-cluster] 2 | == Configure your OpenShift Environment 3 | 4 | === Prepare your shell environment 5 | 6 | [#knative-tutorial-shell-env] 7 | [source,bash,subs="attributes+,+macros"] 8 | ---- 9 | # set the current workshop user 10 | export WORKSHOP_USER=1 11 | # update the tutorial to point to knative-tutorial 12 | export TUTORIAL_HOME="/projects/$CHE_WORKSPACE_ID/projects/knative-tutorial" 13 | ---- 14 | copyToClipboard::knative-tutorial-shell-env[] 15 | 16 | === Login into OpenShift 17 | 18 | [#knative-tutorial-oc-login] 19 | [source,bash,subs="attributes+,+macros"] 20 | ---- 21 | oc login --insecure-skip-tls-verify=true --username userpass:[$WORKSHOP_USER] {ocpurl} 22 | ---- 23 | copyToClipboard::knative-tutorial-oc-login[] 24 | 25 | You can also access the OpenShift Console via url {openshift-console-url} 26 | 27 | === Change to OpenShift Workshop Project 28 | 29 | [#knative-oc-project] 30 | [source,bash,subs="attributes+,+macros"] 31 | ---- 32 | oc project {tutorial-namespace} 33 | ---- 34 | copyToClipboard::knative-oc-project[] -------------------------------------------------------------------------------- /eventing/channel-subscriber.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghelloa 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghelloa-v1 #<1> 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.1 -------------------------------------------------------------------------------- /eventing/channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1 2 | kind: Channel 3 | metadata: 4 | name: eventinghello-ch -------------------------------------------------------------------------------- /eventing/curler.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | labels: 5 | run: curler 6 | name: curler 7 | spec: 8 | containers: 9 | - name: curler 10 | image: fedora:34 11 | tty: true 12 | -------------------------------------------------------------------------------- /eventing/default-broker.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: eventing.knative.dev/v1 3 | kind: broker 4 | metadata: 5 | name: default -------------------------------------------------------------------------------- /eventing/default-channel-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: default-ch-webhook 5 | namespace: knative-eventing 6 | data: 7 | default-ch-config: | 8 | clusterDefault: 9 | apiVersion: messaging.knative.dev/v1 10 | kind: InMemoryChannel 11 | namespaceDefaults: 12 | knativetutorial: 13 | apiVersion: messaging.knative.dev/v1beta1 14 | kind: KafkaChannel 15 | spec: 16 | numPartitions: 2 17 | replicationFactor: 1 18 | -------------------------------------------------------------------------------- /eventing/default-kafka-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1 2 | kind: Channel 3 | metadata: 4 | name: my-events-ch -------------------------------------------------------------------------------- /eventing/event-source-broker.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.eventing.knative.dev/v1alpha1 2 | kind: ContainerSource 3 | metadata: 4 | name: heartbeat-event-source 5 | spec: 6 | image: quay.io/openshift-knative/knative-eventing-sources-heartbeats:v0.5.0 7 | args: 8 | - '--label="Thanks for doing Knative Tutorial"' 9 | - '--period=1' 10 | env: 11 | - name: POD_NAME 12 | valueFrom: 13 | fieldRef: 14 | fieldPath: metadata.name 15 | - name: POD_NAMESPACE 16 | valueFrom: 17 | fieldRef: 18 | fieldPath: metadata.namespace 19 | sink: 20 | apiVersion: eventing.knative.dev/v1alpha1 21 | kind: Broker 22 | name: default 23 | -------------------------------------------------------------------------------- /eventing/event-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1 2 | kind: PingSource 3 | metadata: 4 | name: event-greeter-ping-source 5 | spec: 6 | schedule: "*/2 * * * *" 7 | data: '{"message": "Thanks for doing Knative Tutorial"}' 8 | sink: 9 | ref: 10 | apiVersion: messaging.knative.dev/v1 11 | kind: Channel 12 | name: eventinghello-ch 13 | -------------------------------------------------------------------------------- /eventing/eventing-aloha-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventingaloha 5 | spec: 6 | template: 7 | metadata: 8 | name: eventingaloha-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /eventing/eventing-bonjour-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventingbonjour 5 | spec: 6 | template: 7 | metadata: 8 | name: eventingbonjour-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /eventing/eventing-hello-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghello 5 | spec: 6 | template: 7 | metadata: 8 | annotations: 9 | autoscaling.knative.dev/target: "1" 10 | spec: 11 | containers: 12 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 13 | 14 | -------------------------------------------------------------------------------- /eventing/eventing-helloa-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghelloa 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghelloa-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /eventing/eventing-helloa-sub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1 2 | kind: Subscription 3 | metadata: 4 | name: eventinghelloa-sub 5 | spec: 6 | channel: 7 | apiVersion: messaging.knative.dev/v1 8 | kind: Channel 9 | name: eventinghello-ch 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventinghelloa -------------------------------------------------------------------------------- /eventing/eventing-hellob-sink.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: eventinghellob 5 | spec: 6 | template: 7 | metadata: 8 | name: eventinghellob-v1 9 | annotations: 10 | autoscaling.knative.dev/target: "1" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/eventinghello:0.0.2 14 | 15 | -------------------------------------------------------------------------------- /eventing/eventing-hellob-sub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1 2 | kind: Subscription 3 | metadata: 4 | name: eventinghellob-sub 5 | spec: 6 | channel: 7 | apiVersion: messaging.knative.dev/v1 8 | kind: Channel 9 | name: eventinghello-ch 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventinghellob -------------------------------------------------------------------------------- /eventing/eventinghello-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: messaging.knative.dev/v1alpha1 2 | kind: Channel 3 | metadata: 4 | name: eventinghello-ch -------------------------------------------------------------------------------- /eventing/eventinghello-source-ch.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1 2 | kind: PingSource 3 | metadata: 4 | name: my-cjs 5 | spec: 6 | schedule: "*/1 * * * *" 7 | data: '{"key": "from PingSource"}' 8 | sink: 9 | ref: 10 | apiVersion: messaging.knative.dev/v1 11 | kind: Channel 12 | name: eventinghello-ch 13 | -------------------------------------------------------------------------------- /eventing/eventinghello-source-ping.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1 2 | kind: PingSource 3 | metadata: 4 | name: eventinghello-ping-source 5 | spec: 6 | schedule: "*/2 * * * *" 7 | data: '{"key": "every 2 mins"}' 8 | sink: 9 | ref: 10 | apiVersion: serving.knative.dev/v1 11 | kind: Service 12 | name: eventinghello 13 | -------------------------------------------------------------------------------- /eventing/eventinghello-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1 2 | kind: PingSource 3 | metadata: 4 | name: eventinghello-ping-source 5 | spec: 6 | data: '{"message": "Thanks for doing Knative Tutorial"}' 7 | schedule: '*/1 * * * *' 8 | sink: 9 | ref: 10 | apiVersion: serving.knative.dev/v1 11 | kind: Service 12 | name: eventinghello 13 | -------------------------------------------------------------------------------- /eventing/kafka-broker-my-cluster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kafka.strimzi.io/v1beta2 2 | kind: Kafka 3 | metadata: 4 | name: my-cluster 5 | spec: 6 | kafka: 7 | replicas: 1 8 | listeners: 9 | - name: plain 10 | port: 9092 11 | type: internal 12 | tls: false 13 | - name: tls 14 | port: 9093 15 | type: internal 16 | tls: true 17 | authentication: 18 | type: tls 19 | - name: external 20 | port: 9094 21 | type: nodeport 22 | tls: false 23 | storage: 24 | type: jbod 25 | volumes: 26 | - id: 0 27 | type: persistent-claim 28 | size: 100Gi 29 | deleteClaim: false 30 | config: 31 | offsets.topic.replication.factor: 1 32 | transaction.state.log.replication.factor: 1 33 | transaction.state.log.min.isr: 1 34 | default.replication.factor: 1 35 | min.insync.replicas: 1 36 | zookeeper: 37 | replicas: 1 38 | storage: 39 | type: persistent-claim 40 | size: 100Gi 41 | deleteClaim: false 42 | entityOperator: 43 | topicOperator: {} 44 | userOperator: {} -------------------------------------------------------------------------------- /eventing/kafka-topic-my-topic.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kafka.strimzi.io/v1beta2 2 | kind: KafkaTopic 3 | metadata: 4 | name: my-topic 5 | labels: 6 | strimzi.io/cluster: my-cluster 7 | spec: 8 | partitions: 10 9 | replicas: 1 -------------------------------------------------------------------------------- /eventing/mykafka-source.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: sources.knative.dev/v1beta1 2 | kind: KafkaSource 3 | metadata: 4 | name: mykafka-source 5 | spec: 6 | consumerGroup: knative-group 7 | bootstrapServers: 8 | - my-cluster-kafka-bootstrap.kafka:9092 9 | topics: 10 | - my-topic 11 | sink: 12 | ref: 13 | apiVersion: serving.knative.dev/v1 14 | kind: Service 15 | name: eventinghello -------------------------------------------------------------------------------- /eventing/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: event-greeter 5 | spec: 6 | template: 7 | metadata: 8 | name: event-greeter-v1 9 | annotations: 10 | # disable istio-proxy injection 11 | sidecar.istio.io/inject: "false" 12 | spec: 13 | containers: 14 | - image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 15 | livenessProbe: 16 | httpGet: 17 | path: /healthz 18 | readinessProbe: 19 | httpGet: 20 | path: /healthz 21 | -------------------------------------------------------------------------------- /eventing/trigger-helloaloha.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1 2 | kind: Trigger 3 | metadata: 4 | name: helloaloha 5 | spec: 6 | broker: default 7 | filter: 8 | attributes: 9 | type: aloha 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventingaloha -------------------------------------------------------------------------------- /eventing/trigger-hellobonjour.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1 2 | kind: Trigger 3 | metadata: 4 | name: hellobonjour 5 | spec: 6 | broker: default 7 | filter: 8 | attributes: 9 | type: bonjour 10 | subscriber: 11 | ref: 12 | apiVersion: serving.knative.dev/v1 13 | kind: Service 14 | name: eventingbonjour -------------------------------------------------------------------------------- /eventing/trigger.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eventing.knative.dev/v1alpha1 2 | kind: Trigger 3 | metadata: 4 | name: event-greeter-trigger 5 | spec: 6 | filter: 7 | sourceAndType: 8 | type: dev.knative.eventing.samples.heartbeat 9 | subscriber: 10 | ref: 11 | apiVersion: serving.knative.dev/v1 12 | kind: Service 13 | name: event-greeter 14 | -------------------------------------------------------------------------------- /gulpfile.ts: -------------------------------------------------------------------------------- 1 | import { BuildTasks } from './build-tasks' 2 | import yargs = require('yargs') 3 | 4 | const buildConfig = yargs.options("playbook", { 5 | alias: 'p', 6 | default: 'dev-site.yml', 7 | describe: 'Antora Playbook file to use to build the site' 8 | }).options("srcDir", { 9 | alias: 's', 10 | default: '/usr/src/app', 11 | describe: 'The documentation source root' 12 | }).options("outputDir", { 13 | alias: 'o', 14 | default: 'gh-pages', 15 | describe: 'The site generation path relative to source root' 16 | }).options("cacheDir", { 17 | alias: 'c', 18 | default: '.cache', 19 | describe: 'The Antora Cache directory' 20 | }).argv; 21 | 22 | let buildTasks = new BuildTasks(buildConfig); 23 | buildTasks.configure(); -------------------------------------------------------------------------------- /install/community-operators-csc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: operators.coreos.com/v1 2 | kind: CatalogSourceConfig 3 | metadata: 4 | name: community-operators-packages 5 | namespace: openshift-marketplace 6 | spec: 7 | targetNamespace: openshift-operators 8 | packages: knative-eventing-operator,openshift-pipelines-operator,knative-kafka-operator ,strimzi-kafka-operator 9 | source: community-operators -------------------------------------------------------------------------------- /install/csv-columns.txt: -------------------------------------------------------------------------------- 1 | NAME VERSION PHASE 2 | .metadata.name .spec.version .status.phase -------------------------------------------------------------------------------- /install/knative-eventing/subscription.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: operators.coreos.com/v1alpha1 3 | kind: Subscription 4 | metadata: 5 | name: knative-eventing 6 | namespace: openshift-operators 7 | spec: 8 | channel: alpha 9 | source: community-operators-packages 10 | name: knative-eventing-operator 11 | sourceNamespace: openshift-operators -------------------------------------------------------------------------------- /install/knative-serving/cr.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: KnativeServing 3 | metadata: 4 | name: knative-serving 5 | namespace: knative-serving 6 | spec: 7 | config: 8 | autoscaler: 9 | container-concurrency-target-default: '100' 10 | container-concurrency-target-percentage: '1.0' 11 | enable-scale-to-zero: 'true' 12 | max-scale-up-rate: '10' 13 | panic-threshold-percentage: '200.0' 14 | panic-window: 6s 15 | panic-window-percentage: '10.0' 16 | scale-to-zero-grace-period: 30s 17 | stable-window: 60s 18 | tick-interval: 2s 19 | defaults: 20 | revision-cpu-limit: 1000m 21 | revision-cpu-request: 400m 22 | revision-memory-limit: 200M 23 | revision-memory-request: 100M 24 | revision-timeout-seconds: '300' 25 | deployment: 26 | registriesSkippingTagResolving: 'ko.local,dev.local' 27 | gc: 28 | stale-revision-create-delay: 24h 29 | stale-revision-lastpinned-debounce: 5h 30 | stale-revision-minimum-generations: '1' 31 | stale-revision-timeout: 15h 32 | logging: 33 | loglevel.activator: info 34 | loglevel.autoscaler: info 35 | loglevel.controller: info 36 | loglevel.queueproxy: info 37 | loglevel.webhook: info 38 | observability: 39 | logging.enable-var-log-collection: 'false' 40 | metrics.backend-destination: prometheus 41 | tracing: 42 | enable: 'false' 43 | sample-rate: '0.1' 44 | -------------------------------------------------------------------------------- /install/knative-serving/subscription.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: operators.coreos.com/v1alpha1 3 | kind: Subscription 4 | metadata: 5 | name: knative-serving 6 | namespace: openshift-operators 7 | spec: 8 | channel: techpreview 9 | source: redhat-operators-packages 10 | name: serverless-operator 11 | sourceNamespace: openshift-operators -------------------------------------------------------------------------------- /install/observability/deploy-jaeger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | kubectl apply \ 6 | --filename https://github.com/knative/serving/releases/download/v0.12.0/monitoring-tracing-jaeger-in-mem.yaml 7 | -------------------------------------------------------------------------------- /install/observability/install-jaeger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | kubectl create namespace observability 6 | kubectl create \ 7 | -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/crds/jaegertracing.io_jaegers_crd.yaml \ 8 | -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/service_account.yaml \ 9 | -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role.yaml \ 10 | -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role_binding.yaml \ 11 | -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/operator.yaml 12 | -------------------------------------------------------------------------------- /install/observability/install-prometheus-grafana.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | kubectl apply \ 6 | --filename "https://github.com/knative/serving/releases/download/v0.12.0/monitoring-metrics-prometheus.yaml" 7 | -------------------------------------------------------------------------------- /install/redhat-operators-csc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: operators.coreos.com/v1 2 | kind: CatalogSourceConfig 3 | metadata: 4 | name: redhat-operators-packages 5 | namespace: openshift-marketplace 6 | spec: 7 | targetNamespace: openshift-operators 8 | packages: serverless-operator,servicemeshoperator,kiali-ossm,jaeger-product,elasticsearch-operator 9 | source: redhat-operators -------------------------------------------------------------------------------- /install/tektoncd-pipelines/subscription.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: operators.coreos.com/v1alpha1 3 | kind: Subscription 4 | metadata: 5 | name: openshift-pipelines 6 | namespace: openshift-operators 7 | spec: 8 | channel: dev-preview 9 | source: community-operators-packages 10 | name: openshift-pipelines-operator 11 | sourceNamespace: openshift-operators -------------------------------------------------------------------------------- /install/tutorial-tools.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: tutorial-tools 5 | namespace: che 6 | --- 7 | apiVersion: rbac.authorization.k8s.io/v1 8 | kind: ClusterRoleBinding 9 | metadata: 10 | name: tutorial-tools-binding 11 | namespace: che 12 | roleRef: 13 | kind: ClusterRole 14 | name: cluster-admin 15 | apiGroup: rbac.authorization.k8s.io 16 | subjects: 17 | - kind: ServiceAccount 18 | name: tutorial-tools 19 | namespace: che 20 | --- 21 | apiVersion: v1 22 | kind: ConfigMap 23 | metadata: 24 | name: tutorial-tools-kubeconfig 25 | namespace: che 26 | data: 27 | config: | 28 | apiVersion: v1 29 | kind: Config 30 | preferences: {} 31 | clusters: 32 | - cluster: 33 | name: knativetutorial 34 | users: 35 | - name: tutorial-tools 36 | contexts: [] -------------------------------------------------------------------------------- /install/utils/camel-k-maven-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | nexus 13 | * 14 | http://nexus:8081/repository/maven-public/ 15 | 16 | 17 | 18 | 19 | nexus 20 | 21 | 22 | 23 | 24 | central 25 | http://central 26 | 27 | true 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | central 37 | http://central 38 | 39 | true 40 | 41 | 42 | true 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | nexus 51 | 52 | -------------------------------------------------------------------------------- /install/utils/fruit-events-display.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: fruit-events-display 5 | spec: 6 | selector: 7 | app: fruit-events-display 8 | ports: 9 | - port: 80 10 | targetPort: 8080 11 | type: NodePort 12 | --- 13 | apiVersion: apps/v1 14 | kind: Deployment 15 | metadata: 16 | name: fruit-events-display 17 | spec: 18 | selector: 19 | matchLabels: 20 | app: fruit-events-display 21 | template: 22 | metadata: 23 | labels: 24 | app: fruit-events-display 25 | spec: 26 | containers: 27 | - name: fruit-events-display 28 | image: quay.io/rhdevelopers/knative-tutorial-fruit-events-display:0.0.2 29 | imagePullPolicy: Always 30 | resources: 31 | limits: 32 | memory: "128Mi" 33 | cpu: "500m" 34 | ports: 35 | - containerPort: 8080 36 | -------------------------------------------------------------------------------- /install/utils/fruityvice-proxy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: fruityvice-proxy 5 | spec: 6 | selector: 7 | app: fruityvice-proxy 8 | ports: 9 | - port: 8080 10 | targetPort: 8080 11 | type: NodePort 12 | --- 13 | apiVersion: apps/v1 14 | kind: Deployment 15 | metadata: 16 | name: fruityvice-proxy 17 | spec: 18 | selector: 19 | matchLabels: 20 | app: fruityvice-proxy 21 | template: 22 | metadata: 23 | labels: 24 | app: fruityvice-proxy 25 | spec: 26 | containers: 27 | - name: fruityvice-proxy 28 | image: quay.io/rhdevelopers/fruityvice-proxy 29 | imagePullPolicy: Always 30 | resources: 31 | limits: 32 | memory: "128Mi" 33 | cpu: "500m" 34 | ports: 35 | - containerPort: 8080 36 | -------------------------------------------------------------------------------- /install/utils/nexus.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nexus 5 | spec: 6 | type: NodePort 7 | selector: 8 | app: nexus 9 | ports: 10 | - port: 8081 11 | targetPort: 8081-tcp 12 | --- 13 | apiVersion: apps/v1 14 | kind: Deployment 15 | metadata: 16 | name: nexus 17 | spec: 18 | selector: 19 | matchLabels: 20 | app: nexus 21 | template: 22 | metadata: 23 | labels: 24 | app: nexus 25 | spec: 26 | containers: 27 | - name: nexus 28 | image: docker.io/sonatype/nexus3 29 | ports: 30 | - containerPort: 8081 31 | name: 8081-tcp 32 | livenessProbe: 33 | httpGet: 34 | path: /service/rest/v1/status 35 | port: 8081 36 | # nexus has lots of init to do first time so lets give 37 | # more time for that to happen 38 | initialDelaySeconds: 180 39 | periodSeconds: 3 40 | readinessProbe: 41 | httpGet: 42 | path: /service/rest/v1/status 43 | port: 8081 44 | # nexus has lots of init to do first time so lets give 45 | # more time for that to happen 46 | initialDelaySeconds: 180 47 | periodSeconds: 3 48 | volumeMounts: 49 | - name: nexus-data 50 | mountPath: /nexus-data 51 | volumes: 52 | - name: nexus-data 53 | emptyDir: {} 54 | -------------------------------------------------------------------------------- /lib/remote-include-processor.js: -------------------------------------------------------------------------------- 1 | module.exports = function () { 2 | this.includeProcessor(function () { 3 | this.$option('position', '>>') 4 | this.handles((target) => target.startsWith('http')) 5 | this.process((doc, reader, target, attrs) => { 6 | const contents = require('child_process').execFileSync('curl', ['--silent', '-L', target], { encoding: 'utf8' }) 7 | reader.pushInclude(contents, target, target, 1, attrs) 8 | }) 9 | }) 10 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": "true", 3 | "dependencies": { 4 | "@antora/cli": "^2.3.3", 5 | "@antora/site-generator-default": "^2.3.3", 6 | "@types/browser-sync": "^2.26.1", 7 | "@types/fs-extra": "^9.0.1", 8 | "@types/node": "^14.0.27", 9 | "browser-sync": "^2.26.12", 10 | "fs-extra": "^8.1.0", 11 | "gulp": "^4.0.0", 12 | "js-yaml": "^3.14.0", 13 | "ts-node": "^8.10.2", 14 | "typescript": "^3.9.7", 15 | "yargs": "^15.4.1" 16 | }, 17 | "license": "Apache-2.0", 18 | "devDependencies": { 19 | "@types/gulp": "^4.0.6", 20 | "@types/yargs": "^15.0.5" 21 | } 22 | } -------------------------------------------------------------------------------- /serving/colors-service-blue.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: blue-green-canary 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/blue-green-canary 10 | env: 11 | - name: BLUE_GREEN_CANARY_COLOR 12 | value: "#6bbded" 13 | - name: BLUE_GREEN_CANARY_MESSAGE 14 | value: "Hello" 15 | -------------------------------------------------------------------------------- /serving/colors-service-canary.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: blue-green-canary 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/blue-green-canary 10 | env: 11 | - name: BLUE_GREEN_CANARY_COLOR 12 | value: "#f2f25e" 13 | - name: BLUE_GREEN_CANARY_MESSAGE 14 | value: "Bonjour" 15 | -------------------------------------------------------------------------------- /serving/colors-service-green.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: blue-green-canary 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/blue-green-canary 10 | env: 11 | - name: BLUE_GREEN_CANARY_COLOR 12 | value: "#5bbf45" 13 | - name: BLUE_GREEN_CANARY_MESSAGE 14 | value: "Namaste" 15 | -------------------------------------------------------------------------------- /serving/service-10.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: prime-generator 5 | spec: 6 | template: 7 | metadata: 8 | annotations: 9 | # Target 10 in-flight-requests per pod. 10 | autoscaling.knative.dev/target: "10" 11 | spec: 12 | containers: 13 | - image: quay.io/rhdevelopers/prime-generator:v27-quarkus 14 | livenessProbe: 15 | httpGet: 16 | path: /healthz 17 | readinessProbe: 18 | httpGet: 19 | path: /healthz 20 | -------------------------------------------------------------------------------- /serving/service-min-max-scale.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: prime-generator 5 | spec: 6 | template: 7 | metadata: 8 | annotations: 9 | # the minimum number of pods to scale down to 10 | autoscaling.knative.dev/minScale: "2" 11 | # the maximum number of pods to scale up to 12 | autoscaling.knative.dev/maxScale: "5" 13 | # Target 10 in-flight-requests per pod. 14 | autoscaling.knative.dev/target: "10" 15 | spec: 16 | containers: 17 | - image: quay.io/rhdevelopers/prime-generator:v27-quarkus 18 | livenessProbe: 19 | httpGet: 20 | path: /healthz 21 | readinessProbe: 22 | httpGet: 23 | path: /healthz 24 | -------------------------------------------------------------------------------- /serving/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: serving.knative.dev/v1 2 | kind: Service 3 | metadata: 4 | name: greeter 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus 10 | livenessProbe: 11 | httpGet: 12 | path: /healthz 13 | readinessProbe: 14 | httpGet: 15 | path: /healthz 16 | -------------------------------------------------------------------------------- /site.yaml: -------------------------------------------------------------------------------- 1 | runtime: 2 | cache_dir: ./.cache/antora 3 | 4 | site: 5 | title: Knative Tutorial 6 | url: https://redhat-developer-demos.github.io/knative-tutorial 7 | start_page: knative-tutorial::index.adoc 8 | 9 | content: 10 | sources: 11 | - url: git@github.com:redhat-developer-demos/knative-tutorial.git 12 | branches: HEAD 13 | start_path: documentation 14 | asciidoc: 15 | attributes: 16 | tutorial-namespace: knativetutorial 17 | branch: master 18 | workshop-domain: guru.devx.red 19 | minikube-version: v1.28.0 20 | openshift-version: v4.8 21 | kubernetes-version: v1.23.0 22 | knative-version: v1.8.1 23 | knative-serving-version: v1.8.3 24 | net-kourier-version: v1.8.1 25 | knative-eventing-version: v1.8.5 26 | knative-sources-version: v1.1.0 27 | kn-client-version: v1.8.1 28 | camel-source-version: v0.24.0 29 | kafka-source-version: v1.8.1 30 | kamel-version: 1.11.0 31 | kubernetes-cli: kubectl 32 | release-version: master 33 | page-pagination: true 34 | openshift-console-url: https://console-openshift-console.apps.example.com 35 | etherpad-url: http://example.com 36 | extensions: 37 | - ./lib/remote-include-processor.js 38 | - ./lib/tab-block.js 39 | ui: 40 | bundle: 41 | url: https://github.com/redhat-developer-demos/rhd-tutorial-ui/releases/download/v0.1.10/ui-bundle.zip 42 | snapshot: true 43 | supplemental_files: ./supplemental-ui 44 | output: 45 | dir: ./gh-pages -------------------------------------------------------------------------------- /staging.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _CURR_DIR="$( cd "$(dirname "$0")" ; pwd -P )" 4 | rm -rf ./gh-pages .cache 5 | 6 | antora --pull --stacktrace staging.yaml -------------------------------------------------------------------------------- /staging.yml: -------------------------------------------------------------------------------- 1 | runtime: 2 | cache_dir: ./.cache/antora 3 | 4 | site: 5 | title: Knative Tutorial(Staging) 6 | url: http://redhat-developer-docs.github.io/knative-tutorial-staging 7 | start_page: knative-tutorial::index.adoc 8 | 9 | content: 10 | sources: 11 | - url: git@github.com:redhat-developer-demos/knative-tutorial.git 12 | tags: [] 13 | branches: master 14 | start_path: documentation 15 | asciidoc: 16 | attributes: 17 | tutorial-namespace: knativetutorial 18 | branch: master 19 | workshop-domain: guru.devx.red 20 | minikube-version: v1.28.0 21 | openshift-version: v4.8 22 | kubernetes-version: v1.23.0 23 | knative-version: v1.8.1 24 | knative-serving-version: v1.8.3 25 | net-kourier-version: v1.8.1 26 | knative-eventing-version: v1.8.5 27 | knative-sources-version: v1.1.0 28 | kn-client-version: v1.8.1 29 | camel-source-version: v0.24.0 30 | kafka-source-version: v1.8.1 31 | kamel-version: 1.11.0 32 | kubernetes-cli: kubectl 33 | release-version: master 34 | page-pagination: true 35 | openshift-console-url: https://console-openshift-console.apps.example.com 36 | etherpad-url: http://example.com 37 | repo-base: https://github.com/redhat-developer-demos/knative-tutorial 38 | extensions: 39 | - ./lib/remote-include-processor.js 40 | - ./lib/tab-block.js 41 | ui: 42 | bundle: 43 | url: https://github.com/redhat-developer-demos/rhd-tutorial-ui/releases/download/v0.1.10/ui-bundle.zip 44 | snapshot: true 45 | supplemental_files: ./supplemental-ui 46 | output: 47 | dir: ./gh-pages 48 | -------------------------------------------------------------------------------- /supplemental-ui/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/d60f525588332c16a1a5878f112de50efcf74727/supplemental-ui/img/favicon.ico -------------------------------------------------------------------------------- /supplemental-ui/partials/footer-nav.hbs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 1.13.4 2 | -------------------------------------------------------------------------------- /workshop.yaml: -------------------------------------------------------------------------------- 1 | runtime: 2 | cache_dir: ./.cache/antora 3 | 4 | site: 5 | title: Knative Tutorial 6 | url: https://redhat-developer-demos.github.io/knative-tutorial 7 | start_page: knative-tutorial::index.adoc 8 | 9 | content: 10 | sources: [] 11 | 12 | asciidoc: 13 | attributes: [] 14 | extensions: 15 | - ./lib/copy-to-clipboard.js 16 | - ./lib/tab-block.js 17 | ui: 18 | bundle: 19 | url: https://github.com/redhat-developer-demos/rhd-tutorial-ui/releases/download/v0.1.10/ui-bundle.zip 20 | supplemental_files: ./supplemental-ui 21 | output: 22 | dir: ./gh-pages 23 | -------------------------------------------------------------------------------- /workshopDocs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _CURR_DIR="$( cd "$(dirname "$0")" ; pwd -P )" 4 | rm -rf ./gh-pages .cache 5 | 6 | yq w workshop.yaml -s workshop-attributes.yaml > workshop-site.yaml 7 | 8 | antora --pull --stacktrace workshop-site.yaml 9 | 10 | open gh-pages/index.html --------------------------------------------------------------------------------