Update Doc: Jobs

Signed-off-by: Felixnoo <felixliu@yunify.com>
This commit is contained in:
Felixnoo 2021-06-30 18:50:19 +08:00
parent 5060f6c46b
commit 188eebfb31
32 changed files with 28 additions and 34 deletions

View File

@ -7,11 +7,11 @@ linkTitle: "Jobs"
weight: 10250
---
A Job creates one or more Pods and ensures that a specified number of them successfully terminate. As Pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created.
A Job creates one or more Pods and ensures that a specified number of them successfully terminates. As Pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (namely, Job) is complete. Deleting a Job will clean up the Pods it created.
A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example due to a node hardware failure or a node reboot). You can also use a Job to run multiple Pods in parallel.
A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example, due to a node hardware failure or a node reboot). You can also use a Job to run multiple Pods in parallel.
The following example demonstrates specific steps of creating a Job (computing π to 2000 decimal places) in KubeSphere.
The following example demonstrates specific steps of creating a Job (computing π to 2000 decimal places) on KubeSphere.
## Prerequisites
@ -23,7 +23,7 @@ You need to create a workspace, a project and an account (`project-regular`). Th
Log in to the console as `project-regular`. Go to **Jobs** under **Application Workloads** and click **Create**.
![create-job](/images/docs/project-user-guide/application-workloads/jobs/create-job.jpg)
![create-job](/images/docs/project-user-guide/application-workloads/jobs/click-create.png)
### Step 2: Enter basic information
@ -33,13 +33,13 @@ Enter the basic information. Refer to the image below as an example.
- **Alias**: The alias name of the Job, making resources easier to identify.
- **Description**: The description of the Job, which gives a brief introduction of the Job.
![job-create-basic-info](/images/docs/project-user-guide/application-workloads/jobs/job-create-basic-info.png)
![job-create-basic-info](/images/docs/project-user-guide/application-workloads/jobs/basic-info.png)
### Step 3: Job settings (optional)
You can set the values in this step as below or click **Next** to use the default values. Refer to the table below for detailed explanations of each field.
![job-create-job-settings](/images/docs/project-user-guide/application-workloads/jobs/job-create-job-settings.png)
![job-create-job-settings](/images/docs/project-user-guide/application-workloads/jobs/job-settings.png)
| Name | Definition | Description |
| ----------------------- | ---------------------------- | ------------------------------------------------------------ |
@ -56,33 +56,31 @@ You can set the values in this step as below or click **Next** to use the defaul
- If **Restart Policy** is set to **OnFailure**, the Job will internally restart the container when the Pod fails, instead of creating a new Pod.
![job-container-settings](/images/docs/project-user-guide/application-workloads/jobs/job-container-settings.png)
![job-container-settings](/images/docs/project-user-guide/application-workloads/jobs/restart-policy.png)
2. Click **Add Container Image** which directs you to the **Add Container** page. Enter `perl` in the image search bar and press the **Return** key.
2. Click **Add Container Image** which directs you to the **Add Container** page. Enter `perl` in the image search bar and press **Enter**.
![add-container-image-job](/images/docs/project-user-guide/application-workloads/jobs/add-container-image-job.png)
![add-container-image-job](/images/docs/project-user-guide/application-workloads/jobs/set-image.png)
3. On the same page, scroll down to **Start Command**. Enter the following commands in the box which computes pi to 2000 places then prints it. Click **√** in the bottom-right corner and select **Next** to continue.
3. On the same page, scroll down to **Start Command**. Enter the following commands in the box which computes pi to 2000 places then prints it. Click **√** in the lower-right corner and select **Next** to continue.
```bash
perl,-Mbignum=bpi,-wle,print bpi(2000)
```
![start-command-job](/images/docs/project-user-guide/application-workloads/jobs/start-command-job.jpg)
![start-command-job](/images/docs/project-user-guide/application-workloads/jobs/start-command.png)
{{< notice note >}}
For more information about setting images, see [Container Image Settings](../container-image-settings/).
{{</ notice >}}
{{< notice note >}}For more information about setting images, see [Container Image Settings](../container-image-settings/).{{</ notice >}}
### Step 5: Inspect the Job manifest (optional)
1. Enable **Edit Mode** in the top-right corner which displays the manifest file of the Job. You can see all the values are set based on what you have specified in the previous steps.
1. Enable **Edit Mode** in the upper-right corner which displays the manifest file of the Job. You can see all the values are set based on what you have specified in the previous steps.
```yaml
apiVersion: batch/v1
kind: Job
metadata:
namespace: cc
namespace: demo-project
labels:
app: job-test-1
name: job-test-1
@ -94,11 +92,9 @@ For more information about setting images, see [Container Image Settings](../con
metadata:
labels:
app: job-test-1
annotations:
kubesphere.io/containerSecrets: null
spec:
containers:
- name: container-xv4p2o
- name: container-4rwiyb
imagePullPolicy: IfNotPresent
image: perl
command:
@ -112,36 +108,34 @@ For more information about setting images, see [Container Image Settings](../con
volumes: []
imagePullSecrets: null
backoffLimit: 5
parallelism: 2
completions: 4
parallelism: 2
activeDeadlineSeconds: 300
```
2. You can make adjustments in the manifest directly and click **Create** or disable the **Edit Mode** and get back to the **Create Job** page.
{{< notice note >}}
You can skip **Mount Volumes** and **Advanced Settings** for this tutorial. For more information, see [Mount volumes](../deployments/#step-4-mount-volumes) and [Configure advanced settings](../deployments/#step-5-configure-advanced-settings).
{{</ notice >}}
{{< notice note >}}You can skip **Mount Volumes** and **Advanced Settings** for this tutorial. For more information, see [Mount volumes](../deployments/#step-4-mount-volumes) and [Configure advanced settings](../deployments/#step-5-configure-advanced-settings).{{</ notice >}}
### Step 6: Check the result
1. In the final step of **Advanced Settings**, click **Create** to finish. A new item will be added to the Job list if the creation is successful.
![job-list-new](/images/docs/project-user-guide/application-workloads/jobs/job-list-new.png)
![job-list-new](/images/docs/project-user-guide/application-workloads/jobs/job-in-list.png)
2. Click this Job and go to **Execution Records** where you can see the information of each execution record. There are four completed Pods since **Completions** was set to `4` in Step 3.
![execution-record](/images/docs/project-user-guide/application-workloads/jobs/execution-record.jpg)
![execution-record](/images/docs/project-user-guide/application-workloads/jobs/exe-records.png)
{{< notice tip >}}
You can rerun the Job if it fails, the reason of which displays under **Messages**.
{{</ notice >}}
3. In **Resource Status**, you can inspect the Pod status. Two Pods were created each time as **Parallelism** was set to 2. Click the arrow on the right and check the container log as shown below, which displays the expected calculation result.
3. In **Resource Status**, you can inspect the Pod status. Two Pods were created each time as **Parallelism** was set to 2. Click <img src="/images/docs/project-user-guide/application-workloads/jobs/down-arrow.png" width="20px" /> on the right and check the container log as shown below, which displays the expected calculation result.
![container-log](/images/docs/project-user-guide/application-workloads/jobs/container-log.jpg)
![container-log](/images/docs/project-user-guide/application-workloads/jobs/resource-status.png)
![container-log-check](/images/docs/project-user-guide/application-workloads/jobs/container-log-check.jpg)
![container-log-check](/images/docs/project-user-guide/application-workloads/jobs/log.png)
{{< notice tip >}}
@ -158,12 +152,12 @@ You can rerun the Job if it fails, the reason of which displays under **Messages
On the Job detail page, you can manage the Job after it is created.
- **Edit Info**: Edit the basic information except `Name` of the job.
- **Edit Info**: Edit the basic information except `Name` of the Job.
- **Rerun Job**: Rerun the Job, the Pod will restart, and a new execution record will be generated.
- **View YAML**: View the Job's specification in YAML format.
- **Delete**: Delete the Job and return to the Job list page.
![job-operation](/images/docs/project-user-guide/application-workloads/jobs/job-operation.jpg)
![job-operation](/images/docs/project-user-guide/application-workloads/jobs/modify-job.png)
### Execution records
@ -177,7 +171,7 @@ On the Job detail page, you can manage the Job after it is created.
1. Click the **Resource Status** tab to view the Pods of the Job.
![resource-status](/images/docs/project-user-guide/application-workloads/jobs/resource-status.png)
![resource-status](/images/docs/project-user-guide/application-workloads/jobs/res-status.png)
2. Click <img src="/images/docs/project-user-guide/application-workloads/jobs/refresh.png" width="20px" /> to refresh the Pod information, and click <img src="/images/docs/project-user-guide/application-workloads/jobs/display.png" width="20px" />/<img src="/images/docs/project-user-guide/application-workloads/jobs/hide.png" width="20px" /> to display/hide the containers in each Pod.
@ -191,7 +185,7 @@ Click the **Metadata** tab to view the labels and annotations of the Job.
Click the **Environment Variables** tab to view the environment variables of the Job.
![env-variable](/images/docs/project-user-guide/application-workloads/jobs/env-variable.png)
![env-variable](/images/docs/project-user-guide/application-workloads/jobs/env-variables.png)
### Events

View File

@ -131,7 +131,7 @@ weight: 10250
{{< notice tip >}}如果任务失败,您可以重新运行该任务,失败原因显示在**消息**下。{{</ notice >}}
3. 在**资源状态**中,您可以查看 Pod 状态。先前将**并行数**设置为 2因此每次会创建两个 Pod。点击右侧的箭头,查看容器日志,如下所示,该日志显示了预期的计算结果。
3. 在**资源状态**中,您可以查看 Pod 状态。先前将**并行数**设置为 2因此每次会创建两个 Pod。点击右侧的 <img src="/images/docs/zh-cn/project-user-guide/application-workloads/jobs/down-arrow.png" width="20px" />,查看容器日志,如下所示,该日志显示了预期的计算结果。
![容器日志](/images/docs/zh-cn/project-user-guide/application-workloads/jobs/container-log.PNG)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 352 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 734 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB