본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

쿠버네티스에서 컨트롤 플레인 권한 관리

원문 보기 위키 갱신

쿠버네티스에서 컨트롤 플레인 권한 관리 (Control Plane Permissions on Kubernetes)

Kong Mesh는 기본적으로 쿠버네티스 클러스터 전체 범위에서 리소스를 관찰하고 이벤트에 반응해요. 이 문서에서는 namespaceAllowList 옵션을 사용해 컨트롤 플레인이 접근할 수 있는 네임스페이스를 선택적으로 제한하는 방법을 설명해요. 클러스터 범위 리소스 생성이 제한된 환경을 위해 RBAC 리소스를 직접 관리하고 자동 생성을 끄는 방법도 함께 다루니까 프로덕션 환경의 보안을 강화할 때 참고해 보세요

출처: 문서

본문

기본적으로 Kubernetes에 배포된 Kong Mesh는 이벤트에 반응하면서 클러스터 범위에서 모든 리소스를 관찰해요. 이 방식은 기능을 살펴보고 싶은 처음 사용하는 분들에게 유리하고 마이그레이션도 간단해져요. 하지만 프로덕션 환경에서는 특정 리소스로 접근을 제한하면 보안을 강화하고 Kong Mesh가 실행 중인 애플리케이션에 영향을 주지 않도록 할 수 있어요.

선택한 네임스페이스로 권한 제한하기

Kong Mesh 컨트롤 플레인이 접근할 수 있는 네임스페이스 목록을 정의할 수 있어요. 이 목록이 설정되면 Kong Mesh는 선택된 네임스페이스와 자체 시스템 네임스페이스에서만 권한을 가져요. 그 외 다른 네임스페이스의 리소스에는 접근하거나 관리할 수 없어요.

Kong Mesh를 특정 네임스페이스 집합으로 제한하려면 설치 시 kuma.namespaceAllowList 옵션을 설정하세요:

kumactl

kumactl install control-plane \
  --set "kuma.namespaceAllowList={first-namespace,second-namespace}" \
  | kubectl apply -f -

{:.no-line-numbers}

Helm

# Before installing Kong Mesh with Helm, configure your local Helm repository:
# https://developer.konghq.com/mesh/2.14/production/cp-deployment/kubernetes/#helm
helm install \
  --create-namespace \
  --namespace kong-mesh-system \
  --set "kuma.namespaceAllowList={first-namespace,second-namespace}" \
  kong-mesh kong-mesh/kong-mesh

{:.no-line-numbers}

이렇게 하면 나열된 각 네임스페이스에 RoleBinding이 생성되고, kong-mesh-control-plane-workloads ClusterRole이 해당 네임스페이스에 바인딩돼요. 또한 Kong Mesh의 mutating 웹훅과 validating 웹훅이 지정된 네임스페이스 안에서만 작동하도록 구성돼요.

RBAC 리소스 수동으로 관리하기

환경에서 클러스터 범위 리소스(ClusterRole 또는 ClusterRoleBinding) 생성을 제한하거나, 권한을 직접 관리하고 싶다면 설치 시 자동 리소스 생성을 비활성화할 수 있어요.

Kong Mesh를 설치하기 전에 다음 리소스를 수동으로 만들어야 해요:

  • 컨트롤 플레인이 사용하는 ClusterRole과 ClusterRoleBinding
  • 컨트롤 플레인 네임스페이스 안의 Role과 RoleBinding
  • namespaceAllowList를 사용할 때 선택한 네임스페이스의 RoleBindings (선택 사항)

필요한 매니페스트 전체 세트는 여기에서 확인할 수 있어요:

ClusterRole

kong-mesh-control-plane

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kong-mesh-control-plane
rules:
- apiGroups:
  - ''
  resources:
  - namespaces
  - pods
  - nodes
  - services
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - discovery.k8s.io
  resources:
  - endpointslices
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - apps
  resources:
  - deployments
  - replicasets
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - batch
  resources:
  - jobs
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gateways
  - referencegrants
  - httproutes
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gatewayclasses
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gatewayclasses/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - kuma.io
  resources:
  - dataplanes
  - dataplaneinsights
  - meshes
  - zones
  - zoneinsights
  - zoneingresses
  - zoneingressinsights
  - zoneegresses
  - zoneegressinsights
  - meshinsights
  - serviceinsights
  - proxytemplates
  - ratelimits
  - trafficpermissions
  - trafficroutes
  - timeouts
  - retries
  - circuitbreakers
  - virtualoutbounds
  - containerpatches
  - externalservices
  - faultinjections
  - healthchecks
  - trafficlogs
  - traffictraces
  - meshgateways
  - meshgatewayroutes
  - meshgatewayinstances
  - meshgatewayconfigs
  - meshaccesslogs
  - meshcircuitbreakers
  - meshfaultinjections
  - meshglobalratelimits
  - meshhealthchecks
  - meshhttproutes
  - meshloadbalancingstrategies
  - meshmetrics
  - meshopas
  - meshpassthroughs
  - meshproxypatches
  - meshratelimits
  - meshretries
  - meshtcproutes
  - meshtimeouts
  - meshtlses
  - meshtraces
  - meshtrafficpermissions
  - hostnamegenerators
  - meshexternalservices
  - meshidentities
  - meshmultizoneservices
  - meshopentelemetrybackends
  - meshservices
  - meshtrusts
  - meshzoneaddresses
  - workloads
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - kuma.io
  resources:
  - meshgatewayinstances/status
  - meshgatewayinstances/finalizers
  - meshes/finalizers
  - dataplanes/finalizers
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - authentication.k8s.io
  resources:
  - tokenreviews
  verbs:
  - create

