Deploying a Kubernetes Cluster Using Google Kubernetes Engine

30 minutes
  • 2 Learning Objectives

About this Hands-on Lab

In this lab, you will be creating a Kubernetes cluster using Google Kubernetes Engine (GKE). You will create the cluster through Google’s Cloud Shell.

You will learn how to easily create a cluster with just a few commands.

Understanding how to create your cluster through the command line will give you the advantage of having granular control over your cluster and understanding exactly what’s going on under the hood.

For this lab, you should have a basic understanding of Kubernetes. This way, you have the basic knowledge and skills to comprehend what you will be achieving in this lab.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a Two-Node Cluster
  1. Create your first cluster.
  2. Launch Google Cloud Shell and connect to the cluster.
Deploy the Voting App
  1. Launch the Google Cloud IDE.
  2. Paste the provided YAML code into the deployment file.
  3. Deploy the app through Cloud Shell.
  4. Verify that the app is working.

Additional Resources

You work for a small startup that is developing a new e-commerce application. The application needs to be highly available and scalable, so your team decides to test a deployment on a two-node Google Kubernetes Engine (GKE) cluster.

To accomplish this, you will complete the following tasks:

  • Create a GKE cluster in the us-central1 region.
  • Deploy a test application to mimic the application.
  • Configure autoscaling to a max of 4 nodes.
  • Test the cluster to see if what you created works!

Use the following YAML code to configure the application:

apiVersion: v1
kind: Service
metadata:
  name: vote-service
  labels:
    app: vote
spec:
  selector:
    app: vote
  ports:
    - name: http
      port: 80
      targetPort: 80
    - name: udp
      port: 5000
      targetPort: 5000
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vote-deployment
  labels:
    app: vote
spec:
  replicas: 2
  selector:
    matchLabels:
      app: vote
  template:
    metadata:
      labels:
        app: vote
    spec:
      containers:
        - name: vote
          image: dockersamples/examplevotingapp_vote:before
          ports:
            - name: http
              containerPort: 80
            - name: udp
              containerPort: 5000

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?