"Killer Shell CKS - Apiserver NodeRestriction"의 두 판 사이의 차이

4번째 줄: 4번째 줄:
* 목적: node01의 Kubelet 신분으로, 금지 접두어(node-restriction.kubernetes.io/*)를 갖는 Node 레이블을 설정할 수 있는지 시험하여 NodeRestriction 어드미션 플러그인이 비활성화되어 있음을 확인
* 목적: node01의 Kubelet 신분으로, 금지 접두어(node-restriction.kubernetes.io/*)를 갖는 Node 레이블을 설정할 수 있는지 시험하여 NodeRestriction 어드미션 플러그인이 비활성화되어 있음을 확인


==배경==
----
* NodeRestriction 어드미션 플러그인이 활성화되어 있으면, Kubelet(주체: system:node:<노드명>, 그룹: system:nodes)은 자신(Node, 자신이 생성한 Pod) 범위를 벗어난 변경이나 특정 예약 접두어 레이블(node-restriction.kubernetes.io/*) 변경이 거부된다.
* NodeRestriction 어드미션 플러그인이 활성화되어 있으면, Kubelet(주체: system:node:<노드명>, 그룹: system:nodes)은 자신(Node, 자신이 생성한 Pod) 범위를 벗어난 변경이나 특정 예약 접두어 레이블(node-restriction.kubernetes.io/*) 변경이 거부된다.
* 본 단계의 목표는 “현재는 제한이 적용되지 않음”을 증명하는 것이다. 따라서 node01의 kubelet 신분으로 위 접두어 레이블을 추가해 보고 성공한다면, 제한이 꺼져 있음을 확인할 수 있다.
* 본 단계의 목표는 “현재는 제한이 적용되지 않음”을 증명하는 것이다. 따라서 node01의 kubelet 신분으로 위 접두어 레이블을 추가해 보고 성공한다면, 제한이 꺼져 있음을 확인할 수 있다.
<syntaxhighlight lang='console'>
controlplane:~$ k get node
NAME          STATUS  ROLES          AGE  VERSION
controlplane  Ready    control-plane  39h  v1.34.1
node01        Ready    <none>          39h  v1.34.1
</syntaxhighlight>


==검증 절차==
==검증 절차==
12번째 줄: 19번째 줄:
<syntaxhighlight lang='console'>
<syntaxhighlight lang='console'>
controlplane:~$ ssh node01
controlplane:~$ ssh node01
Last login: Mon Feb 10 22:06:42 2025 from 10.244.0.131
node01:~$ export KUBECONFIG=/etc/kubernetes/kubelet.conf
node01:~$ export KUBECONFIG=/etc/kubernetes/kubelet.conf
node01:~$ k get node
node01:~$ k get node
NAME    STATUS  ROLES          AGE  VERSION
Error from server (Forbidden): nodes is forbidden: User "system:node:node01" cannot list resource "nodes" in API group "" at the cluster scope: node 'node01' cannot read all nodes, only its own Node object
controlplane  Ready    control-plane  ...  v1.xx.x
node01         Ready    <none>          ...  v1.xx.x
</syntaxhighlight>
</syntaxhighlight>


30번째 줄: 37번째 줄:
node-restriction.kubernetes.io/one=123
node-restriction.kubernetes.io/one=123
</syntaxhighlight>
</syntaxhighlight>
위와 같이 Kubelet 자격으로 제한 접두어 레이블이 성공적으로 추가되었다면, 현재 NodeRestriction이 적용되지 않았음을 확인한 것이다.
위와 같이 Kubelet 자격으로 제한 접두어 레이블이 성공적으로 추가되었다면, 현재 NodeRestriction이 적용되지 않았음을 확인한 것이다.
참고: 만약 제한이 올바르게 적용된 환경이라면, 아래와 유사한 거부 메시지가 나타난다.
<syntaxhighlight lang='console'>
Error from server (Forbidden): nodes "node01" is forbidden:
node "node01" cannot modify labels with prefix "node-restriction.kubernetes.io/"
</syntaxhighlight>
==정리(선택)==
다음 단계(제한 활성화 실습)를 위해 레이블을 제거해 둔다.
<syntaxhighlight lang='console'>
node01:~$ k label node node01 node-restriction.kubernetes.io/one-
</syntaxhighlight>
==팁==
* kubelet 자격으로 호출: 환경변수 KUBECONFIG=/etc/kubernetes/kubelet.conf 사용
** 또는 명령별로 --kubeconfig=/etc/kubernetes/kubelet.conf 지정 가능
* kubelet.conf는 각 노드에 존재하므로, 본 실습은 node01에서 수행하는 것이 안전하다.


==같이 보기==
==같이 보기==
* Kubernetes NodeRestriction 문서: https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#noderestriction
* Admission Controllers 개요: https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/
* [[Killer Shell CKS]]
* [[Killer Shell CKS]]


[[분류: Killer Shell CKS]]
[[분류: Killer Shell CKS]]

2025년 11월 19일 (수) 19:44 판

1 개요

Killer Shell CKS - Apiserver NodeRestriction

  • NodeRestriction 어드미션 플러그인이 활성화되어 있으면, Kubelet(주체: system:node:<노드명>, 그룹: system:nodes)은 자신(Node, 자신이 생성한 Pod) 범위를 벗어난 변경이나 특정 예약 접두어 레이블(node-restriction.kubernetes.io/*) 변경이 거부된다.
  • 본 단계의 목표는 “현재는 제한이 적용되지 않음”을 증명하는 것이다. 따라서 node01의 kubelet 신분으로 위 접두어 레이블을 추가해 보고 성공한다면, 제한이 꺼져 있음을 확인할 수 있다.
controlplane:~$ k get node
NAME           STATUS   ROLES           AGE   VERSION
controlplane   Ready    control-plane   39h   v1.34.1
node01         Ready    <none>          39h   v1.34.1

2 검증 절차

node01 호스트에서 Kubelet 자격증명으로 API 서버에 접근해, 제한 접두어 레이블 추가를 시도한다.

controlplane:~$ ssh node01
Last login: Mon Feb 10 22:06:42 2025 from 10.244.0.131

node01:~$ export KUBECONFIG=/etc/kubernetes/kubelet.conf
node01:~$ k get node
Error from server (Forbidden): nodes is forbidden: User "system:node:node01" cannot list resource "nodes" in API group "" at the cluster scope: node 'node01' cannot read all nodes, only its own Node object

레이블 추가 시도:

node01:~$ k label node node01 node-restriction.kubernetes.io/one=123
node/node01 labeled

레이블이 실제로 적용되었는지 확인:

node01:~$ k get node node01 --show-labels | tr ',' '\n' | grep node-restriction.kubernetes.io/one
node-restriction.kubernetes.io/one=123

위와 같이 Kubelet 자격으로 제한 접두어 레이블이 성공적으로 추가되었다면, 현재 NodeRestriction이 적용되지 않았음을 확인한 것이다.

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}