Link to the Architecture Diagram
-
Get the billing accounts list
gcloud alpha billing accounts list
-
Get the Organisation ID
ORGANISATION_ID=$(gcloud organizations describe codeworks.fr --format=json | jq '.name' | cut -f 2 -d '/' | sed 's/"//g') -
Name the project
PROJECT_NAME=codeday-canary-deployment-demo
-
Create new project
gcloud projects create ${PROJECT_NAME} --organization=${ORGANISATON_ID}
-
Get the project number
PROJECT_NUMBER=$(gcloud projects describe $PROJECT_NAME --format='value(projectNumber)') -
Link the project to the billing account
gcloud alpha billing accounts projects link ${PROJECT_NUMBER} --account-id=0150EE-171E17-3E357F -
Inspects
-
From your terminal
gcloud projects list
-
From the Google Cloud Console
-
- Configure the gcloud tool to match account / project / zone to use from scratch
gcloud init
- Display zones list
gcloud compute zones list
- Another init !! to init the compute zone
gcloud init
- Checl all of the configuration
gcloud config list
-
Build docker images
- Stable version
cd nodeapp/stable docker build -t gcr.io/${PROJECT_NAME}/nodeapp-stable:1.0.0 .
- Canary version
cd nodeapp/canary docker build -t gcr.io/${PROJECT_NAME}/nodeapp-canary:1.0.0 .
-
Launch the Docker image in your local host
-
Launch the stable image
docker run --publish 9000:7070 --detach --name stable-app gcr.io/${PROJECT_NAME}/nodeapp-stable:1.0.0 -
Launch the canary image
docker run --publish 9001:7070 --detach --name canary-app gcr.io/${PROJECT_NAME}/nodeapp-canary:1.0.0 -
Test containers using localhost
Stable Version
Canary Version
-
Test containers using internal IP address
Stable Version
Canary Version
-
-
Login :set up a credential helper
gcloud auth configure-docker
-
Push all of images to the GCR
-
Stable version
docker push gcr.io/${PROJECT_NAME}/nodeapp-stable:1.0.0 -
Canary version
docker push gcr.io/${PROJECT_NAME}/nodeapp-canary:1.0.0
-
gcloud container clusters create stable-canary-cluster --num-nodes=2-
Create a new Namespace
kubectl create ns stable-canary
-
Create Deployment Resource
-
Stable Application
cat ./k8s/app-stable.deployment.yml | sh ./k8s/config.sh | kubectl create --save-config --record -f -
-
Canary Application
cat ./k8s/app-canary.deployment.yml | sh ./k8s/config.sh | kubectl create --save-config --record -f -
-
-
Create Service Resource
kubectl create -f ./k8s/app.service.yml -n stable-canary --save-config --record
-
Open a browser and pick the external service IP address and launch it
-
Using a shell script : update the script ./curl_loadbalancer_service.sh with the right external service IP address
./curl_loadbalancer_service.sh
-
Stable version
update app-stable.deployment.yml => replicas: 2
cat ./k8s/app-stable.deployment.yml | sh ./k8s/config.sh | kubectl apply --record -f -
-
Canary version
update app-canary.deployment.yml => replicas: 2
cat ./k8s/app-canary.deployment.yml | sh ./k8s/config.sh | kubectl apply --record -f -
-
Stable version
update app-stable.deployment.yml => replicas: 0
cat ./k8s/app-stable.deployment.yml | sh ./k8s/config.sh | kubectl apply --record -f -
-
Canary version
update app-canary.deployment.yml => replicas: 4
cat ./k8s/app-canary.deployment.yml | sh ./k8s/config.sh | kubectl apply --record -f -
-
Delete the Services
kubectl delete service nodeapp-service -n stable-canary
-
Delete the Deloyments
kubectl delete deployment stable -n stable-canary kubectl delete deployment canary -n stable-canary
-
Delete the Namespace
kubectl delete ns stable-canary
-
Delete the Cluster
gcloud container clusters delete stable-canary-cluster
-
Delete the specific images
gcloud container images delete gcr.io/${PROJECT_NAME}/nodeapp-stable:1.0.0 gcloud container images delete gcr.io/${PROJECT_NAME}/nodeapp-canary:1.0.0
-
Delete the GCP Project
gcloud projects delete $PROJECT_NAME