{"id":18804875,"url":"https://github.com/idvoretskyi/knative-demo","last_synced_at":"2025-09-02T12:32:15.550Z","repository":{"id":70396988,"uuid":"152453787","full_name":"idvoretskyi/knative-demo","owner":"idvoretskyi","description":"Just a brief and simple demo of KNative","archived":false,"fork":false,"pushed_at":"2018-11-29T13:17:57.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-07T22:46:30.424Z","etag":null,"topics":["demo","demo-app","knative","kubernetes","serverless"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idvoretskyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-10T16:19:31.000Z","updated_at":"2024-06-13T06:15:32.000Z","dependencies_parsed_at":"2023-02-24T11:45:34.387Z","dependency_job_id":null,"html_url":"https://github.com/idvoretskyi/knative-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idvoretskyi%2Fknative-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idvoretskyi%2Fknative-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idvoretskyi%2Fknative-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idvoretskyi%2Fknative-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idvoretskyi","download_url":"https://codeload.github.com/idvoretskyi/knative-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231785214,"owners_count":18426286,"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","demo-app","knative","kubernetes","serverless"],"created_at":"2024-11-07T22:40:35.642Z","updated_at":"2024-12-29T20:44:48.152Z","avatar_url":"https://github.com/idvoretskyi.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"knative-demo\n============\n\nA brief and small demo of [Knative](https://github.com/knative/) - the [Kubernetes](https://kubernetes.io)-based platform to build, deploy, and manage modern serverless workloads\n\nInstalling Knative\n------------------\n\nThe instructions on how to install KNative are available in the official [Knative repo](https://github.com/knative/docs/tree/master/install).\n\nAlternatively, you may install Knative on GKE (Google Kubernetes Engine) just running the [install-knative-gke.sh](scripts/install-knative-gke.sh) script, available in this repo, or just copy and paste the following to your shell (use carefully!):\n\n```\ncurl -sSL https://git.io/fpVaH | bash\n```\n\nPS. This script will create a 3-node Kubernetes cluster on GKE with the *n1-standard-4* machine type. Please, check the GKE documentation to find more details (as well as pricing) about the [machine types](https://cloud.google.com/compute/docs/machine-types).\n\nDeploying Applications\n----------------------\n\n### Hello World Sample\n\n-\tCreate a new file named `helloworld.go` and paste the following code. This code creates a basic web server which listens on port 8080:\n\n\t```go\n\tpackage main\n\n\timport (\n\t\t\"flag\"\n\t\t\"fmt\"\n\t\t\"log\"\n\t\t\"net/http\"\n\t\t\"os\"\n\t)\n\n\tfunc handler(w http.ResponseWriter, r *http.Request) {\n\t\tlog.Print(\"Hello world received a request.\")\n\t\ttarget := os.Getenv(\"TARGET\")\n\t\tif target == \"\" {\n\t\t\ttarget = \"World\"\n\t\t}\n\t\tfmt.Fprintf(w, \"Hello %s!\\n\", target)\n\t}\n\n\tfunc main() {\n\t\tflag.Parse()\n\t\tlog.Print(\"Hello world sample started.\")\n\n\t\thttp.HandleFunc(\"/\", handler)\n\t\thttp.ListenAndServe(\":8080\", nil)\n\t}\n\t```\n\n\t-\tCreate a `Dockerfile` with the following contents:\n\n\t```docker\n\t# Start from a Debian image with the latest version of Go installed\n\t# and a workspace (GOPATH) configured at /go.\n\tFROM golang\n\n\t# Copy the local package files to the container's workspace.\n\tADD . /go/src/github.com/knative/docs/helloworld\n\n\t# Build the helloworld command inside the container.\n\t# (You may fetch or manage dependencies here,\n\t# either manually or with a tool like \"godep\".)\n\tRUN go install github.com/knative/docs/helloworld\n\n\t# Run the helloworld command by default when the container starts.\n\tENTRYPOINT /go/bin/helloworld\n\n\t# Document that the service listens on port 8080.\n\tEXPOSE 8080\n\t```\n\n-\tCreate a service.yaml file with the following contents:\n\n```yaml\napiVersion: serving.knative.dev/v1alpha1 # Current version of Knative\nkind: Service\nmetadata:\n  name: helloworld-go # The name of the app\n  namespace: default # The namespace the app will use\nspec:\n  runLatest:\n    configuration:\n      revisionTemplate:\n        spec:\n          container:\n            image: gcr.io/${KNATIVE_PROJECT}/helloworld-go # The URL to the image of the app\n            env:\n            - name: TARGET # The environment variable printed out by the sample app\n              value: \"Go Sample v1\"\n```\n\n### Building and deploying\n\n-\tBuild the container image locally:\n\n```shell\ndocker build -t gcr.io/${KNATIVE_PROJECT}/helloworld-go .\n```\n\n-\tPush it to the remote registry:\n\n```shell\ndocker push gcr.io/${KNATIVE_PROJECT}/helloworld-go\n```\n\n-\tApply the configuration\n\n\t```\n\tkubectl apply --filename service.yaml\n\t```\n\n-\tFind the IP address of your service (and export it as a system variable):\n\n\t```\n\tkubectl get svc knative-ingressgateway --namespace istio-system\n\texport IP_ADDRESS=$(kubectl get svc knative-ingressgateway --namespace istio-system --output 'jsonpath={.status.loadBalancer.ingress[0].ip}')\n\t```\n\n-\tFind the URL of your service (and export it as a system variable):\n\n\t```\n\tkubectl get services.serving.knative.dev helloworld-go  --output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain\n\texport HOST_URL=$(kubectl get services.serving.knative.dev helloworld-go  --output jsonpath='{.status.domain}')\n\t```\n\n-\tRequest the app and see the results:\n\n```shell\ncurl -H \"Host: ${HOST_URL}\" http://${IP_ADDRESS}\nHello World: Go Sample v1!\n```\n\n*Based on the official [Knative documentation](https://github.com/knative/docs/blob/master/serving/samples/helloworld-go/README.md), licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidvoretskyi%2Fknative-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidvoretskyi%2Fknative-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidvoretskyi%2Fknative-demo/lists"}