更新和删除检查任务

用户可以通过更新或删除检查任务来调整检查任务的配置,以满足业务需求。

过程

更新检查任务

命令行工具

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

$ kubectl edit iotedgeinspection <inspection_name>

===
# 请编辑下面的对象。以 '#' 开头的行将被忽略,
# 空文件将会中止编辑。如果保存此文件时发生错误,该文件将会
# 重新打开并显示相关失败信息。
#
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 将会自动删除。