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

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

Trying example Cronjob from Kubnetes with errors

问题

以下是翻译好的部分:

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

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文件。

apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
  namespace: test
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: hello
              image: busybox:1.28
              imagePullPolicy: IfNotPresent
              command:
                - /bin/sh
                - c
                - date; echo Hello from the Kubernetes cluster
          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.

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.

apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
  namespace: test
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: hello
              image: busybox:1.28
              imagePullPolicy: IfNotPresent
              command:
                - /bin/sh
                - c
                - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

答案1

得分: 1

你的命名空间似乎已配置了配额。尝试在你的CronJob上配置资源,例如:

    apiVersion: batch/v1
    kind: CronJob
    metadata:
      name: hello
      namespace: test
    spec:
      schedule: "* * * * *"
      jobTemplate:
        spec:
          template:
            spec:
              containers:
                - name: hello
                  image: busybox:1.28
                  imagePullPolicy: IfNotPresent
                  command:
                    - /bin/sh
                    - c
                    - date; echo Hello from the Kubernetes cluster
                  resources:
                    requests:
                      memory: "64Mi"
                      cpu: "250m"
                    limits:
                      memory: "128Mi"
                      cpu: "500m"
              restartPolicy: OnFailure
英文:

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

apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
  namespace: test
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: hello
              image: busybox:1.28
              imagePullPolicy: IfNotPresent
              command:
                - /bin/sh
                - c
                - date; echo Hello from the Kubernetes cluster
              resources:
                requests:
                  memory: "64Mi"
                  cpu: "250m"
                limits:
                  memory: "128Mi"
                  cpu: "500m"
          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:

确定