Remove–CronJob - anongitmous/k8sShell GitHub Wiki

Remove the Kubernetes cron job resource(s).

Syntax

Remove-CronJob

[-CronJobs] <Mtf.Kubernetes.Models.V1K8sCronJob[]>
[<K8sShellRemoveParameters>]
[<K8sShellCommonCore>]
[<CommonParameters>]

Description

Removes cron job resource objects from the cluster.

Examples

ℹ️ See A Note about the Examples

1. Delete all cron jobs from the currently active namespace

Get-CronJobs | Remove-CronJob

  • The results from Get–CronJobs are piped into Remove-CronJob
  • If there is no currently active namespace (i.e. namespace is $null or an empty string ''), then this would delete all cron jobs from all namespaces.
  • Using aliasing, the above can be shortened to
    ksgcj | ksrcj

2. Delete all cron jobs from the 'foo' namespace

Get-CronJobs -Namespace 'foo' | Remove-CronJob

  • Using aliasing, the above can be shortened to
    ksgcj -ns 'foo' | ksrcj

3. Delete the cron job named 'my_cron_job' in the 'foo' namespace

Get-CronJobs -Namespace 'foo' | Where-Object {$_.Name -match 'my_cron_job'} | Remove-CronJob

  • To do a trial run, utilize the -DryRun All option:
    Get-CronJobs -Namespace 'foo' | Where-Object {$_.Name -match 'my_cron_job'} | Remove-CronJob -DryRun All
  • Using aliasing, the previous can be shortened to
    ksgcj | ? {$_.Name -match 'my_cron_job'} | ksrcj -DryRun All

Parameters

-CronJobs

  • Specifies the cron job(s) to delete.
Type: Mtf.Kubernetes.Models.V1K8sCronJob[]
Aliases:
Position: 0
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

See Remove Parameters
See Common Parameters/Non-namespaced Core Context

Inputs

  • Mtf.Kubernetes.Models.V1K8sCronJob
    You can pipe cron job object(s) to this cmdlet.

Outputs

Mtf.Kubernetes.K8sWrapperCommon.K8sObjectDeleterResponse<k8s.Models.V1CronJob>

Notes

K8sShell includes the following alias for Remove-CronJob:

  • ksrcj

This cmdlet does not have a namespace parameter because the service objects processed by it are self-contained in that they carry with them the InvocationConfig active at their creation.

Related