更新和删除巡检任务

用户可以通过更新或删除巡检任务,在使用过程中调整巡检任务的配置以满足业务需求。

目录

操作步骤

更新巡检任务

CLI

更新巡检任务与更新其他 K8S 资源类似。可以使用 kubectl edit 命令更新巡检任务的配置。

kubectl edit iotedgeinspection <inspection_name>

===
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: middleware.alauda.io/v1
kind: Inspection
metadata:
  annotations:
    cpaas.io/creator: admin
    cpaas.io/display-name: ""
    cpaas.io/updated-at: "2025-02-24T05:57:46Z"
  creationTimestamp: "2025-02-24T05:57:46Z"
  generation: 1
  labels:
    inspection.middleware.io/cluster: business-1
    inspection.middleware.io/component: mysqlcluster
    inspection.middleware.io/namespace: tongrds-1
    inspection.middleware.io/project: tongrds
    inspection.middleware.io/trigger: Schedule
  name: ins1
  namespace: tongrds-1
  resourceVersion: "58781609"
  uid: 530410bc-8d12-476c-b82c-034c9ac4d3ae
spec:
  component: mysqlcluster
  instances:
  - name: '*'
  jobsHistoryLimit: 1
  schedule: 30 18 25 12 *
  trigger: Schedule
status:
  lastJobStatus: ""
  message: ""
INFO

需要注意的是,用户只能更新 spec 结构体内的字段;statusmetadata 结构体中的字段为只读。

删除巡检任务

删除巡检任务与删除其他 K8S 资源类似。可以使用 kubectl delete 命令删除巡检任务。

kubectl delete -n <namespace> inspection <inspection_name>
INFO

需要注意的是,设计上 inspectionjobinspection 是一一对应的,因此当删除 inspection 时,相关联的 inspectionjob 会被自动删除。