{:.no-line-numbers}

kong-mesh-control-plane-workloads

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kong-mesh-control-plane-workloads
rules:
- apiGroups:
  - ''
  - events.k8s.io
  resources:
  - events
  verbs:
  - create
  - patch
- apiGroups:
  - apps
  resources:
  - deployments
  - replicasets
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - batch
  resources:
  - jobs
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ''
  resources:
  - services
  verbs:
  - get
  - delete
  - list
  - watch
  - create
  - update
  - patch
- apiGroups:
  - ''
  resources:
  - pods/finalizers
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gateways
  - referencegrants
  - httproutes
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gateways/status
  - httproutes/status
  verbs:
  - get
  - patch
  - update

{:.no-line-numbers}

kong-mesh-control-plane-kmesh

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kong-mesh-control-plane-kmesh
rules:
- apiGroups:
  - kuma.io
  resources:
  - opapolicies
  - accessroles
  - accessrolebindings
  - accessaudits
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete

{:.no-line-numbers}

ClusterRoleBinding

kong-mesh-control-plane

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kong-mesh-control-plane
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kong-mesh-control-plane
subjects:
- kind: ServiceAccount
  name: kong-mesh-control-plane
  namespace: kong-mesh-system

{:.no-line-numbers}

kong-mesh-control-plane-workloads

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kong-mesh-control-plane-workloads
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kong-mesh-control-plane-workloads
subjects:
- kind: ServiceAccount
  name: kong-mesh-control-plane
  namespace: kong-mesh-system

{:.no-line-numbers}

kong-mesh-control-plane-kmesh

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kong-mesh-control-plane-kmesh
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kong-mesh-control-plane-kmesh
subjects:
- kind: ServiceAccount
  name: kong-mesh-control-plane
  namespace: kong-mesh-system

{:.no-line-numbers}

Role

kong-mesh-control-plane

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: kong-mesh-control-plane
  namespace: kong-mesh-system
rules:
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - ''
  resources:
  - configmaps
  - secrets
  verbs:
  - get
  - delete
  - list
  - watch
  - create
  - update
  - patch
- apiGroups:
  - ''
  - events.k8s.io
  resources:
  - events
  verbs:
  - create
  - patch
- apiGroups:
  - ''
  resources:
  - pods
  verbs:
  - delete
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gateways
  - referencegrants
  - httproutes
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - gateway.networking.k8s.io
  resources:
  - gateways/status
  - httproutes/status
  verbs:
  - get
  - patch
  - update

{:.no-line-numbers}

kong-mesh-control-plane-kmesh

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: kong-mesh-control-plane-kmesh
  namespace: kong-mesh-system
rules:
- apiGroups:
  - cert-manager.io
  resources:
  - certificaterequests
  verbs:
  - create
  - get
  - list
  - watch
  - update
  - delete
  - patch

{:.no-line-numbers}

RoleBinding

kong-mesh-control-plane

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: kong-mesh-control-plane
  namespace: kong-mesh-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: kong-mesh-control-plane
subjects:
- kind: ServiceAccount
  name: kong-mesh-control-plane
  namespace: kong-mesh-system

{:.no-line-numbers}

kong-mesh-control-plane-kmesh

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: kong-mesh-control-plane-kmesh
  namespace: kong-mesh-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: kong-mesh-control-plane-kmesh
subjects:
- kind: ServiceAccount
  name: kong-mesh-control-plane
  namespace: kong-mesh-system

{:.no-line-numbers}

이 매니페스트에는 kong-mesh-control-plane-workloads 바인딩이 포함되어 있어서 컨트롤 플레인이 모든 네임스페이스의 리소스에 쓰기 접근할 수 있게 돼요.

Kong Mesh를 설치하기 전에 필요한 모든 리소스를 만들어야 해요.

자동 리소스 생성 비활성화하기

모든 리소스 생성을 건너뛰려면 설치 시 kuma.skipRBAC=true를 사용하세요:

kumactl

kumactl install control-plane \
  --set "kuma.skipRBAC=true" \
  | kubectl apply -f -

{:.no-line-numbers}

Helm

# Before installing Kong Mesh with Helm, configure your local Helm repository:
# https://developer.konghq.com/mesh/2.14/production/cp-deployment/kubernetes/#helm
helm install \
  --create-namespace \
  --namespace kong-mesh-system \
  --set "kuma.skipRBAC=true" \
  kong-mesh kong-mesh/kong-mesh

{:.no-line-numbers}

클러스터 범위 리소스만 건너뛰려면 kuma.controlPlane.skipClusterRoleCreation=true를 사용하세요:

kumactl

kumactl install control-plane \
  --set "kuma.controlPlane.skipClusterRoleCreation=true" \
  | kubectl apply -f -

{:.no-line-numbers}

Helm

# Before installing Kong Mesh with Helm, configure your local Helm repository:
# https://developer.konghq.com/mesh/2.14/production/cp-deployment/kubernetes/#helm
helm install \
  --create-namespace \
  --namespace kong-mesh-system \
  --set "kuma.controlPlane.skipClusterRoleCreation=true" \
  kong-mesh kong-mesh/kong-mesh

{:.no-line-numbers}

Kong Mesh의 RBAC 리소스를 직접 관리하기로 선택했다면, 업그레이드할 때 리소스를 동기화 상태로 유지하는 걸 잊지 마세요. Kong Mesh의 새 버전이 출시되면 role과 role binding이 바뀔 수 있고, 그에 맞게 업데이트하는 건 여러분의 책임이에요.

관련 리소스

더 알아보기 (Learn more)