1.2. AMQ Streams Operator
AMQ Streams Operator는 OpenShift에서 Kafka를 효과적으로 관리하기 위해 전문 지식으로 구축된 것입니다. 각 Operator는 고유한 기능을 수행합니다.
- Cluster Operator
- Cluster Operator는 OpenShift에서 Apache Kafka 클러스터의 배포 및 관리를 처리합니다. Kafka 브로커 및 기타 Kafka 구성 요소 및 리소스의 설정을 자동화합니다.
- 주제 Operator
- Topic Operator는 Kafka 클러스터 내의 주제 생성, 구성 및 삭제를 관리합니다.
- User Operator
- User Operator는 Kafka 브로커에 액세스해야 하는 Kafka 사용자를 관리합니다.
AMQ Streams를 배포할 때 먼저 Cluster Operator를 배포합니다. 그런 다음 Cluster Operator가 Kafka 배포를 처리할 준비가 되었습니다. Cluster Operator(권장) 또는 독립 실행형 Operator를 사용하여 Topic Operator 및 User Operator를 배포할 수도 있습니다. Cluster Operator에서 관리하지 않는 Kafka 클러스터와 함께 독립 실행형 Operator를 사용합니다.
Topic Operator 및 User Operator는 Entity Operator의 일부입니다. Cluster Operator는 Entity Operator 구성에 따라 Operator를 하나 또는 둘 다 배포할 수 있습니다.
독립 실행형 Operator를 배포하려면 Kafka 클러스터에 연결할 환경 변수를 설정해야 합니다. Cluster Operator에 의해 설정되므로 Operator를 배포하는 경우 이러한 환경 변수를 설정할 필요가 없습니다.
1.2.1. OpenShift 네임스페이스에서 AMQ Streams 리소스 모니터링 링크 복사링크가 클립보드에 복사되었습니다!
Operator는 OpenShift 네임스페이스에서 AMQ Streams 리소스를 감시하고 관리합니다. Cluster Operator는 단일 네임스페이스, 여러 네임스페이스 또는 OpenShift 클러스터의 모든 네임스페이스를 조사할 수 있습니다. Topic Operator 및 User Operator는 단일 네임스페이스를 조사할 수 있습니다.
-
Cluster Operator는
Kafka리소스를 감시합니다. -
주제 Operator는
KafkaTopic리소스를 감시합니다. -
User Operator는
KafkaUser리소스를 조사합니다.
Topic Operator 및 User Operator는 네임스페이스에서 단일 Kafka 클러스터만 조사할 수 있습니다. 또한 단일 Kafka 클러스터에만 연결할 수 있습니다.
여러 주제 Operator에서 동일한 네임스페이스를 조사하는 경우 이름 충돌 및 주제 삭제가 발생할 수 있습니다. 각 Kafka 클러스터는 이름이 동일한 Kafka 주제(예: __consumer_offsets)를 사용하기 때문입니다. 하나의 주제 Operator만 지정된 네임스페이스를 감시하는지 확인합니다.
단일 네임스페이스에서 여러 User Operator를 사용하는 경우 지정된 사용자 이름이 있는 사용자는 둘 이상의 Kafka 클러스터에 존재할 수 있습니다.
Cluster Operator를 사용하여 Topic Operator 및 User Operator를 배포하는 경우 기본적으로 Cluster Operator가 배포한 Kafka 클러스터를 확인합니다. Operator 구성에서 watchedNamespace 를 사용하여 네임스페이스를 지정할 수도 있습니다.
각 Operator의 독립 실행형 배포의 경우 네임스페이스를 지정하고 구성을 조사할 Kafka 클러스터에 연결합니다.
1.2.2. RBAC 리소스 관리 링크 복사링크가 클립보드에 복사되었습니다!
Cluster Operator는 OpenShift 리소스에 액세스해야 하는 AMQ Streams 구성 요소에 대한 RBAC(역할 기반 액세스 제어) 리소스를 생성하고 관리합니다.
Cluster Operator가 작동하려면 Kafka 및 KafkaConnect 와 같은 Kafka 리소스와 상호 작용하고 ConfigMap,Pod,배포 및 서비스와 같은 관리형 리소스와 상호 작용하려면 OpenShift 클러스터 내 권한이 필요합니다.
권한은 다음 OpenShift RBAC 리소스를 통해 지정됩니다.
-
ServiceAccount -
Role및ClusterRole -
RoleBinding및ClusterRoleBinding
1.2.2.1. AMQ Streams 구성 요소에 대한 권한 위임 링크 복사링크가 클립보드에 복사되었습니다!
Cluster Operator는 strimzi-cluster-operator 라는 서비스 계정에서 실행됩니다. AMQ Streams 구성 요소에 대한 RBAC 리소스를 생성할 수 있는 권한을 부여하는 클러스터 역할이 할당됩니다. 역할 바인딩은 클러스터 역할과 서비스 계정을 연결합니다.
OpenShift는 하나의 ServiceAccount 에서 작동하는 구성 요소가 ServiceAccount 부여에 없는 다른 ServiceAccount 권한을 부여하지 못하도록 합니다. Cluster Operator는 관리하는 리소스에 필요한 RoleBinding 및 ClusterRoleBinding RBAC 리소스를 생성하므로 동일한 권한을 제공하는 역할이 필요합니다.
다음 표에는 Cluster Operator가 생성한 RBAC 리소스에 대해 설명합니다.
| 이름 | 사용 대상 |
|---|---|
|
| Kafka 브로커 Pod |
|
| zookeeper Pod |
|
| Kafka Connect Pod |
|
| MirrorMaker Pod |
|
| MirrorMaker 2 Pod |
|
| Kafka 브리지 Pod |
|
| 엔터티 Operator |
| 이름 | 사용 대상 |
|---|---|
|
| Cluster Operator |
|
| Cluster Operator |
|
| Cluster Operator |
|
| 클러스터 Operator, 랙 기능(사용 시) |
|
| Cluster Operator, Topic Operator, User Operator |
|
| 랙을 위한 Cluster Operator, Kafka 클라이언트 |
| 이름 | 사용 대상 |
|---|---|
|
| Cluster Operator |
|
| 랙을 위한 Cluster Operator, Kafka 브로커 |
|
| 랙을 위한 Cluster Operator, Kafka 클라이언트 |
| 이름 | 사용 대상 |
|---|---|
|
| Cluster Operator |
|
| 랙을 위한 Cluster Operator, Kafka 브로커 |
1.2.2.2. ServiceAccount를 사용하여 Cluster Operator 실행 링크 복사링크가 클립보드에 복사되었습니다!
Cluster Operator는 ServiceAccount 를 사용하여 실행하는 것이 가장 좋습니다.
Cluster Operator의 ServiceAccount 예
apiVersion: v1
kind: ServiceAccount
metadata:
name: strimzi-cluster-operator
labels:
app: strimzi
그런 다음 Operator 배포 는 spec.template.spec.serviceAccountName 에 이 값을 지정해야 합니다.
Cluster Operator의 부분 배포 예
apiVersion: apps/v1
kind: Deployment
metadata:
name: strimzi-cluster-operator
labels:
app: strimzi
spec:
replicas: 1
selector:
matchLabels:
name: strimzi-cluster-operator
strimzi.io/kind: cluster-operator
template:
metadata:
labels:
name: strimzi-cluster-operator
strimzi.io/kind: cluster-operator
spec:
serviceAccountName: strimzi-cluster-operator
# ...
1.2.2.3. ClusterRole 리소스 링크 복사링크가 클립보드에 복사되었습니다!
Cluster Operator는 ClusterRole 리소스를 사용하여 리소스에 필요한 액세스 권한을 제공합니다. OpenShift 클러스터 설정에 따라 클러스터 관리자가 클러스터 역할을 생성하는 데 필요할 수 있습니다.
클러스터 관리자 권한은 ClusterRole 리소스를 생성하는 경우에만 필요합니다. Cluster Operator는 클러스터 관리자 계정에서 실행되지 않습니다.
ClusterRole 리소스는 최소 권한 원칙을 따르고 Kafka 구성 요소의 클러스터를 작동하기 위해 Cluster Operator에 필요한 권한만 포함합니다. 첫 번째 할당된 권한 세트를 사용하면 Cluster Operator에서 배포,Pod 및 ConfigMap 과 같은 OpenShift 리소스를 관리할 수 있습니다.
권한을 위임하려면 Cluster Operator에 모든 클러스터 역할이 필요합니다.
Cluster Operator는 strimzi-cluster-operator-namespaced 및 strimzi-cluster-operator-global 클러스터 역할을 사용하여 네임스페이스 범위의 리소스 수준 및 클러스터 범위 리소스 수준에서 권한을 부여합니다.
Cluster Operator의 네임스페이스 리소스가 있는 ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: strimzi-cluster-operator-namespaced
labels:
app: strimzi
rules:
# Resources in this role are used by the operator based on an operand being deployed in some namespace. When needed, you
# can deploy the operator as a cluster-wide operator. But grant the rights listed in this role only on the namespaces
# where the operands will be deployed. That way, you can limit the access the operator has to other namespaces where it
# does not manage any clusters.
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
# The cluster operator needs to access and manage rolebindings to grant Strimzi components cluster permissions
- rolebindings
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
# The cluster operator needs to access and manage roles to grant the entity operator permissions
- roles
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- ""
resources:
# The cluster operator needs to access and delete pods, this is to allow it to monitor pod health and coordinate rolling updates
- pods
# The cluster operator needs to access and manage service accounts to grant Strimzi components cluster permissions
- serviceaccounts
# The cluster operator needs to access and manage config maps for Strimzi components configuration
- configmaps
# The cluster operator needs to access and manage services and endpoints to expose Strimzi components to network traffic
- services
- endpoints
# The cluster operator needs to access and manage secrets to handle credentials
- secrets
# The cluster operator needs to access and manage persistent volume claims to bind them to Strimzi components for persistent data
- persistentvolumeclaims
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- "apps"
resources:
# The cluster operator needs to access and manage deployments to run deployment based Strimzi components
- deployments
- deployments/scale
- deployments/status
# The cluster operator needs to access and manage stateful sets to run stateful sets based Strimzi components
- statefulsets
# The cluster operator needs to access replica-sets to manage Strimzi components and to determine error states
- replicasets
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- "" # legacy core events api, used by topic operator
- "events.k8s.io" # new events api, used by cluster operator
resources:
# The cluster operator needs to be able to create events and delegate permissions to do so
- events
verbs:
- create
- apiGroups:
# Kafka Connect Build on OpenShift requirement
- build.openshift.io
resources:
- buildconfigs
- buildconfigs/instantiate
- builds
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- networking.k8s.io
resources:
# The cluster operator needs to access and manage network policies to lock down communication between Strimzi components
- networkpolicies
# The cluster operator needs to access and manage ingresses which allow external access to the services in a cluster
- ingresses
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- route.openshift.io
resources:
# The cluster operator needs to access and manage routes to expose Strimzi components for external access
- routes
- routes/custom-host
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- image.openshift.io
resources:
# The cluster operator needs to verify the image stream when used for Kafka Connect image build
- imagestreams
verbs:
- get
- apiGroups:
- policy
resources:
# The cluster operator needs to access and manage pod disruption budgets this limits the number of concurrent disruptions
# that a Strimzi component experiences, allowing for higher availability
- poddisruptionbudgets
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
Cluster Operator의 클러스터 범위 리소스가 있는 ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: strimzi-cluster-operator-global
labels:
app: strimzi
rules:
- apiGroups:
- "rbac.authorization.k8s.io"
resources:
# The cluster operator needs to create and manage cluster role bindings in the case of an install where a user
# has specified they want their cluster role bindings generated
- clusterrolebindings
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
- apiGroups:
- storage.k8s.io
resources:
# The cluster operator requires "get" permissions to view storage class details
# This is because only a persistent volume of a supported storage class type can be resized
- storageclasses
verbs:
- get
- apiGroups:
- ""
resources:
# The cluster operator requires "list" permissions to view all nodes in a cluster
# The listing is used to determine the node addresses when NodePort access is configured
# These addresses are then exposed in the custom resource states
- nodes
verbs:
- list
strimzi-cluster-operator-leader-election 클러스터 역할은 리더 선택에 필요한 권한을 나타냅니다.
리더 선택 권한이 있는 ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: strimzi-cluster-operator-leader-election
labels:
app: strimzi
rules:
- apiGroups:
- coordination.k8s.io
resources:
# The cluster operator needs to access and manage leases for leader election
# The "create" verb cannot be used with "resourceNames"
- leases
verbs:
- create
- apiGroups:
- coordination.k8s.io
resources:
# The cluster operator needs to access and manage leases for leader election
- leases
resourceNames:
# The default RBAC files give the operator only access to the Lease resource names strimzi-cluster-operator
# If you want to use another resource name or resource namespace, you have to configure the RBAC resources accordingly
- strimzi-cluster-operator
verbs:
- get
- list
- watch
- delete
- patch
- update
strimzi-kafka-broker 클러스터 역할은 랙 인식을 사용하는 Kafka Pod의 init 컨테이너에서 필요한 액세스를 나타냅니다.
strimzi- <cluster_name> -kafka-init 라는 역할 바인딩은 strimzi > -kafka 서비스 계정 액세스 권한을 부여합니다. rack 기능을 사용하지 않고 클러스터가 -kafka-broker 역할을 사용하여 <cluster_namenodeport 를 통해 노출되지 않으면 바인딩이 생성되지 않습니다.
Cluster Operator의 ClusterRole 을 통해 OpenShift 노드에 대한 액세스를 Kafka 브로커 Pod에 위임할 수 있습니다.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: strimzi-kafka-broker
labels:
app: strimzi
rules:
- apiGroups:
- ""
resources:
# The Kafka Brokers require "get" permissions to view the node they are on
# This information is used to generate a Rack ID that is used for High Availability configurations
- nodes
verbs:
- get
strimzi-entity-operator 클러스터 역할은 Topic Operator 및 User Operator에 필요한 액세스를 나타냅니다.
Topic Operator는 상태 정보를 사용하여 OpenShift 이벤트를 생성하므로 < cluster_name> -entity-operator 서비스 계정이 strimzi-entity-operator 역할에 바인딩되어 strimzi-entity-operator 역할 바인딩을 통해 이 액세스 권한을 부여합니다.
Cluster Operator의 ClusterRole 을 통해 이벤트에 대한 액세스를 Topic 및 User Operator에 위임할 수 있습니다.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: strimzi-entity-operator
labels:
app: strimzi
rules:
- apiGroups:
- "kafka.strimzi.io"
resources:
# The entity operator runs the KafkaTopic assembly operator, which needs to access and manage KafkaTopic resources
- kafkatopics
- kafkatopics/status
# The entity operator runs the KafkaUser assembly operator, which needs to access and manage KafkaUser resources
- kafkausers
- kafkausers/status
verbs:
- get
- list
- watch
- create
- patch
- update
- delete
- apiGroups:
- ""
resources:
- events
verbs:
# The entity operator needs to be able to create events
- create
- apiGroups:
- ""
resources:
# The entity operator user-operator needs to access and manage secrets to store generated credentials
- secrets
verbs:
- get
- list
- watch
- create
- delete
- patch
- update
strimzi-kafka-client 클러스터 역할은 랙 인식을 사용하는 Kafka 클라이언트가 필요로 하는 액세스를 나타냅니다.
Cluster Operator의 ClusterRole 을 통해 OpenShift 노드에 대한 액세스를 Kafka 클라이언트 기반 Pod에 위임할 수 있습니다.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: strimzi-kafka-client
labels:
app: strimzi
rules:
- apiGroups:
- ""
resources:
# The Kafka clients (Connect, Mirror Maker, etc.) require "get" permissions to view the node they are on
# This information is used to generate a Rack ID (client.rack option) that is used for consuming from the closest
# replicas when enabled
- nodes
verbs:
- get
1.2.2.4. ClusterRoleBinding 리소스 링크 복사링크가 클립보드에 복사되었습니다!
Cluster Operator는 ClusterRoleBinding 및 RoleBinding 리소스를 사용하여 ClusterRole 을 ServiceAccount 와 연결합니다. 클러스터 역할 바인딩은 클러스터 범위 리소스가 포함된 클러스터 역할에 필요합니다.
Cluster Operator의 ClusterRoleBinding 예
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: strimzi-cluster-operator
labels:
app: strimzi
subjects:
- kind: ServiceAccount
name: strimzi-cluster-operator
namespace: myproject
roleRef:
kind: ClusterRole
name: strimzi-cluster-operator-global
apiGroup: rbac.authorization.k8s.io
권한 위임에 사용되는 클러스터 역할에도 클러스터 역할 바인딩이 필요합니다.
Cluster Operator 및 Kafka 브로커 랙 인식에 대한 ClusterRoleBinding 의 예
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: strimzi-cluster-operator-kafka-broker-delegation
labels:
app: strimzi
# The Kafka broker cluster role must be bound to the cluster operator service account so that it can delegate the cluster role to the Kafka brokers.
# This must be done to avoid escalating privileges which would be blocked by Kubernetes.
subjects:
- kind: ServiceAccount
name: strimzi-cluster-operator
namespace: myproject
roleRef:
kind: ClusterRole
name: strimzi-kafka-broker
apiGroup: rbac.authorization.k8s.io
Cluster Operator 및 Kafka 클라이언트 랙 인식에 대한 ClusterRoleBinding 의 예
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: strimzi-cluster-operator-kafka-client-delegation
labels:
app: strimzi
# The Kafka clients cluster role must be bound to the cluster operator service account so that it can delegate the
# cluster role to the Kafka clients using it for consuming from closest replica.
# This must be done to avoid escalating privileges which would be blocked by Kubernetes.
subjects:
- kind: ServiceAccount
name: strimzi-cluster-operator
namespace: myproject
roleRef:
kind: ClusterRole
name: strimzi-kafka-client
apiGroup: rbac.authorization.k8s.io
네임스페이스된 리소스만 포함하는 클러스터 역할은 역할 바인딩만 사용하여 바인딩됩니다.
Cluster Operator의 RoleBinding 예
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: strimzi-cluster-operator
labels:
app: strimzi
subjects:
- kind: ServiceAccount
name: strimzi-cluster-operator
namespace: myproject
roleRef:
kind: ClusterRole
name: strimzi-cluster-operator-namespaced
apiGroup: rbac.authorization.k8s.io
Cluster Operator 및 Kafka 브로커 랙 인식에 대한 RoleBinding 의 예
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: strimzi-cluster-operator-entity-operator-delegation
labels:
app: strimzi
# The Entity Operator cluster role must be bound to the cluster operator service account so that it can delegate the cluster role to the Entity Operator.
# This must be done to avoid escalating privileges which would be blocked by Kubernetes.
subjects:
- kind: ServiceAccount
name: strimzi-cluster-operator
namespace: myproject
roleRef:
kind: ClusterRole
name: strimzi-entity-operator
apiGroup: rbac.authorization.k8s.io