AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

Kubernetes Operator 배포를 위한 MongoDB 컨트롤러 범위 설정

Kubernetes Operator를 설치하기 전에 Kubernetes Operator 배포의 범위를 설정할 수 있습니다. 범위는 Ops Manager 및 MongoDB 리소스를 배포하기 위해 선택한 네임스페이스에 따라 달라집니다.

다음 범위 중 하나를 설정할 수 있습니다.

You can set the scope for the Kubernetes Operator to use the same namespace as resources. In this case, the Kubernetes Operator watches Ops Manager and MongoDB resources in that same namespace.

Kubernetes 연산자를 설치 하면 기본 네임스페이스가 사용됩니다.

You can set the scope for the Kubernetes Operator to use one or more namespaces that differ from the namespace used by the Kubernetes Operator resources. In this case, the Kubernetes Operator watches Ops Manager and MongoDB resources in a subset of namespaces that you specify.

이 범위로 Kubernetes 연산자 인스턴스를 설치하려면 operator.watchNamespace 와 함께 helm 를 사용합니다. 매개변수입니다.

네임스페이스의 하위 집합을 감시하는 것은 단일 Kubernetes 연산자 인스턴스가 다른 클러스터 리소스 유형을 감시하는 배포에서 유용합니다. 예를 들어, 네임스페이스의 한 하위 집합에서 MongoDB 리소스를 감시하고 네임스페이스의 다른 하위 집합에서 MongoDBMultiCluster 리소스를 감시하도록 Kubernetes 연산자를 구성할 수 있습니다. 리소스 조정 중에 경합 상태를 방지하려면 Kubernetes 연산자가 감시하려는 각 사용자 지정 리소스 유형에 대해 범위를 네임스페이스의 고유한 하위 집합으로 설정해야 합니다.

helm 관련 설치 지침 을 따르되 operator.watchNamespace 에 하나 이상의 네임스페이스를 지정합니다. Kubernetes 연산자가 관찰할 수 있는 매개변수입니다.

# Watch one namespace
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \
--set operator.watchNamespace='namespace-to-watch' <...>
# Watch both namespace-a and namespace-b
helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \
--set operator.watchNamespace="namespace-a\,namespace-b"
# Operator with name `mongodb-kubernetes-operator-qa-envs` will
# watch ns-dev, ns-qa and ns-uat namespaces
helm install mongodb-kubernetes-operator-qa-envs mongodb/mongodb-kubernetes \
--set operator.watchNamespace="ns-dev\,ns-qa\,ns-uat"
# Operator with name `mongodb-kubernetes-operator-staging` will
# watch ns-staging and ns-pre-prod
helm install mongodb-kubernetes-operator-staging mongodb/mongodb-kubernetes --set operator.watchNamespace="ns-staging\,ns-pre-prod"

Kubernetes 연산자가 배포된 네임스페이스가 아닌 하나 이상의 네임스페이스에 있는 리소스를 감시하기 위해 Kubernetes 연산자를 설치하는 경우:

  1. 다음 리소스를 만듭니다.

  2. 설치 중에 적용 기본값 구성 파일에 ClusterRole 및 ClusterRoleBinding을 포함합니다.

  3. 로컬 Kubernetes 서비스 계정:을 생성합니다.

    각 네임스페이스 에 대해 다음 로컬 Kubernetes ServiceAccounts의 일부 또는 전부를 생성합니다.

    • 네임스페이스에 MongoDB 인스턴스를 배포하려면 mongodb-kubernetes-database-pods 을(를) 사용합니다.

    • 네임스페이스에 Ops Manager를 배포하려면 mongodb-kubernetes-appdbmongodb-kubernetes-ops-manager 을 사용합니다.

다음 예시 클러스터 에서 ClusterRoleClusterRoleBinding 이 함께 작동하는 방식을 보여줍니다.

mongodb 네임스페이스에 ServiceAccount를 만든 다음 이 네임스페이스에 Kubernetes 연산자를 설치한다고 가정해 보겠습니다. Kubernetes 연산자는 이 서비스 계정을 사용합니다.

네임스페이스 ns1ns2 을 감시하도록 Kubernetes 연산자 범위를 설정하려면 다음을 수행합니다.

  1. 이러한 권한을 사용하여 클러스터 전체에 네임스페이스가 없는 ClusterRole을 생성합니다.

  2. Create a ClusterRoleBinding in three namespaces: mongodb, ns1 and ns2. This ClusterRoleBinding will bind the ClusterRole to the ServiceAccount in the mongodb namespace. The clusterRoleBinding will allow the Kubernetes Operator deployed in the mongodb namespace to access the resources described in the clusterRole of the target namespace, that is, in mongodb, ns1 and ns2.

