arrow

Deploy Applications From Application Center

1. Experiment

1.1 Knowledge points

This experiment describes how to deploy applications in Kubernetes clusters from the Application Center module in the Container Service for Kubernetes (ACK) console. Application Center provides a unified portal for your applications. This allows you to view the deployment of applications in a unified manner. You can also view the deployment status and changes of all ACK sub-resources that are allocated to each application. In addition, Gits and Helm charts are used to deploy applications in ACK clusters by versions. This allows you to publish or roll back different application versions deployed in ACK clusters.

1.2 Experiment process

  • Create an ACK managed cluster
  • Authorize your cluster to manage templates
  • Create an application based on a YAML template
  • Create an application based on Kubernetes orchestration
  • Create an application based on a Helm chart
  • Release a new application version and roll back an application to an earlier version

1.3 Scene architecture diagram

image desc

1.4 Cloud resources required

  • CS

1.5 Prerequisites

  • If you’re using your own Alibaba Cloud account instead of the account provided by this lab during the experiment, please note that you’ll need to choose the same Ubuntu 16.04 operating system for your ECS, in order to run the experiment smoothly.
  • Before starting the experiment, please confirm that the previous experiment has been closed normally and has been exited.

2. Start the experiment environment

Click Start Lab in the upper right corner of the page to start the experiment.

image desc

After the experiment environment is successfully started, the system has deployed resources needed during the experiment in the background. For example, the ECS instance, RDS instance, Server Load Balancer instance, and OSS bucket. An account consisting of the username and password for logging on to the Web console of Alibaba Cloud is also provided.

image desc

After the experiment environment is started and related resources are properly deployed, the experiment starts a countdown. You have an hour to perform experimental operations. After the countdown ends, the experiment stops, and related resources are released. During the experiment, pay attention to the remaining time and arrange your time wisely. Next, use the username and password provided by the system to log on to the Web console of Alibaba Cloud and view related resources:

image desc

Go to the logon page of Alibaba Cloud console.

image desc

Fill in the sub-user account and click on Next.

image desc

Fill in the sub-user password and click on Login.

image desc

After successfully log on to the console, you will see the page showing as the following page.

image desc

3. Create an ACK managed cluster

Refer to the following figure and select Container Service to enter the container service console.

image desc

Refer to the figure below to create a cluster first.

image desc

Select the Standard Managed Kubernetes.

image desc

Refer to the figure below, set the cluster name, select the US (Silicon Valley) area, and check the VPC network and switch to which it belongs. Click Next.

image desc

Start the worker node configuration.

Refer to the figure below and select the instance type of the Worker node.

image desc

The number of worker nodes is set to 3.

image desc

Set password, and click Next.

image desc

Create an authentication token, as shown in the following figure.

image desc

Click Create Cluster.

image desc

It takes about 10 minutes to create a cluster. Please wait patiently.

image desc

image desc

4. Authorize your cluster to manage templates

To use the Application Center module, you must grant your cluster the permissions to manage templates.

Click the name of your cluster to go to the details page.

image desc

Click the Resource Access Management (RAM) role that is assigned to the cluster, as shown in the following figure.

image desc

Click the policy that is attached to the worker role.

image desc

Click Modify Policy Document.

image desc

Copy the following code block to the end of the policy content and click Next Step:

{
    "Action": [
        "cs:CreateTemplate",
        "cs:DescribeTemplates",
        "cs:DescribeTemplateAttribute",
        "cs:UpdateTemplate",
        "cs:DeleteTemplate"
    ],
    "Resource": [
        "*"
    ],
    "Effect": "Allow"
}

image desc

Click OK.

image desc

5. Create an application with a YAML template

Go to the ACK console and install the component for Application Center, as shown in the following figure.

image desc

Wait 2 minutes for the system to install the component. After the component is installed, click Create Application.

image desc

Click YAML Template and click Next.

image desc

