{"id":22071050,"url":"https://github.com/vshn/knative-demo","last_synced_at":"2025-07-24T08:36:38.369Z","repository":{"id":72137841,"uuid":"174350049","full_name":"vshn/knative-demo","owner":"vshn","description":"Documentation to run a Knative demo","archived":false,"fork":false,"pushed_at":"2023-12-15T08:46:46.000Z","size":16,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-12-15T09:50:30.394Z","etag":null,"topics":["demo","documentation","knative","kubernetes"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vshn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-03-07T13:34:42.000Z","updated_at":"2020-02-14T20:20:18.000Z","dependencies_parsed_at":"2023-12-05T09:43:14.635Z","dependency_job_id":null,"html_url":"https://github.com/vshn/knative-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fknative-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fknative-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fknative-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fknative-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vshn","download_url":"https://codeload.github.com/vshn/knative-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227424233,"owners_count":17775294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","documentation","knative","kubernetes"],"created_at":"2024-11-30T20:22:22.898Z","updated_at":"2024-11-30T20:22:23.580Z","avatar_url":"https://github.com/vshn.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Knative Demo\n\nThis project contains demo files for giving a Knative demo to interested parties.\n\n* [Demo 1: Hello World](#demo-1-hello-world)\n* [Demo 2: Autoscaling](#demo-2-autoscaling)\n* [Demo 3: Blue/Green Deployment](#demo-3-bluegreen-deployment)\n* [Demo 4: Build](#demo-4-build)\n* [Demo 5: Eventing](#demo-5-eventing)\n\n## Prerequisits\n\n* A fresh Kubernetes cluster (1.11+) with cluster-admin rights\n* Knative installed as described in the [official docs](https://github.com/knative/docs/blob/master/install/Knative-with-any-k8s.md)\n  * Installed with Istio\n\n### Adaption: Ingressgateway service type\n\nIf the K8s cluster doesn't support services with the type `LoadBalancer`, change it to be `NodePort`:\n\n```\nkubectl -n istio-system patch svc istio-ingressgateway -p '{\"spec\":{\"type\": \"NodePort\"}}\n```\n\n## Links\n\nTo get some insights before starting the demo, checkout the following links:\n\n* [Knative Docs](https://github.com/knative/docs)\n* [Serving Resource Types / Overview](https://github.com/knative/serving/blob/master/docs/spec/overview.md)\n* [Eventing Introduction](https://github.com/knative/docs/blob/master/eventing/README.md)\n* [Build Introduction](https://github.com/knative/docs/blob/master/build/README.md)\n\n# Demo 1: Hello World\n\nThis manifest deploys a hello world application to showcase the `serving` component.\n\n```\nkubectl apply -f 01-helloworld/helloworld.yaml\n```\n\nAccess the service using the following commands:\n\n```\nexport HOST_URL=$(kubectl -n default get ksvc helloworld-go --output jsonpath='{.status.domain}')\nexport IP_ADDRESS=$(kubectl get node -o 'jsonpath={.items[0].status.addresses[0].address}'):$(kubectl -n istio-system get svc istio-ingressgateway -o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')\n\ncurl -H \"Host: ${HOST_URL}\" http://${IP_ADDRESS}\n```\n\nInteresting parts:\n* Pod gets scaled down automatically when not in use after ...\n* Many objects get automatically created by the `Service` object:\n  * **Route**: provides a named endpoint and a mechanism for routing traffic to: `kubectl -n default get route`\n  * **Revisions**: immutable snapshots of code + config: `kubectl -n default get revision`\n  * **Configuration**: acts as a stream of environments for Revisions: `kubectl -n default get configuration`\n  * See graphic: https://github.com/knative/serving/blob/master/docs/spec/overview.md#resource-types\n\nEditing the service using `kubectl -n default edit ksvc helloworld-go` creates a new revision.\n\n* Demo credits: [Getting Started with Knative App Deployment](https://github.com/knative/docs/blob/master/install/getting-started-knative-app.md).\n* [Hello World App Source](https://github.com/knative/docs/tree/master/serving/samples/helloworld-go)\n\n# Demo 2: Autoscaling\n\nDeploy the sample application using:\n\n```\nkubectl apply -f 02-autoscaling/autoscale.yaml\n```\n\nAccess the service using the following commands:\n\n```\nexport HOST_URL=$(kubectl -n default get ksvc autoscale-go --output jsonpath='{.status.domain}')\nexport IP_ADDRESS=$(kubectl get node -o 'jsonpath={.items[0].status.addresses[0].address}'):$(kubectl -n istio-system get svc istio-ingressgateway -o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')\n\ncurl -H \"Host: ${HOST_URL}\" \"http://${IP_ADDRESS}?sleep=100\u0026prime=10000\u0026bloat=5\"\n```\n\nInstall the `hey` load generator (`go get -u github.com/rakyll/hey`) and generate some load:\n\n```\nhey -z 30s -c 50 \\\n  -host \"${HOST_URL}\" \\\n  \"http://${IP_ADDRESS?}?sleep=100\u0026prime=10000\u0026bloat=5\" \u0026\nwatch kubectl get po\n```\n\nWhat happens here is described under [Algorithm](https://github.com/knative/docs/tree/master/serving/samples/autoscale-go#algorithm)\n\nInteresting metrics can be found in Grafana dashboards:\n\n* [Knative Serving - Scaling Debugging](http://localhost:3000/d/u_-9SIMiz/knative-serving-scaling-debugging?orgId=1\u0026refresh=5s\u0026from=now-15m\u0026to=now)\n* [Knative Serving - Revision HTTP Requests](http://localhost:3000/d/im_gFbWik/knative-serving-revision-http-requests?refresh=5s\u0026orgId=1)\n\nTo access the Grafana Dashboard, start port-forwarding:\n\n```\nkubectl port-forward --namespace knative-monitoring \\\n$(kubectl get pods --namespace knative-monitoring \\\n--selector=app=grafana --output=jsonpath=\"{.items..metadata.name}\") \\\n3000\n```\n\nStatus of autoscaler can be retrieved using:\n\n```\nkubectl get kpa\n```\n\n* Demo credits: [Autoscale Sample](https://github.com/knative/docs/tree/master/serving/samples/autoscale-go).\n* [Autoscale App Source](https://github.com/knative/docs/tree/master/serving/samples/autoscale-go)\n\n# Demo 3: Blue/Green Deployment\n\nDeploy the initial blue deployment:\n\n```\nkubectl apply -f 03-bluegreen/01-blue-green-demo-config.yaml\n```\n\nGet name of the generated revision and write this name into the route object:\n\n```\nkubectl get revision -l serving.knative.dev/configuration=blue-green-demo\nexport REV01=\u003cname\u003e\ncat 03-bluegreen/02-blue-green-demo-route.yaml | sed \"s/blue-green-demo-00001/$REV01/\" | kubectl apply -f -\n```\n\nAccess the service:\n\n```\nexport HOST_URL=blue-green-demo.default.example.com\nexport IP_ADDRESS=$(kubectl get node -o 'jsonpath={.items[0].status.addresses[0].address}'):$(kubectl -n istio-system get svc istio-ingressgateway -o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')\n\ncurl -H \"Host: ${HOST_URL}\" \"http://${IP_ADDRESS}/\"\n```\n\nNow change the configuration with updated parameters:\n\n```\nkubectl apply -f 03-bluegreen/03-blue-green-demo-config.yaml\n```\n\nAccessing the route will still serve the initial version, we can now update\nthe route to point to the new revision:\n\n```\nkubectl get revision -l serving.knative.dev/configuration=blue-green-demo\nexport REV02=\u003cname\u003e\ncat 03-bluegreen/04-blue-green-demo-route.yaml | \\\n  sed \"s/blue-green-demo-00001/$REV01/\" | \\\n  sed \"s/blue-green-demo-00002/$REV02/\" | \\\n  kubectl apply -f -\n\ncurl -H \"Host: v2.${HOST_URL}\" \"http://${IP_ADDRESS}/\"\n```\n\nThe new revision is now available under this new URL.\n\nLet's send 50% of the requests to the new version:\n\n```\ncat 03-bluegreen/05-blue-green-demo-route.yaml | \\\n  sed \"s/blue-green-demo-00001/$REV01/\" | \\\n  sed \"s/blue-green-demo-00002/$REV02/\" | \\\n  kubectl apply -f -\n\nwatch -n1 \"curl -H \\\"Host: ${HOST_URL}\\\" \\\"http://${IP_ADDRESS}/\\\" -s --raw\"\n```\n\nThe new version is still available under the v2 URL.\n\nIt's time to switch completely to v2, but let v1 accessible:\n\n```\ncat 03-bluegreen/06-blue-green-demo-route.yaml | \\\n  sed \"s/blue-green-demo-00001/$REV01/\" | \\\n  sed \"s/blue-green-demo-00002/$REV02/\" | \\\n  kubectl apply -f -\n\ncurl -H \"Host: ${HOST_URL}\" \"http://${IP_ADDRESS}/\"\ncurl -H \"Host: v1.${HOST_URL}\" \"http://${IP_ADDRESS}/\"\n```\n\n* Demo credits: [Routing and managing traffic with blue/green deployment](https://github.com/knative/docs/blob/master/serving/samples/blue-green-deployment.md).\n* [Blue/Green App Source](https://github.com/mchmarny/knative-route-demo)\n\n# Demo 4: Build\n\nThis demo uses Kaniko, install the build template first:\n\n```\nkubectl apply -f 04-build/kaniko.yaml\n```\n\nAccess to a container registry needs to be configured. Amend the YAML file accordingly.\nAfter that, apply the manifest to start building and deploying the application:\n\n```\nkubectl apply -f 04-build/build.yaml\n```\n\nBuild is now running in a Pod using init containers. To view logs, use:\n\n```\nkubectl -n default logs \u003cbuildpod\u003e -c build-step-credential-initializer\nkubectl -n default logs \u003cbuildpod\u003e -c build-step-git-source-0\nkubectl -n default logs \u003cbuildpod\u003e -c build-step-build-and-push\n```\n\nAfter the build has finished it's job, a deployment is made. The app can be reached under:\n\n```\nexport HOST_URL=$(kubectl -n default get ksvc app-from-source --output jsonpath='{.status.domain}')\nexport IP_ADDRESS=$(kubectl get node -o 'jsonpath={.items[0].status.addresses[0].address}'):$(kubectl -n istio-system get svc istio-ingressgateway -o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')\n\ncurl -H \"Host: ${HOST_URL}\" \"http://${IP_ADDRESS}/\"\n```\n\n* Demo credits: [Orchestrating a source-to-URL deployment on Kubernetes](https://github.com/knative/docs/blob/master/serving/samples/source-to-url-go/README.md).\n* [Build App Source](https://github.com/mchmarny/simple-app)\n\n# Demo 5: Eventing\n\nApply the manifest to define a service (sink) and an eventsource:\n\n```\nkubectl apply -f 05-eventing/eventing.yaml\n```\n\nA `CronJobSource` is now deployed which creates an event every 2 minutes. The events are\ncatched by the sink app called message-dumper:\n\n```\nkubectl logs -l serving.knative.dev/service=message-dumper -c user-container --since=10m\n```\n\n* Demo credits: [Cron Job Source example](https://github.com/knative/docs/tree/master/eventing/samples/cronjob-source).\n* [Message Dumper App Source](https://github.com/knative/eventing-sources/tree/master/cmd/message_dumper)\n\n# Demo Magic Usage\n\nStart the demo using `./start-demo.sh`. By default it runs all demos, specifying `-z \"n n n\"`, where `n` are\nthe demo numbers, let's you choose which demo(s) to run. With `-x` (combined with f.e. `-z \"\"`) a manifest cleanup\ncan be triggered.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshn%2Fknative-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvshn%2Fknative-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshn%2Fknative-demo/lists"}