Typical use scenarios of Cloud Native Kit

更新时间:
复制 MD 格式

Cloud Native Kit (CNKIT) is suitable for application development, testing, and online O&M. This topic describes typical scenarios in which you can use CNKIT, for example, to view and download pod logs, to audit commands in the terminal, and to develop and debug applications.

View and download pod logs

Pod logs can be categorized into standard output logs of pods and logs in pods. To view and download pod logs, perform the following operations:

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.

  3. In the left-side navigation pane of the Application Overview page, click Cloud Native Toolbox.
  4. In the Step 3: Service access configuration section below Opening steps, click A key to access to go to the PodList page.
    • To view and download the standard output log of a pod, perform the following operations:

      1. On the PodList page, click Pod Monitoring under the desired pod.
      2. In the panel that appears, click Stdout to view the standard output log of the pod and click Content download to download the log.
      View and download the standard output log of the pod
    • To view and download log files in a pod, perform the following operations:

      1. On the PodList page, click Open Terminal under the desired pod.
      2. In the upper-right corner of the page that appears, click the File Management tab, and then click Download in the Operate column to view and download desired files in the pod.
      View log files in the pod

Audit commands in the terminal

CNKIT allows you to use the terminal to audit commands. To view the details about the commands that were executed, perform the following operations:

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.

  3. In the left-side navigation pane of the Application Overview page, click Cloud Native Toolbox.
  4. In the Step 3: Service access configuration section below Opening steps, click A key to access to go to the PodList page.
  5. On the PodList page, click Audit Log under the desired pod to view the details about the commands that were executed.
Commands audited in the terminal

Develop and debug an application

You can use CNKIT to create a temporary workspace, which is essentially a pod. You can develop, deploy, debug, and diagnose applications in this pod. After debugging, you can delete the temporary workspace with a few clicks. The following figure shows the entire process.

Develop and debug an application

Duplicate a pod

Perform the following operations to duplicate a pod:

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.

  3. In the left-side navigation pane of the Application Overview page, click Cloud Native Toolbox.
  4. In the Step 3: Service access configuration section below Opening steps, click A key to access to go to the PodList page.
  5. On the PodList page, click Create Pod.
Create Pod dialog box
Parameter Description
Start Command The command that starts the application in the pod. By default, use the startup command of the original image for this parameter. If you want to use iterative deployment or enable debugging for the application, you must specify a custom startup command. This is because the startup command of the original image uses the application process as the first process. After the application exits or restarts, the pod is released. Therefore, you need to set a different startup command to prevent the pod from being released when the application exits.
CopyMode You can duplicate an existing pod or create a pod by using the spec of a Deployment.
TargetNode The cluster node on which the pod runs. By default, the node on which a pod runs is selected according to the Kubernetes scheduling rule. You can also directly specify a cluster node to run the pod.
PodLogs Valid values: output to standard output stream and Output to file.
FlowControl You can use the end-to-end throttling feature to admit only requests that meet specific rules into the pod node.
Diagnosis You can choose to run tcpdump to monitor traffic, enable the recording of Java Virtual Machine (JVM) errors, and remove the Liveness probe during application startup.

Deploy an application

In pods that are created by using CNKIT, you can deploy application packages in the EDAS console or IntelliJ IDEA.

Note Pods that are not created by using CNKIT do not support application package deployment in the EDAS console or IntelliJ IDEA.

Deploy an application in the EDAS console

Perform the following operations to upload an application package to a pod and deploy the application:

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.

  3. In the left-side navigation pane of the Application Overview page, click Cloud Native Toolbox.
  4. In the Step 3: Service access configuration section below Opening steps, click A key to access to go to the PodList page.
  5. On the PodList page, click Open Terminal under the desired pod, and then click App Update on the Deploy and Debug tab.
  6. On the App Update tab, click Select File to select the file that you want to upload. Then, click Upload and Deploy to upload the package to the pod and deploy the application.
Deploy an application in the EDAS console

Deploy an application in IntelliJ IDEA

After you install Alibaba Cloud Toolkit in IntelliJ IDEA, you can create a CNKIT Deploy task to deploy the application.

  1. Start IntelliJ IDEA. Click Drop-down arrow icon in the upper-right corner and select Edit Configurations....
  2. In the dialog box, click Add icon and choose EDAS on Alibaba Cloud > EDAS for CNKIT Deploy. After you configure the parameters, click OK.
  3. After you save the configurations, click Debug icon to deploy the application to the pod in IntelliJ IDEA.
    Deploy an application in IntelliJ IDEA 2

Debug an application

In a created pod, you can perform the following operations to enable the debugging port:

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.

  3. In the left-side navigation pane of the Application Overview page, click Cloud Native Toolbox.
  4. In the Step 3: Service access configuration section below Opening steps, click A key to access to go to the PodList page.
  5. On the PodList page, click Open Terminal under the desired pod, and then click Remote Debugging on the Deploy and Debug tab.
  6. On the Remote Debugging tab, click Enable Debugging.
    Enable Debugging
  7. Create Remote JVM Debug in IntelliJ IDEA and connect the local debugging port. (In this example, the port ID is 5005. You can connect IntelliJ IDEA to the application debugging port of the pod.)
    1. Start IntelliJ IDEA. Click Drop-down arrow icon in the upper-right corner and select Edit Configurations....
    2. In the dialog box, click Add icon and select Remote JVM Debug. After you configure the parameters, click OK.
    Remote JVM Debug
  8. Click Debug icon to execute this configuration to perform remote debugging.
    Remote debugging

Diagnose application issues

CNKIT provides Kubernetes scheduling events, tcpdump, and Arthas to help you diagnose application issues.

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.

  3. In the left-side navigation pane of the Application Overview page, click Cloud Native Toolbox.
  4. In the Step 3: Service access configuration section below Opening steps, click A key to access to go to the PodList page.
  5. Use Kubernetes scheduling events, Arthas, and tcpdump to diagnose application issues.
    • Kubernetes scheduling events

      On the PodList page, click Pod Monitoring under the desired pod. On the Pod Status tab in the panel that appears, view Kubernetes scheduling events and the pod status.

      View Kubernetes scheduling events for diagnosis
    • Arthas

      On the PodList page, click Open Terminal under the desired pod, click Arthas on the Deploy and Debug tab, and then click Run Arthas.

      Install and run tcpdump
    • tcpdump

      On the PodList page, click Open Terminal under the desired pod, click Tcpdump on the Deploy and Debug tab, and then click Install Tcpdump.

      Install and run Arthas