Skip to content

Commit 9c58dc1

Browse files
Kubernetes deployment steps updated
1 parent adbc26e commit 9c58dc1

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

Containers/Kubernetes-examples/GCP/steps.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Note: These steps are for Ubuntu. Feel free to use Mac OS if you like.
55
You will have to figure out how to install Docker and Google Cloud CLI on Mac OS.
66

77
1) 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)
1011
SSH 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

3031
3) Build and Push Application Docker container to Google Container Registry (GCR)
3132
cd greetings
33+
export PROJECT_ID=<Your-project-name>
3234
docker build -t gcr.io/${PROJECT_ID}/greetings:v1 .
3335

3436
Enable Google Container Registry API in Cloud Console at
@@ -40,7 +42,7 @@ gcloud docker -- push gcr.io/${PROJECT_ID}/greetings:v1
4042

4143

4244
4) 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

4547
5) Create a GKE cluster
4648
gcloud 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

5355
7) 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).
5660
sudo apt-get install mysql-client
5761
gcloud sql instances list
5862
mysql -h <IP-address-of-SQL-Instance> --user=root --password='testpass123!@#'
5963
mysql>create database testdb;
6064

6165

62-
7) Install kubectl
66+
8) Install kubectl
6367
gcloud components install kubectl
6468

6569

66-
8) Deploy application container
70+
9) Deploy application container
6771
Edit greetings-deployment.yaml and set the environment variables
6872
kubectl create -f greetings-deployment.yaml
6973
kubectl 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
7377
kubectl get services
7478
kubectl get deployments
7579
kubectl get pods
7680
kubectl describe pods <pod-name>
7781
kubectl describe deployments <deployment-name>
7882
kubectl 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)
8084
kubectl 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)
8488
kubectl delete service <service-name>
8589
kubectl delete deployment <deployment-name>
8690
Delete the GKE cluster from Google Cloud Console

0 commit comments

Comments
 (0)