Certificated 도전/CKAD- Kubernetes

[CKAD] Service Account 완벽 정리

지추월자 2024. 9. 5. 14:46
반응형

Pod가 쿠버네티스 API와 상호작용할 때 사용하는 계정이 바로 Service Account 이다. 

무조건 사용하는 것! 여러분들이 설정한 적 없어도 이미 설정되어있는 것이 그것이 바로 service account

목적 


클러스터에 있는 모든 Pod는 쿠버네티스 API 서버와 상호작용할 수 있는 권한이 필요하는데 이때 사용하는 계정이 바로 Service Account이다. 이는 User Account와는 다르다. Service Account는 pod와 같은 애플리케이션이 클러스터 내에서 수행할 작업을 위해서 사용하는 것이다.

쿠버네티스는 기본적으로 각 네임스페이스의 default 라는 Service Account가 자동으로 생성된다. 그래서 별도의 Service Account를 생성하지 않거나 지정하지 않는다면 자동으로 default라는 service Account를 사용하게 된다. 

 

각 Service Account는 고유한 토큰을 가지고 있으며, 이 토큰을 통해 쿠버네티스 API 서버와 인증을 할 수 있습니다. Pod가 실행될 때, 이 토큰이 자동으로 마운트되며, 이를 통해 쿠버네티스 API에 접근할 수 있습니다.

 

사용 방법

default가 아닌 service account를 사용하기 위해서는 pods 등을 생성할 때 spec.serviceAccountName에 지정해줘야 해당 service account가 지정된다. 만약에 이미 생성된 pods의 service account를 변경해야하면 해당 pods의 백업 yaml 파일을 생성한다음에 해당 yaml파일을 수정해서 반영해야하고, 기존에 있는 pods를 삭제해야한다. 

Service account 문제는 무조건 나오는 문제라고하니 완전히 이해하고 있으면 좋을 듯 싶다! 

 

참고문서들 

https://kubernetes.io/docs/concepts/security/service-accounts/

 

Service Accounts

Learn about ServiceAccount objects in Kubernetes.

kubernetes.io

 

https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

 

Configure Service Accounts for Pods

Kubernetes offers two distinct ways for clients that run within your cluster, or that otherwise have a relationship to your cluster's control plane to authenticate to the API server. A service account provides an identity for processes that run in a Pod, a

kubernetes.io

 

반응형

'Certificated 도전 > CKAD- Kubernetes' 카테고리의 다른 글

[CKAD] NetworkPolicy 무조건 알아야함  (0) 2024.09.06