尽管指定了 cpu 限制,但在 pod 部署期间出现 "Must specify limits.cpu" 错误
"Must specify limits.cpu" error during pod deployment even though cpu limit is specified
我正在尝试 运行 使用 OpenShift CLI 进行测试:
$oc run nginx --image=nginx --limits=cpu=2,memory=4Gi
deploymentconfig.apps.openshift.io/nginx created
$oc describe deploymentconfig.apps.openshift.io/nginx
Name: nginx
Namespace: myproject
Created: 12 seconds ago
Labels: run=nginx
Annotations: <none>
Latest Version: 1
Selector: run=nginx
Replicas: 1
Triggers: Config
Strategy: Rolling
Template:
Pod Template:
Labels: run=nginx
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Limits:
cpu: 2
memory: 4Gi
Environment: <none>
Mounts: <none>
Volumes: <none>
Deployment #1 (latest):
Name: nginx-1
Created: 12 seconds ago
Status: New
Replicas: 0 current / 0 desired
Selector: deployment=nginx-1,deploymentconfig=nginx,run=nginx
Labels: openshift.io/deployment-config.name=nginx,run=nginx
Pods Status: 0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal DeploymentCreated 12s deploymentconfig-controller Created new replication controller "nginx-1" for version 1
Warning FailedCreate 1s (x12 over 12s) deployer-controller Error creating deployer pod: pods "nginx-1-deploy" is forbidden: failed quota: quota-svc-myproject: must specify limits.cpu,limits.memory
我收到“必须指定 limits.cpu,limits.memory”错误,尽管两个限制都存在于同一个 describe 输出中。
可能是什么问题,我该如何解决?
您似乎已经指定了资源配额,并且您为限制指定的值似乎大于该值。您能否描述一下资源配额 oc describe quota quota-svc-myproject
并相应地调整您的配置。
一个很好的参考可以是 https://docs.openshift.com/container-platform/3.11/dev_guide/compute_resources.html
我找到了解决办法!
错误消息的一部分是“创建部署程序容器时出错”。这意味着问题不在于我的 pod,而在于执行我的 pod 部署的 deployer pod。
看来我项目中的配额也会影响部署程序 pods。
我找不到使用 CLI 设置部署程序 pod 限制的方法,所以我制作了一个 DeploymentConfig。
kind: "DeploymentConfig"
apiVersion: "v1"
metadata:
name: "test-app"
spec:
template:
metadata:
labels:
name: "test-app"
spec:
containers:
- name: "test-app"
image: "nginxinc/nginx-unprivileged"
resources:
limits:
cpu: "2000m"
memory: "20Gi"
ports:
- containerPort: 8080
protocol: "TCP"
replicas: 1
selector:
name: "test-app"
triggers:
- type: "ConfigChange"
- type: "ImageChange"
imageChangeParams:
automatic: true
containerNames:
- "test-app"
from:
kind: "ImageStreamTag"
name: "nginx-unprivileged:latest"
strategy:
type: "Rolling"
resources:
limits:
cpu: "2000m"
memory: "20Gi"
你可以看到,这里指定了两组限制:容器和部署策略。
使用此配置,它运行良好!
我正在尝试 运行 使用 OpenShift CLI 进行测试:
$oc run nginx --image=nginx --limits=cpu=2,memory=4Gi
deploymentconfig.apps.openshift.io/nginx created
$oc describe deploymentconfig.apps.openshift.io/nginx
Name: nginx
Namespace: myproject
Created: 12 seconds ago
Labels: run=nginx
Annotations: <none>
Latest Version: 1
Selector: run=nginx
Replicas: 1
Triggers: Config
Strategy: Rolling
Template:
Pod Template:
Labels: run=nginx
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Limits:
cpu: 2
memory: 4Gi
Environment: <none>
Mounts: <none>
Volumes: <none>
Deployment #1 (latest):
Name: nginx-1
Created: 12 seconds ago
Status: New
Replicas: 0 current / 0 desired
Selector: deployment=nginx-1,deploymentconfig=nginx,run=nginx
Labels: openshift.io/deployment-config.name=nginx,run=nginx
Pods Status: 0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal DeploymentCreated 12s deploymentconfig-controller Created new replication controller "nginx-1" for version 1
Warning FailedCreate 1s (x12 over 12s) deployer-controller Error creating deployer pod: pods "nginx-1-deploy" is forbidden: failed quota: quota-svc-myproject: must specify limits.cpu,limits.memory
我收到“必须指定 limits.cpu,limits.memory”错误,尽管两个限制都存在于同一个 describe 输出中。
可能是什么问题,我该如何解决?
您似乎已经指定了资源配额,并且您为限制指定的值似乎大于该值。您能否描述一下资源配额 oc describe quota quota-svc-myproject
并相应地调整您的配置。
一个很好的参考可以是 https://docs.openshift.com/container-platform/3.11/dev_guide/compute_resources.html
我找到了解决办法!
错误消息的一部分是“创建部署程序容器时出错”。这意味着问题不在于我的 pod,而在于执行我的 pod 部署的 deployer pod。 看来我项目中的配额也会影响部署程序 pods。 我找不到使用 CLI 设置部署程序 pod 限制的方法,所以我制作了一个 DeploymentConfig。
kind: "DeploymentConfig"
apiVersion: "v1"
metadata:
name: "test-app"
spec:
template:
metadata:
labels:
name: "test-app"
spec:
containers:
- name: "test-app"
image: "nginxinc/nginx-unprivileged"
resources:
limits:
cpu: "2000m"
memory: "20Gi"
ports:
- containerPort: 8080
protocol: "TCP"
replicas: 1
selector:
name: "test-app"
triggers:
- type: "ConfigChange"
- type: "ImageChange"
imageChangeParams:
automatic: true
containerNames:
- "test-app"
from:
kind: "ImageStreamTag"
name: "nginx-unprivileged:latest"
strategy:
type: "Rolling"
resources:
limits:
cpu: "2000m"
memory: "20Gi"
你可以看到,这里指定了两组限制:容器和部署策略。
使用此配置,它运行良好!