Closed janlauber closed 2 years ago
@janlauber thanks for creating this issue! Can you post the failing pod yaml here? I guess there will be a container inside this pod that does not specify resources, for example an init container. You can circumvent this problem by creating a limit range in the host namespace like this:
apiVersion: v1
kind: LimitRange
metadata:
name: vcluster-limit-range
spec:
limits:
- default:
cpu: 100m
memory: 256Mi
defaultRequest:
cpu: 20m
memory: 64Mi
min:
cpu: 10m
memory: 32Mi
type: Container
EDIT: looking at the bitnami chart there are definitely some init containers that do not have resources defined.
Hey @FabianKramm I tested this again on a minikube cluster with the following manifest files Host minikube Cluster:
# hostcluster namespace
apiVersion: v1
kind: Namespace
metadata:
name: test
# hostcluster namespace resourcequota
apiVersion: v1
kind: ResourceQuota
metadata:
name: test-resourcequota
namespace: test
spec:
hard:
cpu: "2"
memory: 5Gi
# hostcluster namespace limit range
apiVersion: v1
kind: LimitRange
metadata:
name: vcluster-limit-range
namespace: test
spec:
limits:
- default:
cpu: 100m
memory: 256Mi
defaultRequest:
cpu: 20m
memory: 64Mi
min:
cpu: 10m
memory: 32Mi
type: Container
Inside the vCluster:
# pod with set subdomain and resource requests for cpu and memory
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: test-pod
image: ubuntu
command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]
resources:
requests:
memory: "1Gi"
cpu: "500m"
subdomain: test
The following event occurs when you describe the pending test-pod:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning SyncError 2s (x13 over 23s) pod-syncer Error syncing to physical cluster: pods "test-pod-x-default-x-vcluster" is forbidden: failed quota: test-resourcequota: must specify cpu,memory
I think this is a general problem which occurs in vclusters.
@janlauber it works for me with:
# pod with set subdomain and resource requests for cpu and memory
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: test-pod
image: ubuntu
command: ["/bin/sh"]
args: ["-c", "while true; do echo hello; sleep 10;done"]
resources:
limits:
memory: "1Gi"
cpu: "500m"
requests:
memory: "1Gi"
cpu: "500m"
subdomain: test
problem is that the default limit from the LimitRange is smaller than the requested resources from the pod which results in the error:
Error syncing to physical cluster: Pod "test-pod-x-default-x-vcluster" is invalid: [spec.containers[0].resources.requests: Invalid value: "500m": must be less than or equal to cpu limit, spec.containers[0].resources.requests: Invalid value: "1Gi": must be less than or equal to memory limit]
@FabianKramm Thank you very much for this. Implemented this with postgresql-ha cluster and it's working! Thanks for your help, closing this one!
What happened?
I recently tried to deploy the bitnami postgresql-ha helm chart into a vcluster. The helm values are as follows:
The hostnamespace has a resourcequota set with the following values:
But the postgresql statefulset pods stayed on pending. When I described them I saw the following error:
What did you expect to happen?
So I debugged the pod specs and found out that when you unset the following spec value, the pod will get deployed:
It should be possible to deploy pods with the subdomain set.
How can we reproduce it (as minimally and precisely as possible)?
deploy the following resource quota in the host namespace:
deploy the following test pod in a vCluster:
It will be stuck in pending
Anything else we need to know?
No response
Host cluster Kubernetes version
Host cluster Kubernetes distribution
vlcuster version
Vcluster Kubernetes distribution(k3s(default)), k8s, k0s)
OS and Arch