Kubernetes在使用配额时坚持"ContainerCreating"



我试图在kubernetes中使用配额功能,但每次我的容器都卡住了"ContainerCreating"而不是继续前进

我不知道是什么问题。

MyQuota yaml:

apiVersion: v1
kind: ResourceQuota
metadata:
creationTimestamp: null
name: awesome-quota
spec: 
hard:
pods: 2
requests.cpu: 1
requests.memory: 1024m
limits.cpu: 4
limits.memory: 4096m
status: {}

我的nginx yaml有配额细节:

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx:1.18.0
name: nginx
resources:
limits:
cpu: "1"
memory: "1024m"
requests:
cpu: "0.5"
memory: "512m"
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}

谢谢Abdul

将内存单元更改为"Mi"注意,您的样例进行了稍微修改,以限制kube-public名称空间中的作用域。

> cat << EOF | kubectl apply -f -
> apiVersion: v1
> kind: ResourceQuota
> metadata:
>   name: test-quota
>   namespace: kube-public
> spec: 
>   hard:
>      pods: 2
>      requests.cpu: 1
>      requests.memory: 1024Mi
>      limits.cpu: 4
>      limits.memory: 4096Mi
> EOF
resourcequota/test-quota created

运行示例pod:

> cat << EOF | kubectl apply -f -
> apiVersion: v1
> kind: Pod
> metadata:
>   labels:
>     app: nginx
>   name: nginx
>   namespace: kube-public
> spec:
>   containers:
>   - image: nginx:latest
>     name: nginx
>     resources:
>       limits:
>         cpu: "1"
>         memory: "1024Mi"
>       requests:
>         cpu: "0.5"
>         memory: "512Mi"
>   dnsPolicy: ClusterFirst
>   restartPolicy: Never
> EOF
pod/nginx created

pod按预期运行:

> kubectl get pods -n kube-public
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          37s

如果资源。限制没有上界:

> cat << EOF | kubectl apply -f -
> apiVersion: v1
> kind: Pod
> metadata:
>   labels:
>     app: nginx
>   name: nginx
>   namespace: kube-public
> spec:
>   containers:
>   - image: nginx:latest
>     name: nginx
>     resources:
>       requests:
>         cpu: "0.5"
>         memory: "512Mi"
>   dnsPolicy: ClusterFirst
>   restartPolicy: Never
> EOF
Error from server (Forbidden): error when creating "STDIN": pods "nginx" is forbidden: failed quota: test-quota: must specify limits.cpu,limits.memory

相关内容

  • 没有找到相关文章

最新更新