Skip to content

Could not get the cronjob running on the image  #17

@lucheeseng827

Description

@lucheeseng827

Hi there, I am planning to use the image as the cronjob for my kubernetes pods which are marked as completed.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cleanup-prod
spec:
  schedule: "*/20 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: kubectl-runner
            image: werner/kubectl
            command: ["sh", "-c", "kubectl delete pods -n test-prod $(kubectl get pods -n test-prod |grep 'Completed'| awk '$3 ' | awk '{print $1}')"]
          restartPolicy: Never

when log from the pods/cronjob

kubectl logs  cleanup-prod-156kd  -n default
No resources found, use --show-all to see completed objects.
error: resource(s) were provided, but no name, label selector, or --all flag specified

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions