CKA SimB - Q17 Operator, CRD, RBAC, Kustomize

1 개요[ | ]

Operator, CRD, RBAC, Kustomize 통합 실습
  • Kubernetes Operator는 CRD(사용자 정의 리소스)를 기반으로 클러스터 리소스를 자동 관리하는 컨트롤러
  • RBAC을 통해 Operator에 적절한 권한을 부여하며, Kustomize를 활용해 배포 환경별 구성을 관리할 수 있음
  • 이 문서에서는 Operator 설치, CRD 적용, Role/RoleBinding 설정, Kustomize를 이용한 배포를 실습함

2 1단계: CRD 생성[ | ]

  • CRD는 새로운 리소스 타입을 정의함
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: widgets.example.com
spec:
  group: example.com
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              size:
                type: string
  scope: Namespaced
  names:
    plural: widgets
    singular: widget
    kind: Widget
    shortNames:
    - wd

3 2단계: RBAC 설정[ | ]

  • CRD 리소스를 관리할 수 있도록 Role 및 RoleBinding 생성
# role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: widget-manager
  namespace: default
rules:
- apiGroups: ["example.com"]
  resources: ["widgets"]
  verbs: ["get", "list", "create", "update", "delete"]

# rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: widget-binding
  namespace: default
subjects:
- kind: ServiceAccount
  name: default
  namespace: default
roleRef:
  kind: Role
  name: widget-manager
  apiGroup: rbac.authorization.k8s.io

4 3단계: Kustomize 디렉터리 구조[ | ]

.
├── base
│   ├── crd.yaml
│   ├── role.yaml
│   ├── rolebinding.yaml
│   └── kustomization.yaml
└── overlays
    └── dev
        ├── kustomization.yaml
  • base/kustomization.yaml
resources:
  - crd.yaml
  - role.yaml
  - rolebinding.yaml
  • overlays/dev/kustomization.yaml
bases:
  - ../../base
namespace: default

5 4단계: 리소스 적용[ | ]

  • Kustomize로 통합 적용
# kubectl apply -k overlays/dev

6 5단계: CRD 리소스 생성 및 확인[ | ]

  • 사용자 정의 리소스 생성
apiVersion: example.com/v1
kind: Widget
metadata:
  name: sample-widget
spec:
  size: large
  • 생성 후 확인
# kubectl get widgets
NAME             AGE
sample-widget    10s

7 요약[ | ]

  • CRD는 새로운 리소스 유형을 정의하며, Operator는 이를 자동 관리
  • RBAC을 통해 CRD에 대한 접근 권한을 제어
  • Kustomize를 이용하면 배포 환경에 따라 리소스를 구조적으로 관리 가능
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}