Puntos de control
Clone the Repository
/ 20
Add cluster to the KubeConfig
/ 20
Deploy the App
/ 20
Test the App
/ 20
Delete App from cluster
/ 20
GKE Autopilot: Qwik Start
GSP957
Overview
Google Kubernetes Engine (GKE) Autopilot is a new managed mode of operation in which Google creates, sizes, and automatically scales on your behalf the physical infrastructure needed to run your application workloads.
In this lab, you get hands-on practice containerizing an application and deploying it to an GKE Autopilot cluster using a Kubernetes configuration and commands.
Simplifying GKE with Autopilot
On GKE your compute infrastructure consists of nodes based on individual compute instances.
A group of nodes is called a cluster.
Powering GKE is Kubernetes, an open source cluster orchestration platform that is heavily influenced by over fifteen years of Google's experience running production workloads in containers.
Kubernetes draws on the same design principles for running popular Google services at global scale to provide:
- Automatic management
- Monitoring and liveness probes for application containers
- Automatic scaling
- Rolling updates
With GKE Autopilot, you reap the benefits of Google's ability to optimize and configure a cluster using best practices for high availability and security, monitor the health of the cluster, and recalculate the cluster capacity needed to run your workloads at any given moment.
GKE Autopilot liberates you, the developer, to focus on application development, and not operational maintenance. You're still using Kubernetes to run the mission-critical mix of stateless and stateful services your application requires.
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
Task 1. Access Cloud Code
An integrated development environment (IDE) with the Cloud Code extension has already been set up to easily deploy workloads to a GKE cluster. This lab is using Cloud Code to access Google Cloud products and services. You can view information about your cluster resources from the editor or via the command line.
-
Copy the
IDE
URL from the Lab details panel. -
Paste it into a new browser window:
Note:
The lab environment is uses a development environment to access services. You can control the GKE Autopilot cluster directly from this environment.
Task 2. Clone repo
The first task is to clone a repo with the code to be run. Retrieve the source code under version control to begin the lab.
-
In your Cloud Code environment, select the Source Control button from the sidebar.
-
Click the Clone Repository button.
-
Paste the following GitHub repository into the prompted search bar:
https://github.com/subfuzion/voting-demo.git -
Click Clone from URL in the dropdown list under the search bar.
-
Click OK to confirm the location.
Note:
If prompted with a pop up asking about trusting the folders, selectYes I trust the Authors
. -
When prompted to open the folder of the repo, click Open.
Click Check my progress to verify the objective.
Clone the Repository
Task 3. Add your cluster to the KubeConfig
GKE Autopilot has been pre-provisioned within the lab. In this section, you will update the environment KubeConfig to point to the cluster. Once the update is complete, you can then commence the deployment of the demo application.
-
Visit the Navigation Menu and select Terminal > New Terminal.
Note:
Existing versions ofkubectl
and custom Kubernetes clients contain provider-specific code to manage authentication between the client and Google Kubernetes Engine. Starting with v1.26, this code will no longer be included as part of the OSS kubectl.
GKE users will need to download and use a separate authentication plugin to generate GKE-specific tokens. This new binary,gke-gcloud-auth-plugin
, uses the Kubernetes Client-go Credential Plugin mechanism to extend kubectl’s authentication to support GKE.
For more information, you can check out the following documentation. -
Add the cluster credentials to the local kube-config
gcloud container clusters get-credentials dev-cluster --region {{{project_0.default_region | Region}}} Expected output:
Fetching cluster endpoint and auth data. kubeconfig entry generated for dev-cluster. Click Check my progress to verify the objective.
Add cluster to the KubeConfig Note:
It can sometimes take a few minutes for this check to verify.
Task 4. Build and deploy the app
Before you can deploy an application, you need a container for that application.
In this environment, you will utilize a skaffold
manifest which builds the web
and vote
containers.
The lab uses artifact registry
to host the container images and then deploys the images using Kubernetes manifests.
-
Open a terminal, if one is not available
-
Change to the application folder
cd ~/voting-demo/v2 -
Set the region for the deployment
gcloud config set compute/region {{{ project_0.default_region | "REGION" }}} -
Use skaffold to deploy the source application
skaffold run --default-repo=gcr.io/{{{ project_0.project_id | "PROJECT_ID" }}}/voting-app --tail Note:
The deployment will take a minute to spin up the resources.
A container image will be built from source and then once available it will be deployed to the GKE autopilot cluster.Click Check my progress to verify the objective.
Deploy the App
Task 5. Run the app
Now test that the application is working as specified.
-
Launch a new terminal to test the application.
-
Run the command below to verify the
web-external
load balancer has been createdkubectl get svc web-external --output=json | jq -r .status.loadBalancer.ingress[0].ip Note:
It may take a moment for the load balancer to return an IP address. Please wait until an IP is returned before moving on. -
Open a new tab in your browser
-
Enter the IP value returned as a HTTP site
http://[web-external-ip] Expected output:
Note:
The application deployed to GKE Autopilot is now accessible on the internet.
Task 6. Test the app
-
Vote for either TABS or SPACES.
Note:
Press either button as many times as you like. We will test the input in the next step. -
Update the voting app URL as follows:
http://[web-external-ip]/results Example output:
{ "results": { "a": 0, "b": 1 }, "success": true } Click Check my progress to verify the objective.
Test the App Great job! You now have your voting application deployed to a cluster. GKE Autopilot has taken care of the management of the Kubernetes infrastructure.
Task 7. Clean up
-
Terminate your application by pressing
CTRL-C
in the terminal running the application.Note:
The skaffold application is still active. If we re-run the skaffold application, it will use the existing resources we created earlier.
How do we delete the application? We need to tell skaffold that the application is no longer required. -
Tell
Skaffold
to delete the resourcesskaffold delete Expected output:
Cleaning up... - deployment.apps "database" deleted - service "database" deleted - deployment.apps "vote" deleted - service "vote" deleted - deployment.apps "web" deleted - service "web" deleted - service "web-external" deleted Click Check my progress to verify the objective.
Delete App from cluster
Congratulations!
You have just deployed a containerized application to Google Kubernetes Engine! In this lab you have performed the following tasks:
- Cloned an external public repository
- Updated the KubeConfig to use GKE Autopilot cluster
- Used Skaffold to create a remote artifact registry image without needing to install software
- Deployed an application to GKE Autopilot
- Tested the application endpoint using HTTP
- Cleaned up existing deployed resources
Next steps / Learn more
This lab is part of a series of labs called Qwik Starts. These labs are designed to give you some experience with the many features available on Google Cloud. Search for "Qwik Starts" in the Cloud Skills Boost catalog to find the next lab you'd like to take!
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated June 03, 2024
Lab Last Tested June 03, 2024
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.