ResourceQuota 적용 테스트
이 단계에서는 ResourceQuota 에 정의된 리소스 제한을 초과하는 Pod 를 생성하고, ResourceQuota 가 제한을 적용하는지 확인합니다. 방법은 다음과 같습니다.
pod-exceeding-limits.yaml이라는 파일을 만들고 다음 내용을 입력합니다.
apiVersion: v1
kind: Pod
metadata:
name: example-pod-exceeding-limits
spec:
containers:
- name: nginx
image: nginx
resources:
limits:
cpu: "2"
memory: "2Gi"
이 Pod 정의는 Step:Creating a ResourceQuota에서 생성된 ResourceQuota 에 설정된 제한을 초과하는 리소스 (CPU: 2 코어, 메모리: 2 GiB) 를 요청하는 컨테이너가 있는 Pod 를 생성합니다.
kubectl apply 명령을 사용하여 pod-exceeding-limits.yaml 파일을 Kubernetes 클러스터에 적용합니다.
kubectl apply -f pod-exceeding-limits.yaml
Pod 생성 작업이 거부되는 것을 확인할 수 있습니다. 오류 메시지는 다음과 같습니다: Error from server (Forbidden): error when creating "pod-exceeding-limits.yaml": pods "example-pod-exceeding-limits" is forbidden: exceeded quota: example-resourcequota, requested: cpu=2,memory=2Gi, used: cpu=0,memory=0, limited: cpu=1,memory=1Gi.