Managing Workloads and Jobs

Scenario

After a workload is created, you can upgrade, monitor, roll back, or delete the workload, as well as edit its YAML file.

Table 1 Workload/Job management

Operation

Description

Monitor

You can view the CPU and memory usage of workloads and pods on the CCE console.

View Log

You can view the logs of workloads.

Upgrade

You can replace images or image tags to quickly upgrade Deployments, StatefulSets, and DaemonSets without interrupting services.

Edit YAML

You can modify and download YAML files of Deployments, StatefulSets, DaemonSets, CronJobs, and containers on the CCE console. YAML files of jobs can only be viewed, copied, and downloaded.

Note

If an existing CronJob is modified, the new configuration takes effect for the new pods, and the existing pod continues to run without any change.

Roll Back

Only Deployments can be rolled back.

Redeploy

You can redeploy a workload. After the workload is redeployed, all pods in the workload will be restarted.

Enabling/Disabling the Upgrade

Only Deployments support this operation.

Manage Label

Labels are attached to workloads as key-value pairs to manage and select workloads. Jobs and Cron Jobs do not support this operation.

Delete

You can delete a workload or job that is no longer needed. Deleted workloads or jobs cannot be recovered.

View Events

You can view event names, event types, number of occurrences, Kubernetes events, first occurrence time, and last occurrence time.

Stop/Start

You can only start or stop a cron job.

Monitoring a Workload

You can view the CPU and memory usage of Deployments and pods on the CCE console to determine the resource specifications you may need. This section uses a Deployment as an example to describe how to monitor a workload.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and click Monitor of the target workload. On the page that is displayed, you can view CPU usage and memory usage of the workload.

  3. Click the workload name. On the Pods tab page, click the Monitor of the target pod to view its CPU and memory usage.

Viewing Logs

You can view logs of Deployments, StatefulSets, DaemonSets, and jobs. This section uses a Deployment as an example to describe how to view logs.

Important

Before viewing logs, ensure that the time of the browser is the same as that on the backend server.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and click the View Log of the target workload.

    In the displayed View Log window, you can view logs.

    Note

    The displayed logs are standard output logs of containers and do not have persistence and advanced O&M capabilities. To use more comprehensive log capabilities, see Logs. If the function of collecting standard output is enabled for the workload (enabled by default), you can go to AOM to view more workload logs. For details, see Collecting Container Logs Using ICAgent.

Upgrading a Workload

You quickly upgrade Deployments, StatefulSets, and DaemonSets on the CCE console.

This section uses a Deployment as an example to describe how to upgrade a workload.

Before replacing an image or image version, upload the new image to the SWR service.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and click Upgrade of the target workload.

    Note

    • Workloads cannot be upgraded in batches.

    • Before performing an in-place StatefulSet upgrade, you must manually delete old pods. Otherwise, the upgrade status is always displayed as Processing.

  3. Upgrade the workload based on service requirements. The method for setting parameter is the same as that for creating a workload.

  4. After the update is complete, click Upgrade Workload, manually confirm the YAML file, and submit the upgrade.

Editing a YAML file

You can modify and download YAML files of Deployments, StatefulSets, DaemonSets, CronJobs, and containers on the CCE console. YAML files of jobs can only be viewed, copied, and downloaded. This section uses a Deployment as an example to describe how to edit the YAML file.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and choose More > Edit YAML in the Operation column of the target workload. In the dialog box that is displayed, modify the YAML file.

  3. Click OK.

  4. (Optional) In the Edit YAML window, click Download to download the YAML file.

Rolling Back a Workload (Available Only for Deployments)

CCE records the release history of all Deployments. You can roll back a Deployment to a specified version.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab, choose More > Roll Back in the Operation column of the target workload.

  3. Switch to the Change History tab page, click Roll Back to This Version of the target version, manually confirm the YAML file, and click OK.

Redeploying a Workload

After you redeploy a workload, all pods in the workload will be restarted. This section uses Deployments as an example to illustrate how to redeploy a workload.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and choose More > Redeploy in the Operation column of the target workload.

  3. In the dialog box that is displayed, click Yes to redeploy the workload.

Disabling/Enabling Upgrade (Available Only for Deployments)

Only Deployments support this operation.

  • After the upgrade is disabled, the upgrade command can be delivered but will not be applied to the pods.

    If you are performing a rolling upgrade, the rolling upgrade stops after the disabling upgrade command is delivered. In this case, the new and old pods co-exist.

  • If a Deployment is being upgraded, it can be upgraded or rolled back. Its pods will inherit the latest updates of the Deployment. If they are inconsistent, the pods are upgraded automatically according to the latest information of the Deployment.

Important

Deployments in the disable upgrade state cannot be rolled back.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and choose More > Disable/Enable Upgrade in the Operation column of the workload.

  3. In the dialog box that is displayed, click Yes.

Managing Labels

Labels are key-value pairs and can be attached to workloads. You can manage and select workloads by labels. You can add labels to multiple workloads or a specified workload.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. Click the Deployments tab and choose More > Manage Label in the Operation column of the target workload.

  3. Click Add, enter a key and a value, and click OK.

    Note

    A key-value pair must contain 1 to 63 characters starting and ending with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.

Deleting a Workload/Job

You can delete a workload or job that is no longer needed. Deleted workloads or jobs cannot be recovered. Exercise caution when you perform this operation. This section uses a Deployment as an example to describe how to delete a workload.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. In the same row as the workload you will delete, choose Operation > More > Delete.

    Read the system prompts carefully. A workload cannot be recovered after it is deleted. Exercise caution when performing this operation.

  3. Click Yes.

    Note

    • If the node where the pod is located is unavailable or shut down and the workload cannot be deleted, you can forcibly delete the pod from the pod list on the workload details page.

    • Ensure that the storage volumes to be deleted are not used by other workloads. If these volumes are imported or have snapshots, you can only unbind them.

Events

This section uses Deployments as an example to illustrate how to view events of a workload. To view the event of a job or cron jon, click View Event in the Operation column of the target workload.

  1. Log in to the CCE console, go to an existing cluster, and choose Workloads in the navigation pane.

  2. On the Deployments tab page, click the target workload. In the Pods tab page, click the View Events to view the event name, event type, number of occurrences, Kubernetes event, first occurrence time, and last occurrence time.

    Note

    Event data will be retained for one hour and then automatically deleted.