简体   繁体   English

在 cronjob k8s 中运行容器

[英]Run container in cronjob k8s

I have a dockerfile finishing with an entrypoint:我有一个 dockerfile 完成一个入口点:

ENTRYPOINT ["/bin/bash" , "-c", "source /app/env.sh && printenv && python3 /app/script.py"]

And a yaml k8s CronJob:还有一个 yaml k8s CronJob:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my_healthcheck
  namespace: default
  labels:
    app: my_healthcheck
spec:
  schedule: "30 8 * * 1-5"
  jobTemplate:
    spec:
      backoffLimit: 5
      template:
        spec:
          containers:
            - name: pythonscript
              image: xxx/pythonscript:latest
          imagePullPolicy: IfNotPresent
          command: [ <what do i put here> ]
          restartPolicy: OnFailure

Inside "command", what command i need to put, to run the container ?在“命令”中,我需要输入什么命令来运行容器? thanks谢谢

The image ENTRYPOINT handles everything, so the command doesn't need to supplied.图像ENTRYPOINT处理所有内容,因此不需要提供该command

If you do provide a command , it will override the ENTRYPOINT .如果您确实提供了command ,它将覆盖ENTRYPOINT

    command: [ '/bin/bash', '-c', 'echo "not running python"' ]

You can supply args if you want to append arguments to the command / ENTRYPOINT .如果要将参数附加到command / ENTRYPOINT则可以提供args

See the difference between the Kubernetes/Docker terms .查看Kubernetes/Docker 术语之间的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM