You want to make automatic deployment whenever the developer push some new commit in the application source code repository.
Creating New Kubernetes Cluster
Create new cluster with f1-micro machine type. For this trial purpose we will use preemptible machine to keep the cost down. Preemptible means we are using spare capacity available from GCP to create node. This node will be restart by Google every 24 hours.
Create new project in GCP and configure default zone
$ gcloud projects create atambua
$ gcloud config set project atambua
$ gcloud config set compute/zone asia-southeast1-a
$ gcloud config list
[compute]
region = asia-southeast1
zone = asia-southeast1-a
[core]
account = [email protected]
disable_usage_reporting = True
project = atambua
Check available machine type in your zone
$ gcloud compute machine-types list --filter=zone=asia-southeast1-a
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-my-cluster-default-pool-8d0c1fcb-gc08 Ready <none> 19s v1.13.11-gke.14
gke-my-cluster-default-pool-8d0c1fcb-hjjh Ready <none> 18s v1.13.11-gke.14
gke-my-cluster-default-pool-8d0c1fcb-n9b8 Ready <none> 20s v1.13.11-gke.14
Creating Google Cloud Build trigger for automatic deployment
Go to Google Cloud Build and choose to create new trigger
Connect your source repository either in Github or Google Repository to cloud build trigger
Edit your trigger configuration and create cloudbuild.yaml file
Connect repository and create trigger
Connect repo trigger
Preparing cloudbuild.yaml file
Create your own cloudbuild.yaml file (sample available in the Github)
To learn the basic of cloud build configuration open here
Make sure you already set all default config to proper value to ensure Google Cloud Build step will not failed. Set your cluster to [cluster-name]
$ gcloud config set container/cluster my-cluster
Create cloudbuild.yaml file and put in the the root directory of your project. Cloud Build will running code inside this file whenever you push new commit in the repo and automatically deploy application in the Kubernetes Engine.
This file will be apply in the cloud builder step id “deploy to gke”. File deployment.yaml will contains Kubernetes instruction to deploy container image to Kubernetes cluster:
You successfully deploy application in Kubernetes cluster.
Dengan pengalaman PT Quorum Nusa Prestasi yang luas dalam industri Teknologi Informasi, kami mendorong klien kami untuk membuka bisnis mereka terhadap peluang baru dan mewujudkan impian. Perusahaan perangkat lunak ada untuk memecahkan masalah dan membantu kehidupan, dan ini adalah prioritas utama kami.
Hubungi kami dengan menekan tombol contact us diatas atau klik disini!