[GSP005] Hello Node Kubernetes


You can find coupons for labs here. I didn’t pay money for this. Because i am poor.

I will use my own application

$ export PROJECT_ID=$(gcloud config get-value project)
$ gcloud config set project ${PROJECT_ID}

$ gcloud container clusters create hello-world \
            --num-nodes 2 \
            --machine-type n1-standard-1 \
            --zone us-central1-a

$ git clone https://github.com/webmakaka/cats-app
$ cd cats-app

$ docker build -t gcr.io/${PROJECT_ID}/hello-node:v1 .

$ docker push gcr.io/${PROJECT_ID}/hello-node:v1

$ kubectl run hello-node \
--image=gcr.io/${PROJECT_ID}/hello-node:v1 \

$ kubectl expose deployment hello-node --type="LoadBalancer"

$ kubectl scale deployment hello-node --replicas=4

$ kubectl get services
NAME         TYPE           CLUSTER-IP   EXTERNAL-IP     PORT(S)          AGE
hello-node   LoadBalancer   8080:31312/TCP   2m23s
kubernetes   ClusterIP     <none>          443/TCP          5m8s

Roll out an upgrade to your service

$ cd ~/cats-app/views/layouts

$ vi main.html
A node.js Voting Game

replace to

A node.js Voting Game in GKE

$ cd ~/cats-app/

$ docker build -t gcr.io/${PROJECT_ID}/hello-node:v2 .
$ docker push gcr.io/${PROJECT_ID}/hello-node:v2

$ kubectl edit deployment hello-node

Spec > containers > image

replace image version from v1 to v2