Specify the application name and description as shown in the following figure and click Create with YAML.

image desc

Copy the following code block to the YAML template, specify the template name and description, and then click OK:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo
  labels:
    app: demo
spec:
  minReadySeconds: 5
  revisionHistoryLimit: 5
  progressDeadlineSeconds: 60
  strategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9797"
      labels:
        app: demo
    spec:
      containers:
      - name: demo
        image: registry.cn-hangzhou.aliyuncs.com/acs/rollouts-demo:red
        imagePullPolicy: IfNotPresent
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        readinessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 5
          timeoutSeconds: 5
        resources:
          limits:
            cpu: 2000m
            memory: 512Mi
          requests:
            cpu: 100m
            memory: 64Mi
---
apiVersion: v1
kind: Service
metadata:
  name: demo-svc
spec:
  selector:
    app: demo
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo
  labels:
    app: demo
spec:
  rules:
    - host: app.demo.example.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: demo-svc
              port:
                number: 80

image desc

After you create the template, click Next.

image desc

Select the cluster in which you want to deploy the application.

image desc

Click Release Now.

image desc

Click OK.

image desc

The deployment is in progress.

image desc

The deployment is completed. You can view all the resource objects that are related to the application, as shown in the following figure.

image desc

Go to the cluster details page.

image desc

View information about an Ingress. Add the endpoint and domain name that are displayed on the page to the hosts file of your on-premises machine.

image desc

If your on-premises machine uses macOS, enter sudo vim /etc/hosts in a shell and copy the following content to the end of the hosts file. Replace YOUR-INGRESS-ENDPOINT with the actual endpoint of the Ingress.

YOUR-INGRESS-ENDPOINT app.demo.example.com

image desc

If your on-premises machine uses Windows, open the hosts file in the C:\Windows\System32\drivers\etc directory.

image desc

Enter app.demo.example.com in the address bar of your browser and press Enter.

image desc

6. Create an application based on Kubernetes orchestration

Delete the application that you deployed.

image desc

Click OK.

image desc

Click Create Application.

image desc

Click Git Repository and click Next, as shown in the following figure.

image desc

Specify a repository address on GitHub, specify main as the branch, and specify demo as the path, as shown in the following figure. Then, click Next. To view the content of the configuration file, copy the following address to the address bar of your browser and press Enter.

https://github.com/andi1991/labexApplyCenter.git

image desc

Select the cluster in which you want to deploy the application.

image desc

Click Release Now.

image desc

Click OK.

image desc

The application is created.

image desc

Test access to the application in the same way you do at the end of the Section 5.

7. Create an application based on Helm orchestration

Click Create Application.

image desc

Click Git Repository.

image desc

Select the Git repository that you added in the previous section and specify helm-demo as the path. To view the content of the configuration file, enter the repository address to the address bar of your browser and press Enter.

image desc

Select the cluster in which you want to deploy the application.

image desc

Click Release Now.

image desc

Click OK.

image desc

The application is created.

image desc

Test access to the application in the same way you do at the end of the Section 5.

8. Release a new application version and roll back an application to an earlier version

Find the application that you want to manage and click Details in the Actions column, as shown in the following figure.

image desc

If you update the application code in the code repository on GitHub after you deploy the application, you can click Redeploy to redeploy the application.

image desc

image desc

You can click History Versions to view earlier versions of the application.

image desc

If the new version failed to be released, you can roll back the application to a specified version.

image desc

Reminder:
Before you leave this lab, remember to log out of your Alibaba RAM user before you click the stop button of your lab. Otherwise, you will encounter some issues when you open a new lab session in the same browser.

image descimage desc

9. Experiment summary

This experiment describes how to deploy applications in Kubernetes clusters from the Application Center module in the ACK console. After you deploy an application from Application Center, you can view the application topology in a unified portal. Versioning and rollbacks can be centrally managed for continuous deployments. This helps you understand how your applications are deployed in a unified view.