Skip to content

[quota management] Create test for quota exceeding k8 quota #374

@KPostOffice

Description

@KPostOffice
Contributor

If requested quota is greater than k8 quota, the AppWrapper should successfully schedule, but no pods should be created due to k8 enforced limits.

Files used:

k8-tiny-quota.yaml

apiVersion: v1
kind: ResourceQuota
metadata:
  name: example
  namespace: test1
spec:
  hard:
    requests.cpu: '1m'
    requests.memory: 1Mi
    limits.cpu: '1m'
    limits.memory: 1Mi

testing-forest.yaml

apiVersion: ibm.com/v1
kind: QuotaSubtree
metadata:
  name: context-root
  namespace: kube-system
  labels:
    tree: quota_context
spec:
  children:
    - name: context-root
      quotas:
        hardLimit: true
        requests:
          cpu: 2000
          memory: 8000Mi
---
apiVersion: ibm.com/v1
kind: QuotaSubtree
metadata:
  name: context-root-children
  namespace: kube-system
  labels:
    tree: quota_context
spec:
  parent: context-root
  children:
    - name: alpha
      quotas:
        hardLimit: false
        requests:
          cpu: 1000
          memory: 4000Mi
    - name: beta
      quotas:
        requests:
          cpu: 1000
          memory: 4000Mi

exceeed-k8-quota.yaml

apiVersion: mcad.ibm.com/v1beta1
kind: AppWrapper
metadata:
  name: fail-for-k8
  namespace: test1
  labels:
    quota_context: "alpha"
spec:
  service:
    spec: {}
  resources:
    metadata: {}
    GenericItems:
      - metadata: {}
        replicas: 1
        custompodresources:
        - replicas:  1
          requests:
            cpu: 500m
            memory: 2000Mi
          limits:
            cpu: 500m
            memory: 2000Mi
        generictemplate:
          apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
          kind: StatefulSet
          metadata:
            name: fail-for-k8
            namespace: test1
            labels:
              app: fail-for-k8
          spec:
            selector:
              matchLabels:
                app: fail-for-k8
            replicas: 1
            template:
              metadata:
                labels:
                  app: fail-for-k8
                  size: "1"
              spec:
                containers:
                  - name: fail-for-k8
                    image: registry.access.redhat.com/ubi8/ubi:latest
                    command:
                      - /bin/sh
                      - -c
                      - while true; do sleep 10; done
                    resources:
                      requests:
                        cpu: "500m"
                        memory: "2000Mi"
                      limits:
                        cpu: "500m"
                        memory: "2000Mi"

Expect

An event indicating that a pod cannot be scheduled due to resource limits being exceeded, i.e.:

create Pod fail-for-k8-0 in StatefulSet fail-for-k8 failed error: pods "fail-for-k8-0" is forbidden: exceeded
quota: example, requested: limits.cpu=500m,limits.memory=2000Mi,requests.cpu=500m,requests.memory=2000Mi,
used: limits.cpu=0,limits.memory=0,requests.cpu=0,requests.memory=0,
limited: limits.cpu=1m,limits.memory=1Mi,requests.cpu=1m,requests.memory=1Mi

Activity

KPostOffice

KPostOffice commented on May 16, 2023

@KPostOffice
ContributorAuthor
changed the title [-]Create test for quota exceeding k8 quota[/-] [+][quota management] Create test for quota exceeding k8 quota[/+] on May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tardieu@KPostOffice

        Issue actions

          [quota management] Create test for quota exceeding k8 quota · Issue #374 · project-codeflare/multi-cluster-app-dispatcher