尝试使用 Kubernetes 中的 CronJob 示例,出现了错误。

huangapple go评论80阅读模式
英文:

Trying example Cronjob from Kubnetes with errors

问题

以下是翻译好的部分:

我尝试使用Kubernetes文档中解释的示例cronjob 这里。但是,当我在Lens上检查它(这是一个用于显示Kubernetes信息的工具)时,创建一个Pod时出现错误。 Kubernetes示例和我的代码之间唯一的区别是,由于我不拥有我正在工作的服务器,我添加了一个命名空间。 感谢任何帮助。 以下是我的错误和YAML文件。

  1. Error creating: pods "hello-27928364--1-ftzjb" is forbidden: exceeded quota: test-rq, requested: limits.cpu=16,limits.memory=64Gi,requests.cpu=16,requests.memory=64Gi, used: limits.cpu=1,limits.memory=2G,requests.cpu=1,requests.memory=2G, limited: limits.cpu=12,limits.memory=24Gi,requests.cpu=12,requests.memory=24Gi

这是我应用的YAML文件。

  1. apiVersion: batch/v1
  2. kind: CronJob
  3. metadata:
  4. name: hello
  5. namespace: test
  6. spec:
  7. schedule: "* * * * *"
  8. jobTemplate:
  9. spec:
  10. template:
  11. spec:
  12. containers:
  13. - name: hello
  14. image: busybox:1.28
  15. imagePullPolicy: IfNotPresent
  16. command:
  17. - /bin/sh
  18. - c
  19. - date; echo Hello from the Kubernetes cluster
  20. restartPolicy: OnFailure
英文:

I am trying to use the example cronjob that is explained through Kubernetes documentation here. However, when I check it on Lens (a tool to display Kubernetes info), I receive an error upon creating a pod. The only difference between the Kubernetes example and my code is I added a namespace since I do not own the server I am working on. Any help is appreciated. Below is my error and yaml file.

  1. Error creating: pods "hello-27928364--1-ftzjb" is forbidden: exceeded quota: test-rq, requested: limits.cpu=16,limits.memory=64Gi,requests.cpu=16,requests.memory=64Gi, used: limits.cpu=1,limits.memory=2G,requests.cpu=1,requests.memory=2G, limited: limits.cpu=12,limits.memory=24Gi,requests.cpu=12,requests.memory=24Gi

This is my yaml file that I apply.

  1. apiVersion: batch/v1
  2. kind: CronJob
  3. metadata:
  4. name: hello
  5. namespace: test
  6. spec:
  7. schedule: "* * * * *"
  8. jobTemplate:
  9. spec:
  10. template:
  11. spec:
  12. containers:
  13. - name: hello
  14. image: busybox:1.28
  15. imagePullPolicy: IfNotPresent
  16. command:
  17. - /bin/sh
  18. - c
  19. - date; echo Hello from the Kubernetes cluster
  20. restartPolicy: OnFailure

答案1

得分: 1

  1. 你的命名空间似乎已配置了配额。尝试在你的CronJob上配置资源,例如:
  2. apiVersion: batch/v1
  3. kind: CronJob
  4. metadata:
  5. name: hello
  6. namespace: test
  7. spec:
  8. schedule: "* * * * *"
  9. jobTemplate:
  10. spec:
  11. template:
  12. spec:
  13. containers:
  14. - name: hello
  15. image: busybox:1.28
  16. imagePullPolicy: IfNotPresent
  17. command:
  18. - /bin/sh
  19. - c
  20. - date; echo Hello from the Kubernetes cluster
  21. resources:
  22. requests:
  23. memory: "64Mi"
  24. cpu: "250m"
  25. limits:
  26. memory: "128Mi"
  27. cpu: "500m"
  28. restartPolicy: OnFailure
英文:

Your namespace seems to have a quota configured. Try to configure the resources on your CronJob, for example:

  1. apiVersion: batch/v1
  2. kind: CronJob
  3. metadata:
  4. name: hello
  5. namespace: test
  6. spec:
  7. schedule: "* * * * *"
  8. jobTemplate:
  9. spec:
  10. template:
  11. spec:
  12. containers:
  13. - name: hello
  14. image: busybox:1.28
  15. imagePullPolicy: IfNotPresent
  16. command:
  17. - /bin/sh
  18. - c
  19. - date; echo Hello from the Kubernetes cluster
  20. resources:
  21. requests:
  22. memory: "64Mi"
  23. cpu: "250m"
  24. limits:
  25. memory: "128Mi"
  26. cpu: "500m"
  27. restartPolicy: OnFailure

Note the resources: and it's indentation.

huangapple
  • 本文由 发表于 2023年2月7日 01:11:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75364469.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定