Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not get the cronjob running on the image #17

Open
lucheeseng827 opened this issue Dec 25, 2019 · 0 comments
Open

Could not get the cronjob running on the image #17

lucheeseng827 opened this issue Dec 25, 2019 · 0 comments

Comments

@lucheeseng827
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant