All Products
Search
Document Center

:Create an application from an orchestration template

Last Updated:Aug 22, 2023

You can view the deployment progress and changes of all Kubernetes resources when you deploy an application in the Application Center module of the Container Service for Kubernetes (ACK) console. You can choose different methods to deploy applications based on the data sources of the templates. This topic describes how to create an application from an orchestration template in Application Center.

Prerequisites

An ACK cluster is created. For more information, see Create an ACK managed cluster.

Procedure

  1. Log on to the ACK console.

  2. Authorize the cluster to manage orchestration templates.

    1. On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.

    2. On the Cluster Information page, click the Cluster Resources tab.

    3. On the Cluster Resources tab, click KubernetesWorkerRole-**** to the right of Worker RAM Role.

      K8sWorkerRole hyperlink
    4. On the KubernetesWorkerRole-**** page, click the Permissions tab and then click the policy name of k8sWorkerRolePolicy-****.

    5. On the policy details page, click the Policy Document tab and click Modify Policy Document.

    6. In the Modify Policy Document panel, add the following code block and click OK.

      {
          "Action": [
              "cs:CreateTemplate",
              "cs:DescribeTemplates",
              "cs:DescribeTemplateAttribute",
              "cs:UpdateTemplate",
              "cs:DeleteTemplate"
          ],
          "Resource": [
              "*"
          ],
          "Effect": "Allow"
      }
  3. In the upper-left corner of the ACK console, click the Return icon icon to the left of the cluster name.

  4. In the left-side navigation pane of the ACK console, choose Multi-cluster > Application Center.

  5. On the Application Center page, click Create Application.

  6. On the Source wizard page, set the parameters.

    1. In the Install appcenter section, select the cluster where you want to install appcenter and click Install.

      Note

      This step is required only when you use Application Center to create applications for the first time.

    2. In the Source section, click YAML Template.

    3. Click Next.

  7. On the Application Configurations wizard page, set the parameters.

    1. Set Name and Description.

    2. Specify a template for the application. You can select an existing template or create a template. In this topic, a template is created.

      1. Click the Create Template tab and then click Create with YAML in the upper-right corner of the tab.

      2. Copy the following code into the Create panel and 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
    3. Click Next.

  8. On the Release Configurations wizard page, set the parameters.

    1. In the Release Configurations section, select the release type. Full Release and Canary Release are supported.

      Note

      If this is the initial release of the application, you can select only Full Release. You can select Full Release or Canary Release when you update the application.

    2. In the Select Cluster section, click Add to the left side of the cluster that you want to select. The added cluster appears in the Cluster section. Then, select the namespace where you want to deploy the new application version in the Cluster section.

      Note

      If you want to select a cluster that does not have Internet access, you must associate an elastic IP address (EIP) with the cluster API server to enable Internet access. For more information, see Control public access to the API server of a cluster.

    3. Click Release Now.

    4. In the Confirm Release message, click OK.

      In the Release Log step, you can view the deployment progress.

  9. In the Release Log step, click Complete.

Verify the result.

  1. Obtain the endpoint of the application.
    1. Log on to the ACK console.

    2. In the left-side navigation pane of the ACK console, click Clusters.

    3. On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.

    4. In the left-side navigation pane of the details page, choose Network > Ingresses.

    5. On the Ingresses page, check the endpoint of the Ingress created for the demo application.
  2. Add the following content to the hosts file:

    <Endpoint> app.demo.example.com 
  3. Enter app.demo.example.com in the address bar of your browser and press Enter.

    If the page appears as shown in the following figure, it indicates that the application is deployed. red