operator.watchNamespace도 참조하세요.

Kubernetes Operator의 범위를 Kubernetes 클러스터 로 설정하다 수 있습니다. 이 경우 Kubernetes Operator는 MongoDB Ops Manager 와 MongoDB Kubernetes 클러스터 의 모든 네임스페이스에 있는 리소스를 감시합니다.

중요

Kubernetes cluster당 cluster 전체 범위로 Kubernetes 연산자 인스턴스를 하나만 배포할 수 있습니다.

Kubernetes Operator의 cluster 전체 범위를 설정하려면 선호하는 설치 방법에 대한 지침을 따르십시오.

  1. Set the spec.template.spec.containers.name.env.name:WATCH_NAMESPACE in mongodb-kubernetes.yaml to "*". You must include the double quotation marks (") around the asterisk (*) in the YAML file.

    WATCH_NAMESPACE: "*"
  2. In mongodb-kubernetes.yaml, change:

    kind: Role
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: mongodb-kubernetes-operator

    다음 대상:

    kind: ClusterRole
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: mongodb-kubernetes-operator
  3. 방금 수정한 ClusterRole 에 다음 코드를 추가합니다.

    - apiGroups:
    - ""
    resources:
    - namespaces
    verbs:
    - list
    - watch
  4. In mongodb-kubernetes.yaml, change:

    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: mongodb-kubernetes-operator
    namespace: mongodb
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: Role
    name: mongodb-kubernetes-operator
    subjects:
    - kind: ServiceAccount
    name: mongodb-kubernetes-operator
    namespace: mongodb

    다음 대상:

    kind: ClusterRoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: mongodb-kubernetes-operator
    namespace: mongodb
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: mongodb-kubernetes-operator
    subjects:
    - kind: ServiceAccount
    name: mongodb-kubernetes-operator
    namespace: mongodb
  5. mongodb-kubernetes.yaml 파일에서 <namespace> 값을 Kubernetes 연산자가 리소스를 배포하고 YAML 파일을 적용할 네임스페이스로 변경합니다.

    1---
    2kind: ServiceAccount
    3apiVersion: v1
    4metadata:
    5 name: mongodb-kubernetes-appdb
    6 namespace: <namespace>
    7---
    8kind: ServiceAccount
    9apiVersion: v1
    10metadata:
    11 name: mongodb-kubernetes-database-pods
    12 namespace: <namespace>
    13---
    14kind: ServiceAccount
    15apiVersion: v1
    16metadata:
    17 name: mongodb-kubernetes-ops-manager
    18 namespace: <namespace>
    19---
    20kind: Role
    21apiVersion: rbac.authorization.k8s.io/v1
    22metadata:
    23 name: mongodb-kubernetes-appdb
    24 namespace: <namespace>
    25rules:
    26 - apiGroups:
    27 - ""
    28 resources:
    29 - secrets
    30 verbs:
    31 - get
    32 - apiGroups:
    33 - ""
    34 resources:
    35 - pods
    36 verbs:
    37 - patch
    38---
    39kind: RoleBinding
    40apiVersion: rbac.authorization.k8s.io/v1
    41metadata:
    42 name: mongodb-kubernetes-appdb
    43 namespace: <namespace>
    44roleRef:
    45 apiGroup: rbac.authorization.k8s.io
    46 kind: Role
    47 name: mongodb-kubernetes-appdb
    48subjects:
    49 - kind: ServiceAccount
    50 name: mongodb-kubernetes-appdb
    51 namespace: <namespace>
    52...
  6. 로컬 Kubernetes 서비스 계정을 생성합니다.

    각 네임스페이스에 대해 다음 로컬 Kubernetes 서비스 계정 중 일부 또는 전부를 생성합니다.

    • 네임스페이스에 MongoDB 인스턴스를 배포하려면 mongodb-kubernetes-database-pods 을(를) 사용합니다.

    • 네임스페이스에 Ops Manager를 배포하려면 mongodb-kubernetes-appdbmongodb-kubernetes-ops-manager 을 사용합니다.

    해당 예제를 복사하여 붙여넣고 <namespace> 값을 네임스페이스를 식별하는 레이블로 바꿉니다.

    ---
    kind: ServiceAccount
    apiVersion: v1
    metadata:
    name: mongodb-kubernetes-database-pods
    namespace: <namespace>
    ---
    kind: ServiceAccount
    apiVersion: v1
    metadata:
    name: mongodb-kubernetes-appdb
    namespace: <namespace>
    ---
    kind: ServiceAccount
    apiVersion: v1
    metadata:
    name: mongodb-kubernetes-ops-manager
    namespace: <namespace>

Kubernetes Operator를 배포 하기 전에 다음 항목을 구성합니다.

  1. 모든 네임스페이스를 감시하도록 Kubernetes Operator를 구성합니다.

    helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \
    --set operator.watchNamespace="*"
  2. 로컬 Kubernetes 서비스 계정을 생성합니다.

    각 네임스페이스에 대해 다음 로컬 Kubernetes 서비스 계정 중 일부 또는 전부를 생성합니다.

    • 네임스페이스에 MongoDB 인스턴스를 배포하려면 mongodb-kubernetes-database-pods 을(를) 사용합니다.

    • 네임스페이스에 Ops Manager를 배포하려면 mongodb-kubernetes-appdbmongodb-kubernetes-ops-manager 을 사용합니다.

    해당 예제를 복사하여 붙여넣고 <namespace> 값을 네임스페이스를 식별하는 레이블로 바꿉니다.

    helm template mongodb/mongodb-kubernetes \
    --set operator.namespace=<metadata.namespace> \
    --show-only templates/database-roles.yaml | kubectl apply -f -

Kubernetes Operator를 배포 하기 전에 다음 항목을 구성합니다.

  1. Set the spec.template.spec.containers.name.env.name:WATCH_NAMESPACE in mongodb-kubernetes-openshift.yaml to "*". You must include the double quotation marks (") around the asterisk (*) in the YAML file.

    WATCH_NAMESPACE: "*"
  2. 이러한 계정에 해당하는 역할을 만듭니다. mongodb-kubernetes-openshift.yaml에서 다음을 변경합니다.

    kind: Role
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: enterprise-operator

    다음 대상:

    kind: ClusterRole
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: enterprise-operator
  3. 방금 수정한 ClusterRole 에 다음 코드를 추가합니다.

    - apiGroups:
    - ""
    resources:
    - namespaces
    verbs:
    - list
    - watch
  4. mongodb-kubernetes-openshift.yaml에서 다음을 변경합니다.

    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: enterprise-operator
    namespace: mongodb
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: Role
    name: enterprise-operator
    subjects:
    - kind: ServiceAccount
    name: enterprise-operator
    namespace: mongodb

    다음 대상:

    kind: ClusterRoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: enterprise-operator
    namespace: mongodb
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: enterprise-operator
    subjects:
    - kind: ServiceAccount
    name: enterprise-operator
    namespace: mongodb
  5. Create the secret only in the namespace where you will deploy the Kubernetes Operator. If you deploy MongoDB resources in multiple namespaces or with a cluster-wide scope, the Kubernetes Operator synchronizes the secret across all watched namespaces. To learn more, see the registry.imagePullSecrets setting in the Helm installation settings.

    mongodb-kubernetes.yaml 파일 에서 <namespace> 을 Kubernetes Operator를 설치하려는 네임스페이스 로 바꿉니다. oc 또는 OpenShift Container Platform UI 사용하여 결과 YAML 파일 적용 .

    1---
    2kind: ServiceAccount
    3apiVersion: v1
    4metadata:
    5 name: mongodb-kubernetes-appdb
    6 namespace: <namespace>
    7---
    8kind: ServiceAccount
    9apiVersion: v1
    10metadata:
    11 name: mongodb-kubernetes-database-pods
    12 namespace: <namespace>
    13---
    14kind: ServiceAccount
    15apiVersion: v1
    16metadata:
    17 name: mongodb-kubernetes-ops-manager
    18 namespace: <namespace>
    19---
    20kind: Role
    21apiVersion: rbac.authorization.k8s.io/v1
    22metadata:
    23 name: mongodb-kubernetes-appdb
    24 namespace: <namespace>
    25rules:
    26 - apiGroups:
    27 - ""
    28 resources:
    29 - secrets
    30 verbs:
    31 - get
    32 - apiGroups:
    33 - ""
    34 resources:
    35 - pods
    36 verbs:
    37 - patch
    38---
    39kind: RoleBinding
    40apiVersion: rbac.authorization.k8s.io/v1
    41metadata:
    42 name: mongodb-kubernetes-appdb
    43 namespace: <namespace>
    44roleRef:
    45 apiGroup: rbac.authorization.k8s.io
    46 kind: Role
    47 name: mongodb-kubernetes-appdb
    48subjects:
    49 - kind: ServiceAccount
    50 name: mongodb-kubernetes-appdb
    51 namespace: <namespace>
    52...
  6. 로컬 Kubernetes 서비스 계정을 생성합니다.

    각 네임스페이스에 대해 다음 로컬 Kubernetes 서비스 계정 중 일부 또는 전부를 생성합니다.

    • 네임스페이스에 MongoDB 인스턴스를 배포하려면 mongodb-kubernetes-database-pods 을(를) 사용합니다.

    • 네임스페이스에 Ops Manager를 배포하려면 mongodb-kubernetes-appdbmongodb-kubernetes-ops-manager 을 사용합니다.

    해당 예제를 복사하여 붙여넣고 <namespace> 값을 네임스페이스를 식별하는 레이블로 바꿉니다.

Kubernetes Operator를 배포 하기 전에 다음 항목을 구성합니다.

  1. 모든 네임스페이스를 감시하도록 Kubernetes Operator를 구성합니다.

    helm install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \
    --set operator.watchNamespace="*" \
  2. Create the secret only in the namespace where you will deploy the Kubernetes Operator. If you deploy MongoDB resources in multiple namespaces or with a cluster-wide scope, the Kubernetes Operator synchronizes the secret across all watched namespaces. To learn more, see the registry.imagePullSecrets setting in the Helm installation settings.

    mongodb-kubernetes.yaml 파일 에서 <namespace> 을 Kubernetes Operator를 설치하려는 네임스페이스 로 바꿉니다. oc 또는 OpenShift Container Platform UI 사용하여 결과 YAML 파일 적용 .

    1---
    2kind: ServiceAccount
    3apiVersion: v1
    4metadata:
    5 name: mongodb-kubernetes-appdb
    6 namespace: <namespace>
    7---
    8kind: ServiceAccount
    9apiVersion: v1
    10metadata:
    11 name: mongodb-kubernetes-database-pods
    12 namespace: <namespace>
    13---
    14kind: ServiceAccount
    15apiVersion: v1
    16metadata:
    17 name: mongodb-kubernetes-ops-manager
    18 namespace: <namespace>
    19---
    20kind: Role
    21apiVersion: rbac.authorization.k8s.io/v1
    22metadata:
    23 name: mongodb-kubernetes-appdb
    24 namespace: <namespace>
    25rules:
    26 - apiGroups:
    27 - ""
    28 resources:
    29 - secrets
    30 verbs:
    31 - get
    32 - apiGroups:
    33 - ""
    34 resources:
    35 - pods
    36 verbs:
    37 - patch
    38---
    39kind: RoleBinding
    40apiVersion: rbac.authorization.k8s.io/v1
    41metadata:
    42 name: mongodb-kubernetes-appdb
    43 namespace: <namespace>
    44roleRef:
    45 apiGroup: rbac.authorization.k8s.io
    46 kind: Role
    47 name: mongodb-kubernetes-appdb
    48subjects:
    49 - kind: ServiceAccount
    50 name: mongodb-kubernetes-appdb
    51 namespace: <namespace>
    52...
  3. 로컬 Kubernetes 서비스 계정을 생성합니다.

    각 네임스페이스에 대해 다음 로컬 Kubernetes 서비스 계정 중 일부 또는 전부를 생성합니다.

    • 네임스페이스에 MongoDB 인스턴스를 배포하려면 mongodb-kubernetes-database-pods 을(를) 사용합니다.

    • 네임스페이스에 Ops Manager를 배포하려면 mongodb-kubernetes-appdbmongodb-kubernetes-ops-manager 을 사용합니다.

    해당 예제를 복사하여 붙여넣고 <namespace> 값을 네임스페이스를 식별하는 레이블로 바꿉니다.

    helm template mongodb/mongodb-kubernetes \
    --set operator.namespace=<metadata.namespace> \
    --show-only templates/database-roles.yaml | oc apply -f -

Kubernetes Operator용 MongoDB 컨트롤러의 범위를 설정한 후 다음을 수행할 수 있습니다.

이 페이지 평가하기