For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to Suspend All Kubernetes CronJobs

Problem

CronJobs running on the cluster need to be (temporarily) suspended (such as for a maintenance activity).

Environment

  • Platform9 Managed Kubernetes - All Versions

  • kubectl

Procedure

  1. Export Kubeconfig.

  2. Retrieve a list of all CronJobs across all namespaces and patch their spec.

while read -r CRONJOB NAMESPACE; do kubectl -n $NAMESPACE patch cronjobs -p '{"spec" : {"suspend" : true }}' $CRONJOB; done <<< $(kubectl get cronjobs -Ao=jsonpath='{range .items[*]}{@.metadata.name}{" "}{@.metadata.namespace}{"<br>"}{end}')

Last updated