{"id":18941495,"url":"https://github.com/mchmarny/knative-gitops-using-cloud-build","last_synced_at":"2025-04-15T20:32:02.520Z","repository":{"id":45338817,"uuid":"167064468","full_name":"mchmarny/knative-gitops-using-cloud-build","owner":"mchmarny","description":"GitOps demo using Cloud Build and Knative","archived":false,"fork":false,"pushed_at":"2021-12-20T09:04:29.000Z","size":252,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T12:36:50.236Z","etag":null,"topics":["build","cloud","github","knative"],"latest_commit_sha":null,"homepage":"https://knative.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mchmarny.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}},"created_at":"2019-01-22T20:44:39.000Z","updated_at":"2019-09-28T03:52:26.000Z","dependencies_parsed_at":"2022-09-02T00:02:12.356Z","dependency_job_id":null,"html_url":"https://github.com/mchmarny/knative-gitops-using-cloud-build","commit_stats":null,"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fknative-gitops-using-cloud-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fknative-gitops-using-cloud-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fknative-gitops-using-cloud-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fknative-gitops-using-cloud-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mchmarny","download_url":"https://codeload.github.com/mchmarny/knative-gitops-using-cloud-build/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249148032,"owners_count":21220465,"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":["build","cloud","github","knative"],"created_at":"2024-11-08T12:28:16.912Z","updated_at":"2025-04-15T20:32:02.049Z","avatar_url":"https://github.com/mchmarny.png","language":"Go","readme":"# knative-gitops-using-cloud-build\n\n\u003e GitOps demo using Cloud Build and Knative\n\nLive demo: https://gocr.demo.knative.tech/\n\nSimple setup to automate Knative deployments using Git and Cloud Build\n\nAs a developer, you write code and commit it to a repo. You also hopefully run tests on that code for each commit. Assuming your application passes all the tests, you may want to deploy it to Knative cluster. You can do it form your workstation by using any one of the Knative CLIs (e.g. gcloud, knctl, tm etc.).\n\nIn this demo however we are going to demonstrate deploying directly from git repository. This means that you as a developer do not need install anything on your machine other than the standard git tooling. Here is the outline:\n\n* Create a release tag on the commit you want to deploy in git\n* Cloud Build then:\n  * Tests (again)\n  * Builds and tags image\n  * Pushes that image to repository\n  * Creates Knative service manifest\n  * Applies that manifest to designated Knative cluster\n\n\u003e As an add-on, we are also going to send mobile notification with build status using [knative-build-status-notifs](https://github.com/mchmarny/knative-build-status-notifs)\n\n## Setup\n\nYou will have to [configure git trigger](https://pantheon.corp.google.com/cloud-build/triggers/add) in Cloud Build first. There doesn't seem to be a way to do this using `gcloud`.\n\n![kpush flow](static/img/src.png)\n\nThen setup IAM policy binding to allow Cloud Builder deploy build image to your cluster\n\n```shell\nPROJECT_NUMBER=\"$(gcloud projects describe ${PROJECT_ID} --format='get(projectNumber)')\"\ngcloud projects add-iam-policy-binding ${PROJECT_NUMBER} \\\n    --member=serviceAccount:${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com \\\n    --role=roles/container.developer\n```\n\nFinally submit the Cloud Build configuration\n\n```shell\ngcloud builds submit --config deployments/cloudbuild.yaml\n```\n\n![kpush flow](static/img/trigger.png)\n\n## Deployment\n\nTo build and deploy specific commit from git, tag it and publish the tags. We also are going to print the last few tags so we can see the exact commit hash.\n\n```shell\ngit tag \"release-v${RELEASE_VERSION}\"\ngit push origin \"release-v${RELEASE_VERSION}\"\ngit log --oneline\n```\n\n## Logs\n\nYou can monitor progress of your build but first finding its id\n\n```shell\ngcloud builds list\n```\n\nAnd then describing it\n\n```shell\ngcloud builds describe BUILD_ID\n```\n\nYou can always also navigate to the [Build History](https://pantheon.corp.google.com/cloud-build/builds?folder=\u0026organizationId=433637338589\u0026project=s9-demo) screen in UI and see it there.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmchmarny%2Fknative-gitops-using-cloud-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmchmarny%2Fknative-gitops-using-cloud-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmchmarny%2Fknative-gitops-using-cloud-build/lists"}