All Products
Search
Document Center

Publish Container Service Kubernetes applications

Last Updated: Feb 02, 2019

At present, EDAS only allows you to publish Container Service Kubernetes applications by using images.

Prerequisites

Create applications

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications.

  3. On the Applications page, select Region and click Create Application in the upper-right corner.

  4. On the Application Information page, set the basic information about the application. Then click Next Step: Application Configurations.

    • Namespace: Select Region and Namespace from the drop-down list.If you do not select a namespace, the default namespace is automatically selected.
    • Cluster Type: Select Container Service K8S Cluster from the drop-down list and then select a specific cluster.
    • Application Name: Enter the application name.
    • Application Description: Enter up to 100 characters of basic application information.
  5. Go to the Application Configuration page and configure an image.

    1. Select Image for Application Deployment Method.

    2. Select an image in My Image.

      Note:

      • If you are publishing a Container Service Kubernetes application for the first time, no images will be available in the image market. Follow the instructions provided in Create a Container Service Kubernetes application image to create an image and upload it to the repository.

      • You cannot pull images across regions.

  6. Set pods.

    Pods are the smallest units for deploying an application.An application can contain multiple pods. In the event that load balancing can be achieved, a request is randomly allocated to a pod for processing.

    1. Set Total Pods.

      When the pods of an application fail to run or are faulty, they can be automatically restarted or quickly migrated to ensure the high availability of the application.For stateful applications using persistent storage, instance data can be saved. For redeployed stateless applications, instance data is not saved.

    2. Set Single Pod Resource Quota.

      No quota is set by default. Therefore, both the values of CPU Cores and Memory of a single pod are 0.To set the quota, enter a number.

  7. Set the startup command and parameters.

    Note: We recommend that you do not modify the custom startup command and parameters if you are not familiar with the CMD and ENTRYPOINT of the original Dockerfile. An incorrect custom command could lead to an application creation failure.

    • Startup Command: Enter content in [“”] only. For example, to run CMD [“/usr/sbin/sshd”,”-D”] , enter /usr/sbin/sshd –D only.
    • Startup Parameters: Enter one parameter per line.For example, args:[“-c”; “while sleep 2”; “do echo date”; “done”] contains four parameters. Enter them separately in four lines.
  8. Set environment variables.

    When creating the application, inject the entered environment variables in the container to be generated. This saves you from having to repeatedly add common environment variables.

    If you are using a MySQL image, refer to the following environment variables:

    • MYSQL_ROOT_PASSWORD (required) allows you to set a root password for MySQL.
    • MYSQL_USER and MYSQL_PASSWORD (optional) allows you to add an account in addition to the root account, and to set a password.
    • MYSQL_DATABASE (optional) allows you to set the database to be created when the container is generated.

    If you are using another type of image, configure the environment variables as needed.

  9. Set persistent storage.

    In the Container Service Kubernetes cluster, the native Volume object corresponds to non-persistent physical storage, whose lifecycle is the same as the Kubernetes pods, which are a transient storage object.Network Attached Storage (NAS) is a persistent storage service that can store instance data permanently and ensure data integrity after application upgrade or migration.

    Note: Before configuring persistent storage, ensure that the NAS service is active for your EDAS account.Because the NAS billing method is Pay-As-You-Go, ensure that your account has a sufficient balance or adopts post payment.

    Description of persistent storage parameters:

    • Storage Type: This parameter is NAS by default and cannot be configured manually.
    • Storage Service Type: Currently, this parameter only supports SSD and cannot be configured manually.
    • Select NAS:

      • Buy a new NAS: Select a NAS mount directory and a local mount directory.

        A single region supports up to 10 NAS instances. Once you have 10, you cannot create any more instances.If you need to create more instances, submit a ticket.

      • Use Existing NAS: Select an existing NAS instance.

        You can create up to two mount points.Only compliant NAS instances are displayed in the drop-down list.

  10. Set local storage.

    You can map part of the file system of the host machine to the container, as needed.Before using this feature, read this document to determine if this is the correct solution.

    Description of file types:

    Name value Description
    Default Null string Mount directly without checking the type.
    (New) File directory DirectoryOrCreate File directory; a new directory is created if this does not exist.
    File directory Directory File directory; container startup fails if this does not exist.
    (New) File FileOrCreate File; a new file is created if this does not exist.
    File File File; container startup fails if this does not exist.
    Socket Socket Standard Unix Socket file; container startup fails if this does not exist.
    CharDevice CharDevice Character device file; container startup fails if this does not exist.
    BlockDevice BlockDevice Block device file; container startup fails if this does not exist.

    Note: You do not need to pay attention to the Value column in this step.However, the Value column may be used by APIs after the application is created.

  11. Set the lifecycle management script of the application (for stateful applications).

    Container Service Kubernetes applications can be stateful or stateless:

    • Stateless: A stateless application supports multi-replica deployment.When a stateless application is redeployed, instance data is not saved.A stateless application can be:

      • A web application that does not retain instance data during upgrade or migration.
      • An application that can be scaled up horizontally to address changing service volumes.
    • Stateful: A stateful application stores data that requires persistent storage and retains instance data during upgrade or migration.A stateful application can be:

      • An application that frequently operates on containers through SSH.
      • An application that is used for persistent data storage (such as the database application MySQL) or that supports inter-cluster election and service discovery, such as ZooKeeper and etcd.

    You can set lifecycle management for a stateful application as needed.

    Description of the lifecycle management script:

    • PreStop script: a container hook,which is triggered before a container is deleted. The corresponding hook handler must be completed before the container deletion request is sent to Docker daemon.Docker daemon sends an SGTERN semaphore to itself to delete the container, regardless of the result of hook handler execution.For more information, see Container Lifecycle Hooks.

    • Liveness script: a container status probe, which monitors the health status of applications.If an application is unhealthy, the container is deleted and created again.For more information, see Pod Lifecycle.

    • Readiness script: a container status probe, which monitors whether applications have started successfully and are running properly.If an application is abnormal, the container status is updated.For more information, see Pod Lifecycle.

    • Poststart script: a container hook,which is triggered immediately after a container is created to notify the container of its creation.The hook does not transfer any parameters to the corresponding hook handler.If the corresponding hook handler fails to run, the container is killed and the system determines whether to restart the container according to the container’s restart policy.For more information, see Container Lifecycle Hooks.

  12. Then, click Create.

Result verification

Creating an application can take up to several minutes. During the creation process, you can use an application publishing order to track the creation progress.After the application has been created, return to the Application Details page and check whether the application status is Normal on the Application Information tab page.

The Container Service Kubernetes application does not need to be deployed. The application is published once it is created.