Getting Started with Google Container Builder – Part 3

November 20, 2017

Note: This is the third part in a series of posts Getting Started with Google Container Builder


 

Configure Google Kubernetes Engine and deploy the application

In this part we will configure a simple Kubernetes cluster to use it to deploy the application.

Variables that will be used in this demo:

[PROJECT_ID]: sdp-demo-185120
[YOUR_ZONE]: europe-west1-c
[YOUR_REGION]: europe-west1
[CLUSTER_NAME]: demo-cluster

 

• Open the shell console and set the following variables:

gcloud config set project [PROJECT_ID]
gcloud config set compute/zone [YOUR_ZONE]
gcloud config set compute/region [YOUR_REGION]

Image

 

• Confirm that the variables were set

gcloud config list

Image

 

• Create a kubernetes cluster

gcloud container clusters create [CLUSTER_NAME] --num-nodes 3

Image

 

• Deploy the image created before to the cluster (manually)

kubectl run demo-app --image=gcr.io/[PROJECT_ID]/sdp-demo-app:[IMAGE_TAG]

Image

 

• Verify that the pods are running

kubectl get pods

Image

 

• Expose the demo-app as an external service

kubectl expose deployment demo-app --port=80 --target-port=3000 --type=LoadBalancer

Image

 

• Find the network load balancer address

kubectl get service demo-app

Image

 

• Browse to the deployed site

http://EXTERNAL_IP

Image

 

• Scale the application

kubectl scale deployment demo-app --replicas=3

Image

 

• Give Container Builder Service Account (container.developer) role access to your Container Engine clusters

PROJECT=''$(gcloud projects describe \
    $(gcloud config get-value core/project -q) --format='get(projectNumber)')''

gcloud projects add-iam-policy-binding $PROJECT \
    --member=serviceAccount:$PROJECT@cloudbuild.gserviceaccount.com \
    --role=roles/container.developer

Image

Image

 
 

Continue with: Getting Started with Google Container Builder – Part 4

 

Add comment
facebook linkedin twitter email

Leave a Reply