Scale Out and Update a Containerized Application on a Kubernetes Cluster – Qwiklab

0 46

When you open the page of this lab in Qwiklabs, you can find the task requirements by click the green activity tracker (on the top right of the page) to expand the score box.

The screenshot above shows that there are 4 steps required for completing this lab. Combining with the instruction details, they are translated to the following mission statements.

  1. Update a docker application and push a new version of image tagged echo-app:v2 to a container repository (gcr.io).
  2. Upload the deployment running on the Kubernetes cluster to echo-app:v2.
  3. Scale out the application so that the Kubernetes cluster deployment is running 2 replicas.
  4. The application must respond to web requests with V2.0.0.

 

  1. Build a Docker Image of Sample Application with a v2 tag
    1. Uou can start with the pre-uploaded archive that contains the sample application and the docker configuration in the Cloud Storage bucket. Use a gsutil cp command to copy the archive from the Cloud Storage to the Cloud Shell environment. Next, use a tar -xvzf command to unzip the files. You may use a code editor to compare the change between the v1 and v2 codes. After that, use docker commands to build, tag and push the new container image to Google Container Registry (gcr.io).
    2. Edit the line in the /manifests/echoweb-deployment.yaml file defining which image to use:
      apiVersion: apps/v1beta1
      kind: Deployment
      metadata:
        name: echoweb
        labels:
          app: echo
      spec:
        template:
          metadata:
            labels:
              app: echo
              tier: web
          spec:
            containers:
            - name: echo-app
              image: gcr.io/PROJECT_ID/echo-app:v2 # Update this to v2.
                                                   # Replace PROJECT_ID
                                                   # with your project
              ports:
              - containerPort: 8000
    3. Build a new docker image of the sample application with a tag called v2, and push the image to Google Container Registry,
      docker build -t echo-app:v2 .
      export PROJECT_ID=$(gcloud info --format='value(config.project)')
      docker tag echo-app:v2 gcr.io/${PROJECT_ID}/echo-app:v2
      docker push gcr.io/${PROJECT_ID}/echo-app:v2
    4. In the web console, navigate to Container Registry > Images to confirm the docker image tagged v2 has been pushed to the cloud repositories.
  2. Update the Application to the Kubernetes Cluster Using Web Console
    1. Navigate to Kubernetes Engine > Workloads, click the name echo-web to show the Deployment details. Press the  icon to expand the menu and select Rolling Update.
    2. In the Rolling Update dialogue, modify the end of the image field from v1 to v2.
    3. Click UPDATE.
  3. Scale out the application so that the Kubernetes cluster deployment
    1. Navigate to Kubernetes Engine > Workloads, click the name echo-web to show the Deployment details. Press the  icon to expand the menu and select Scale.
    2. In the Scale dialogue, type 2 to the field Replicas,
    3. Click SCALE, then waits for creating/deleting instances until 2 replicas exist in the Kubernetes cluster.

Leave A Reply

Your email address will not be published.