@@ -5,7 +5,8 @@ Note: These steps are for Ubuntu. Feel free to use Mac OS if you like.
55You will have to figure out how to install Docker and Google Cloud CLI on Mac OS.
66
771) Install Docker and gcloud CLI
8- Create free tier EC2 instance
8+ In order to use Ubuntu VM one option is to use free tier EC2 instance where you can
9+ then install the required tools and CLIs.
910- create Ubuntu 16.04 EC2 instance (free tier). Allow ingress for port 22 from anywhere (0.0.0.0/0)
1011SSH into EC2 instance
1112- To SSH, $ chmod 400 <your-key-pair>.pem ; $ ssh -i <your-key-pair>.pem ubuntu@<ec2 instance endpoint url>
@@ -29,6 +30,7 @@ gcloud config set project ${PROJECT_ID}
2930
30313) Build and Push Application Docker container to Google Container Registry (GCR)
3132cd greetings
33+ export PROJECT_ID=<Your-project-name>
3234docker build -t gcr.io/${PROJECT_ID}/greetings:v1 .
3335
3436Enable Google Container Registry API in Cloud Console at
@@ -40,7 +42,7 @@ gcloud docker -- push gcr.io/${PROJECT_ID}/greetings:v1
4042
4143
42444) Enable Kubernetes Engine API in Cloud Console at
43- https://console.cloud.google.com/apis/api/container.googleapis.com/overview?project=4 {PROJECT_ID}
45+ https://console.cloud.google.com/apis/api/container.googleapis.com/overview?project=$ {PROJECT_ID}
4446
45475) Create a GKE cluster
4648gcloud container clusters create --machine-type=g1-small --num-nodes=1 testcluster1
@@ -51,36 +53,38 @@ gcloud sql instances create instance1 --tier=db-f1-micro --authorized-networks=0
5153
5254
53557) Create testdb database on the Cloud SQL instance
54- gcloud sql users set-password root --instance=instance1 --host=35.184.210.53 --password='testpass123!@#'
56+
57+ gcloud sql users set-password root --host % --instance instance1 --password 'testpass123!@#'
58+
5559(If for some reason above command fails, you can set the password from Google CloudSQL console).
5660sudo apt-get install mysql-client
5761gcloud sql instances list
5862mysql -h <IP-address-of-SQL-Instance> --user=root --password='testpass123!@#'
5963mysql>create database testdb;
6064
6165
62- 7 ) Install kubectl
66+ 8 ) Install kubectl
6367gcloud components install kubectl
6468
6569
66- 8 ) Deploy application container
70+ 9 ) Deploy application container
6771Edit greetings-deployment.yaml and set the environment variables
6872kubectl create -f greetings-deployment.yaml
6973kubectl expose deployments --port=80 --target-port=5000 --type=LoadBalancer greetings-deployment
7074
7175
72- 9 ) Verify if relevant Kubernetes Objects have been created or not
76+ 10 ) Verify if relevant Kubernetes Objects have been created or not
7377kubectl get services
7478kubectl get deployments
7579kubectl get pods
7680kubectl describe pods <pod-name>
7781kubectl describe deployments <deployment-name>
7882kubectl describe service <service-name>
79- Once you get EXTERNAL-IP of the service, open it up in browser (It may take couple of minutes for the application to respond)
83+ Once you get EXTERNAL-IP of the service, open it up in browser (it may take couple of minutes for the application to respond)
8084kubectl logs <pod-name>
8185
8286
83- 10 ) Clean-up steps (Do these only after your assignment has been graded)
87+ 11 ) Clean-up steps (Do these only after your assignment has been graded)
8488kubectl delete service <service-name>
8589kubectl delete deployment <deployment-name>
8690Delete the GKE cluster from Google Cloud Console
0 commit comments