본문 바로가기
Compute/kubernetis

31. 새로 추가된 시험 유형 - 6 / PriorityClass 생성

by 조청유곽 2025. 11. 7.
반응형

[Question]

Create a new PriorityClass named high-priority for user-workloads with a value 
that is one less than the highest existing user-defined priority class value.
Patch the existing Deployment busybox-logger running in the priority namespace 
to use the high-priority priority class.
Ensure that the busybox-logger Deployment rolls out successfully with the new priority class set.
It is expected that Pods from other Deployments running in the priority namespace are evicted.

 


 

[Precondition]

- deployment(busybox-logger), namespace(priority), priorityclass(user-defined) 생성 

root@controlplane ~ ✖ kubectl create namespace priority
namespace/priority created

root@controlplane ~ ➜  kubectl create deployment -n priority busybox-logger --image=nginx --dry-run=client -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: busybox-logger
  name: busybox-logger
  namespace: priority
spec:
  replicas: 1
  selector:
    matchLabels:
      app: busybox-logger
  strategy: {}
  template:
    metadata:
      labels:
        app: busybox-logger
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}

root@controlplane ~ ➜  kubectl create deployment -n priority busybox-logger --image=nginx 
deployment.apps/busybox-logger created
root@controlplane ~ ➜  cat 31.user-defined.yaml 
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: user-defined
value: 1000000
preemptionPolicy: Never
globalDefault: false
description: "이 프라이어리티클래스는 다른 파드를 축출하지 않는다."

root@controlplane ~ ➜  kubectl apply -f 31.user-defined.yaml 
priorityclass.scheduling.k8s.io/user-defined created

 


 

[Solve]

- high-priority 생성 

- deployments에 적용
   priorityClassName: high-priority

 

root@controlplane ~ ➜  cat 31.priority.yaml 
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: high-priority
value: 100000
globalDefault: false
description: "이 프라이어리티클래스는 XYZ 서비스 파드에만 사용해야 한다."
root@controlplane ~ ➜  kubectl get deployments -n priority busybox-logger -o yaml
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: busybox-logger
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: busybox-logger
    spec:
      containers:
      - image: nginx
        imagePullPolicy: Always
        name: nginx
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      priorityClassName: high-priority
      restartPolicy: Always
반응형