aws-samples / aws-workshop-for-kubernetes

AWS Workshop for Kubernetes
Apache License 2.0
2.66k stars 1.07k forks source link

"Create resources with ResourceQuota" uses a pod with only a memory limit - should also have a cpu limit #574

Open parsiya opened 5 years ago

parsiya commented 5 years ago

In Create resources with ResourceQuota, a ResourceQuota with both CPU and memory limit is set.

$ cat resource-quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: quota
spec:
  hard:
    cpu: "4"
    memory: 6G
    pods: "10"
    replicationcontrollers: "3"
    services: "5"
    configmaps: "5"

However, later when using examples. It's run against a quota with only a memory limit.

First, it attempts to create a pod with no limits. So the error message is

$ kubectl apply -f pod.yaml
Error from server (Forbidden): error when creating "pod.yaml": pods "nginx-pod" is forbidden: failed quota: quota: must specify memory

This is wrong, the error message must mention that both memory and cpu must be specified.

failed quota: quota: must specify cpu,memory

The tutorial then mentions we should use a memory limit. It should mention that we need to specify both a CPU and a memory limit.

The error message indicates that a ResourceQuota is in effect, and that the Pod must explicitly specify memory resources.

Later, a pod with a memory limit is created. This does not work with the quota from the previous step because it only has a memory limit and no CPU limit.

Under Get more details about the ResourceQuota: the output of kubectl describe quota/quota says 400m in front of CPU. It should be 1.

This line explains due to a bug in Kubernetes, we do not need to specify both a CPU and a memory limit.

kubernetes/kubernetes#55433 appears to have been fixed. I tried on the latest AWS EKS and we need both CPU and memory limit in the pod.