Google Kubernetes Engine (GKE) provides a managed environment for deploying, managing, and scaling your containerized applications using Google infrastructure. The GKE environment consists of multiple machines (specifically, Compute Engine instances) grouped together to form a cluster.
In this lab, we will download a sample app from GitHub and learn how to deploy applications to Kubernetes Engine.
Download a sample app from GitHub
Download a sample application from GitHub and preview it in Cloud Shell.
1. In the Cloud Console, click Activate Cloud Shell.
2. If prompted, click Continue.
3. To create a new folder, run the following command:
mkdir gcp-course
4. Change to the folder you just created:
cd gcp-course
5. Clone a simple Python Flask app from GitHub:
git clone https://GitHub.com/GoogleCloudPlatform/training-data-analyst.gitcontent_copy

6. Change to the deploying-apps-to-gcp folder:
cd training-data-analyst/courses/design-process/deploying-apps-to-gcp

7. To test the program, enter the following command to install requirements and then start the program:
sudo pip3 install -r requirements.txt
python3 main.py


8. To see the program running, click Web Preview in the toolbar of Google Cloud Shell. Then, select Preview on port 8080.
The program should be displayed in a new browser tab.

9. In Cloud Shell, type Ctrl+C to stop the program.
Deploy to Kubernetes Engine:
Kubernetes Engine allows you to create a cluster of machines and deploy any number of applications to it. Kubernetes abstracts the details of managing machines and allows you to automate the deployment of your applications with simple CLI commands.
To deploy an application to Kubernetes, you first need to create the cluster. Then you need to add a configuration file for each application you will deploy to the cluster.
- On the Navigation menu, click Kubernetes Engine. If a message appears saying the Kubernetes API is being initialized, wait for it to complete.
- Click Create cluster.

3. Accept all the defaults, and click Create. It will take a couple of minutes for the Kubernetes Engine cluster to be created.


4. When the cluster is ready, a green check appears, click Connect.
5. In the Connect to the cluster screen, click Run in Cloud Shell. This opens Cloud Shell with the connect command entered automatically.

6. Press Enter to connect to the cluster.
7. To test your connection, enter the following command:
kubectl get nodes
This command simply shows the machines in your cluster. If it works, you’re connected.

8. Now go to the directory called “training-data-analyst/courses/design-process/deploying-apps-to-gcp” and update the main.yaml file like below:


9. In the same directory, create another file called “kubernetes-config.yaml” which should be like below:

10. To use Kubernetes Engine, you need to build a Docker image. Enter the following commands to use Cloud Build to create the image and store it in Container Registry:
cd ~/gcp-course/training-data-analyst/courses/design-process/deploying-apps-to-gcp
gcloud builds submit — tag gcr.io/$DEVSHELL_PROJECT_ID/devops-image:v0.2 .content_copy


11. When the previous command completes, the image named will be listed in the output. The image name is in the form gcr.io/project-id/devops-image:v0.2. It should appear as shown below:

Image Name From Above Output: gcr.io/qwiklabs-gcp-01–3aa15ec0c44f/devops-image:v0.2
12. Highlight your image name and copy it to the clipboard. Paste that value in the kubernetes-config.yaml file, overwriting the string <YOUR IMAGE PATH HERE>. You should see something similar to below:

13. Enter the following Kubernetes command to deploy your application:
kubectl apply -f kubernetes-config.yaml

14. In the configuration file, three replicas of the application were specified. Type the following command to see whether three instances have been created:
kubectl get pods
Make sure all the pods are ready. If they aren’t, wait a few seconds and try again

15. A load balancer was also added in the configuration file. Type the following command to see whether it was created:
kubectl get services
You should see something similar to below:

If the load balancer’s external IP address says “pending,” wait a few seconds and try again.
16. When you have an external IP, open a browser tab and make a request to it. It should return Hello Kubernetes Engine. It might take a few seconds to be ready.

Congratulations !! You have deployed your App by downloading a Sample app from Git Repository and Deploying it to Kubernetes Engine.
This Concludes our tutorial for “Deploying Apps using Git and Kubernetes Engine”.
Happy Learning !!!

I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don’t know much about a certain place. Can you help me? https://www.gate.io/id/signup/XwNAU
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://accounts.binance.com/es/register?ref=V2H9AFPY