kubernetes 正在尝试来自Kubnetes的示例Cronjob,但出现错误

sbdsn5lh  于 2023-02-07  发布在  Kubernetes
关注(0)|答案(1)|浏览(124)

我尝试使用Kubernetes文档here中解释的示例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
ddrv8njm

ddrv8njm1#

您的命名空间似乎配置了配额。请尝试配置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

注意**resources:**和它的缩进。

相关问题