Google Cloud Fundamentals: Getting Started with GKE

Task 1: Sign in to the Google Cloud Platform (GCP) Console

For each lab, you get a new GCP project and set of resources for a fixed time at no cost.

  1. Make sure you signed into Qwiklabs using an incognito window.

  2. Note the lab's access time (for example, img/time.png and make sure you can finish in that time block.

  1. When ready, click img/start_lab.png.

  2. Note your lab credentials. You will use them to sign in to Cloud Platform Console. img/open_google_console.png

  3. Click Open Google Console.

  4. Click Use another account and copy/paste credentials for this lab into the prompts.

  1. Accept the terms and skip the recovery resource page.

Task 2: Confirm that needed APIs are enabled

  1. Make a note of the name of your GCP project. This value is shown in the top bar of the Google Cloud Platform Console. It will be of the form qwiklabs-gcp- followed by hexadecimal numbers.

  2. In the GCP Console, on the Navigation menu (Navigation menu), click APIs & Services.

  3. Scroll down in the list of enabled APIs, and confirm that both of these APIs are enabled:

  • Kubernetes Engine API
  • Container Registry API

If either API is missing, click Enable APIs and Services at the top. Search for the above APIs by name and enable each for your current project. (You noted the name of your GCP project above.)

Task 3: Start a Kubernetes Engine cluster

  1. In GCP console, on the top right toolbar, click the Open Cloud Shell button.

    Cloud Shell icon

  2. Click Continue. cloudshell_continue.png

  3. For convenience, place the zone that Qwiklabs assigned you to into an environment variable called MY_ZONE. At the Cloud Shell prompt, type this partial command:

    export MY_ZONE=
    

followed by the zone that Qwiklabs assigned to you. Your complete command will look similar to this:

export MY_ZONE=us-central1-a

Start a Kubernetes cluster managed by Kubernetes Engine. Name the cluster webfrontend and configure it to run 2 nodes:

gcloud container clusters create webfrontend --zone $MY_ZONE --num-nodes 2
  1. The gcloud container clusters create command automatically authenticated kubectl for you.

  2. View your running nodes in the GCP Console. On the Navigation menu (Navigation menu), click Compute Engine > VM Instances.

    Your Kubernetes cluster is now ready for use.

    Click Check my progress to verify the objective. Start a Kubernetes Engine cluster

Task 4: Run and deploy a container

  1. From your Cloud Shell prompt, launch a single instance of the nginx container. (Nginx is a popular web server.)

    kubectl create deploy nginx --image=nginx:1.17.10
    
  1. In Kubernetes, all containers run in pods. This use of the kubectl create command caused Kubernetes to create a deployment consisting of a single pod containing the nginx container. A Kubernetes deployment keeps a given number of pods up and running even in the event of failures among the nodes on which they run. In this command, you launched the default number of pods, which is 1.

Note: If you see any deprecation warning about future version you can simply ignore it for now and can proceed further.

  1. View the pod running the nginx container:

    kubectl get pods
    

Expose the nginx container to the Internet:

kubectl expose deployment nginx --port 80 --type LoadBalancer

Confirm that your external IP address has not changed:

kubectl get services
  1. Return to the web browser tab in which you viewed your cluster's external IP address. Refresh the page to confirm that the nginx web server is still responding.

Click Check my progress to verify the objective.

  • It takes several minutes to create a cluster as Kubernetes Engine provisions virtual machines for you.

  • After the cluster is created, check your installed version of Kubernetes using the kubectl version command:

    kubectl version
    
  • Kubernetes created a service and an external load balancer with a public IP address attached to it. The IP address remains the same for the life of the service. Any network traffic to that public IP address is routed to pods behind the service: in this case, the nginx pod.

  • View the new service:

    kubectl get services
    
  • You can use the displayed external IP address to test and contact the nginx container remotely.

    It may take a few seconds before the External-IP field is populated for your service. This is normal. Just re-run the kubectl get services command every few seconds until the field is populated.

  • Open a new web browser tab and paste your cluster's external IP address into the address bar. The default home page of the Nginx browser is displayed.

  • Scale up the number of pods running on your service:

    kubectl scale deployment nginx --replicas 3
    
  • Scaling up a deployment is useful when you want to increase available resources for an application that is becoming more popular.

  • Confirm that Kubernetes has updated the number of pods:

    kubectl get pods
    
  • 0 Response to "Google Cloud Fundamentals: Getting Started with GKE "

    Post a Comment

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel