From c2a3f75bc369206e27091bbf39f74cc184f0ba4a Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 00:28:57 +0900 Subject: [PATCH] feat(priority): add platform-critical and platform-low PriorityClasses Every platform pod runs at priority 0. During the 2026-11-09 disk eviction the tech-log production pods were ranked with Grafana and kube-state-metrics. The kubelet ranks evictions by usage over requests and then by priority, so without classes the database and the production app have no head start. Add two classes and attach nothing yet: platform-critical (1000000, may preempt) for platform-postgres, Gitea, Keycloak and tech-log, and platform-low (-1000, never preempts) for Grafana, pgAdmin, Loki and Tempo. Neither is the global default, so no pod changes silently. Risk: creating the classes changes no pod. Attaching them restarts the pods, so that is left for the k3s restart window. Verification: render-tenants-and-policies.sh (added later in this series) checks the values, the preemption policy and globalDefault. --- services/priority-classes/README.md | 20 +++++++++++++++ services/priority-classes/kustomization.yaml | 5 ++++ .../priority-classes/priority-classes.yaml | 25 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 services/priority-classes/README.md create mode 100644 services/priority-classes/kustomization.yaml create mode 100644 services/priority-classes/priority-classes.yaml diff --git a/services/priority-classes/README.md b/services/priority-classes/README.md new file mode 100644 index 0000000..26eb2dc --- /dev/null +++ b/services/priority-classes/README.md @@ -0,0 +1,20 @@ +# 플랫폼 PriorityClass + +노드가 한 대라 자원이 모자라면 kubelet이 파드를 내보낸다. 내보낼 순서는 requests를 넘었는지, +그다음 우선순위로 정한다. 2026-11-09 디스크 축출 때 플랫폼 파드는 모두 우선순위 0이라 tech-log +운영 파드가 Grafana·kube-state-metrics와 같은 순위로 나갔다. + +| 이름 | 값 | 선점 | 붙일 곳 | +| --- | --- | --- | --- | +| `platform-critical` | 1000000 | 낮은 것을 선점 | platform-postgres, Gitea, Keycloak, tech-log | +| `platform-low` | -1000 | 선점 안 함 | Grafana, pgAdmin, Loki, Tempo | + +- 아무것도 안 붙인 파드는 기본값 0이다. 시스템 클래스(`system-*`, 20억)는 그대로 가장 높다. +- `globalDefault`는 둘 다 끈다. 새 파드가 모르게 우선순위를 얻지 않게 하려는 것이다. +- 클래스를 만드는 것은 아무 파드도 바꾸지 않는다. **붙이는 것은 파드 재시작을 부르므로** + k3s 재시작 창에 한다(`infrastructure/host/k3s/README.md`). + +```sh +kubectl apply -k services/priority-classes +kubectl get priorityclass platform-critical platform-low +``` diff --git a/services/priority-classes/kustomization.yaml b/services/priority-classes/kustomization.yaml new file mode 100644 index 0000000..8ba8781 --- /dev/null +++ b/services/priority-classes/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - priority-classes.yaml diff --git a/services/priority-classes/priority-classes.yaml b/services/priority-classes/priority-classes.yaml new file mode 100644 index 0000000..38f87ea --- /dev/null +++ b/services/priority-classes/priority-classes.yaml @@ -0,0 +1,25 @@ +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: platform-critical + labels: + app.kubernetes.io/part-of: platform +value: 1000000 +globalDefault: false +preemptionPolicy: PreemptLowerPriority +description: >- + Stateful platform services and production workloads that other services depend on + (platform-postgres, Gitea, Keycloak, tech-log). Evicted after everything else. +--- +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: platform-low + labels: + app.kubernetes.io/part-of: platform +value: -1000 +globalDefault: false +preemptionPolicy: Never +description: >- + Tools whose loss does not stop a user-facing service (Grafana, pgAdmin, Loki, Tempo). + Evicted first and never preempts another pod.