Ensure you have a GKE cluster created
Fork the repo and modify the following files before you proceeed
- Change the Image, location and cluster under args
- Change the project under the image to your project name
- Change the Branch, ProjectID and Repo under triggerTemplate
To use this builder, your builder service account will need IAM permissions sufficient for the operations you want to perform. For typical read-only usage, the "Kubernetes Engine Viewer" role is sufficient. To deploy container images on a GKE cluster, the "Kubernetes Engine Developer" role is sufficient. Check the GKE IAM page for details.
Change core-demos to your Project name
gcloud config set project core-demos
gcloud services enable containerregistry.googleapis.com
gcloud services enable cloudbuild.googleapis.com
Change the details to your GKE Cluster setup
gcloud container clusters get-credentials --zone=us-central1-c devops-demo
PROJECT="$(gcloud projects describe \
$(gcloud config get-value core/project -q) --format='get(projectNumber)')"
gcloud projects add-iam-policy-binding $PROJECT \
--member=serviceAccount:[email protected] \
--role=roles/container.developer
Change YOURID to your Github ID
git clone https://github.com/YOURID/gcp-devops
cd gcp-devops
Change core-demos to your Project name
docker build -t exapp .
docker tag exapp gcr.io/core-demos/exapp
docker push gcr.io/core-demos/exapp
kubectl apply -f deployment.yaml
gcloud builds submit --config=cloudbuild.yaml
kubectl logs -lrun=exapp -f
ssh-keygen -t rsa -b 4096 -C "source repo build [email protected]" -f ~/.ssh/myrepokey -P ''
cat ~/.ssh/myrepokey.pub
https://source.cloud.google.com/user/ssh_keys
gcloud source repos create mycode-repo
gcloud source repos describe mycode-repo
git config user.email [email protected]
User should be your Cloud Identity
cat > ~/.ssh/config <<EOF
Host source.developers.google.com
HostName source.developers.google.com
User [email protected]
IdentityFile ~/.ssh/myrepokey
EOF
Change IDENTITY to your Cloud Identity and PROJECT to your Project Name
git remote add google ssh://[email protected]@source.developers.google.com:2022/p/core-demos/r/mycode-repo
git add .
git commit -m "files"
git push --all google
# Create the cloud build trigger
gcloud beta builds triggers import --source=trigger.yaml --verbosity debug
gcloud beta builds triggers list
vim main.go
git add .
git commit -m "update 1"
git push --all google
watch -t -n2 kubectl logs -lrun=exapp
kubectl get events --sort-by='{.lastTimestamp}' --namespace=default --watch
- Cloud Build History
- Container Registry
- Cloud Source Repositories