Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

전공공부

[K8S - CKA] ServiceAccounts 본문

Study/K8S

[K8S - CKA] ServiceAccounts

monitor 2024. 1. 14. 21:30

정확하지는 않으나 ServiceAccount는 token을 생성하고 생성된 토큰 정보를 이용해서 각 pod에 도달 할 수 있는 역할을 수행한다. 예를 들어서 ca.crt 등 요청으로 curl 날려서 API 요청을 일일이 했던 것을 serviceaccount를 이용해서 연결을 하는데 ServiceAccounts만들고 k create token SECRET_ACCOUNT_NAME 을 하면 해당 정보로 도달 할 수 있는 토큰을 주고 이를 사용하여도 되고 아니면 아래와 같이  RoleBinding에 설정해서 접근 권한의 대한 허가를 주고 이때에 Deployments에도 해당 ServiceAccount로 접근 가능하게 설정을 하면 된다.

 

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  serviceAccountName: build-robot
  automountServiceAccountToken: false

 

apiVersion: v1
kind: ServiceAccount
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"ServiceAccount","metadata":{"annotations":{},"creationTimestamp":null,"name":"dashboard-sa","namespace":"default"}}
  creationTimestamp: "2024-01-14T12:08:13Z"
  name: dashboard-sa
  namespace: default
  resourceVersion: "965"
  uid: ce2807cc-8f31-487a-b40f-a2c736167af7

 

 

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  creationTimestamp: "2024-01-14T12:08:18Z"
  name: pod-reader
  namespace: default
  resourceVersion: "968"
  uid: 55a79261-8322-46c5-b642-da8ec6916726
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
  - watch
  - list

 

 

 

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  creationTimestamp: "2024-01-14T12:08:18Z"
  name: read-pods
  namespace: default
  resourceVersion: "969"
  uid: 3d408e40-cbc8-4dca-b385-3bc96c088c57
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: pod-reader
subjects:
- kind: ServiceAccount
  name: dashboard-sa
  namespace: default

'Study > K8S' 카테고리의 다른 글

[K8S - CKA] Security Context  (0) 2024.01.16
[K8S - CKA] Image Security  (0) 2024.01.16
[K8S - CKA] Cluster Role & Role Binding  (1) 2024.01.11
[K8S - CKA] Role Based Access Controls  (1) 2024.01.10
[K8S - CKA] Authorization  (0) 2024.01.09