기본값 구성에서 MongoDB Agent와 백업 데몬은 인터넷을 통해 MongoDB , Inc.에서 MongoDB 설치 아카이브에 액세스 합니다.
원격 모드 MongoDB Ops Manager 에서 실행 MongoDB 를 구성하여 백업 데몬 및 MongoDB Ops Manager managed 리소스가 HTTP 로컬 웹 서버 또는 S3호환 저장 의 엔드포인트로 다운로드 요청을 프록시하는 에서만 설치 아카이브를 다운로드 수 Kubernetes 있습니다. 클러스터 에 배포됩니다.
전제 조건 및 고려 사항
절차
다음 절차에서는 Nginx HTTP 서버 를 Kubernetes 클러스터 에 배포하여 MongoDB 설치 아카이브를 호스팅하다 합니다.
을 네임스페이스 를 기본값 으로 구성합니다.kubectl
아직 실행하지 않았다면 다음 명령을 실행하여 생성한 네임스페이스에서 kubectl
명령을 모두 실행합니다.
참고
다중 Kubernetes 클러스터 MongoDB deployment에서 MongoDB Ops Manager 리소스를 배포하는 경우:
context
을 중앙 클러스터의 이름(예:kubectl config set context "$MDB_CENTRAL_CLUSTER_FULL_NAME"
)으로 설정합니다.--namespace
를 다중 Kubernetes 클러스터 MongoDB 배포에 사용한 것과 동일한 범위 (예:kubectl config --namespace "mongodb"
로 설정합니다.
kubectl config set-context $(kubectl config current-context) --namespace=<metadata.namespace>
Nginx용 ConfigMap 을 생성합니다.
이 튜토리얼의 ConfigMap은 다음과 같이 Nginx를 구성합니다.
Kubernetes cluster의 노드의 포트
80
에서 수신 대기 중인localhost
이라는 이름의 HTTP 서버를 실행하고특정 리소스에 대한 HTTP 요청을 MongoDB Server 및 MongoDB database Database Tools 설치 아카이브를 제공하는 위치로 라우팅합니다.
다음 예제 Nginx ConfigMap을 텍스트 편집기에 붙여넣습니다.
1 2 apiVersion: v1 3 kind: ConfigMap 4 metadata: 5 name: nginx-conf 6 data: 7 nginx.conf: | 8 events {} 9 http { 10 server { 11 server_name localhost; 12 listen 80; 13 location /linux/ { 14 alias /mongodb-ops-manager/mongodb-releases/linux/; 15 } 16 location /tools/ { 17 alias /tools/; 18 } 19 } 20 } 21 ... 이 파일을
.yaml
파일 확장자로 저장합니다.생성한 ConfigMap 파일에서 다음
kubectl
명령을 호출하여 Nginx ConfigMap을 생성합니다.kubectl apply -f <nginix-configmap>.yaml
Kubernetes cluster에 Nginx를 배포합니다.
이 튜토리얼의 Nginx 리소스 구성은 다음과 같습니다.
하나의 Nginx 복제본을 배포합니다.
MongoDB 서버 및 MongoDB 데이터베이스 도구 설치 아카이브를 저장하기 위한 볼륨 마운트를 생성합니다.
명령을 사용하여 Kubernetes 클러스터 에 배포
curl
MongoDB 데이터베이스 리소스에 Nginx가 제공하는 설치 아카이브를 다운로드 init 컨테이너를 정의합니다.
다음 예제 Nginx 리소스 구성을 텍스트 편집기에 붙여넣습니다.
1 2 apiVersion: apps/v1 3 kind: Deployment 4 metadata: 5 name: nginx-deployment 6 spec: 7 replicas: 1 8 selector: 9 matchLabels: 10 app: nginx 11 template: 12 metadata: 13 labels: 14 app: nginx 15 spec: 16 containers: 17 - image: nginx:1.14.2 18 imagePullPolicy: IfNotPresent 19 name: nginx 20 ports: 21 - containerPort: 80 22 volumeMounts: 23 - mountPath: /mongodb-ops-manager/mongodb-releases/linux 24 name: mongodb-versions 25 - mountPath: /tools/db/ 26 name: mongodb-tools 27 - name: nginx-conf 28 mountPath: /etc/nginx/nginx.conf 29 subPath: nginx.conf 30 initContainers: 31 - name: setting-up-rhel-mongodb 32 image: curlimages/curl:latest 33 command: 34 - curl 35 - -L 36 - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz 37 - -o 38 - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz 39 volumeMounts: 40 - name: mongodb-versions 41 mountPath: /mongodb-ops-manager/mongodb-releases/linux 42 - name: setting-up-rhel-mongodb-tools 43 image: curlimages/curl:latest 44 command: 45 - curl 46 - -L 47 - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel80-x86_64-100.6.0.tgz 48 - -o 49 - /tools/db/mongodb-database-tools-rhel80-x86_64-100.6.0.tgz 50 volumeMounts: 51 - name: mongodb-tools 52 mountPath: /tools/db/ 53 restartPolicy: Always 54 terminationGracePeriodSeconds: 30 55 volumes: 56 - name: mongodb-versions 57 emptyDir: {} 58 - name: mongodb-tools 59 emptyDir: {} 60 - configMap: 61 name: nginx-conf 62 name: nginx-conf 63 ... 예제에 강조 표시된 줄을 수정하여 설치하려는 MongoDB Server 버전을 지정합니다.
예를 들어 MongoDB 버전
4.0.2
을(를) 다른 데이터베이스 버전으로 대체하려면 다음 차단을 업데이트합니다.- name: setting-up-rhel-mongodb image: curlimages/curl:latest command: - curl - -L - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz - -o - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz MongoDB Database Tools 버전을 수정하려면 이 블록을 업데이트합니다.
- name: setting-up-rhel-mongodb-tools image: curlimages/curl:latest command: - curl - -L - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel80-x86_64-100.6.0.tgz - -o - /tools/db/mongodb-database-tools-rhel80-x86_64-100.6.0.tgz - 여러 버전을 로드하려면
curl
명령을 추가합니다. Nginx에서 제공하려는 각 버전에 적합한 initContainer에 추가합니다.
예를 들어 MongoDB
6.0.1
을(를) 제공하도록 Nginx를 구성하려면 다음을 수행합니다.- name: setting-up-rhel-mongodb image: curlimages/curl:latest command: - curl - -L - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz - -o - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz
- 여러 버전을 로드하려면
이 파일을
.yaml
파일 확장자로 저장합니다.생성한 Nginx 리소스 파일에서 다음
kubectl
명령을 호출하여 Nginx를 배포합니다.kubectl apply -f <nginix>.yaml
다음 예제 Nginx 리소스 구성을 텍스트 편집기에 붙여넣습니다.
1 2 apiVersion: apps/v1 3 kind: Deployment 4 metadata: 5 name: nginx-deployment 6 spec: 7 replicas: 1 8 selector: 9 matchLabels: 10 app: nginx 11 template: 12 metadata: 13 labels: 14 app: nginx 15 spec: 16 containers: 17 - image: nginx:1.14.2 18 imagePullPolicy: IfNotPresent 19 name: nginx 20 ports: 21 - containerPort: 80 22 volumeMounts: 23 - mountPath: /mongodb-ops-manager/mongodb-releases/linux 24 name: mongodb-versions 25 - mountPath: /tools/db/ 26 name: mongodb-tools 27 - name: nginx-conf 28 mountPath: /etc/nginx/nginx.conf 29 subPath: nginx.conf 30 initContainers: 31 - name: setting-up-rhel-mongodb 32 image: curlimages/curl:latest 33 command: 34 - curl 35 - -L 36 - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel<version>-4.2.0.tgz 37 - -o 38 - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel<version>-4.2.0.tgz 39 volumeMounts: 40 - name: mongodb-versions 41 mountPath: /mongodb-ops-manager/mongodb-releases/linux 42 - name: setting-up-rhel-mongodb-tools 43 image: curlimages/curl:latest 44 command: 45 - curl 46 - -L 47 - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel<version>-x86_64-100.1.0.tgz 48 - -o 49 - /tools/db/mongodb-database-tools-rhel<version>-x86_64-100.1.0.tgz 50 volumeMounts: 51 - name: mongodb-tools 52 mountPath: /tools/db/ 53 restartPolicy: Always 54 terminationGracePeriodSeconds: 30 55 volumes: 56 - name: mongodb-versions 57 emptyDir: {} 58 - name: mongodb-tools 59 emptyDir: {} 60 - configMap: 61 name: nginx-conf 62 name: nginx-conf 63 ... 예제에 강조 표시된 줄을 수정하여 설치하려는 MongoDB Server 버전을 지정합니다.
예를 들어 MongoDB 버전
4.0.2
을(를) 다른 데이터베이스 버전으로 대체하려면 다음 차단을 업데이트합니다.- name: setting-up-rhel-mongodb image: curlimages/curl:latest command: - curl - -L - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel<version>-4.2.0.tgz - -o - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel<version>-4.2.0.tgz MongoDB Database Tools 버전을 수정하려면 이 블록을 업데이트합니다.
- name: setting-up-rhel-mongodb-tools image: curlimages/curl:latest command: - curl - -L - https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel<version>-x86_64-100.1.0.tgz - -o - /tools/db/mongodb-database-tools-rhel<version>-x86_64-100.1.0.tgz 여러 버전을 로드하려면 Nginx에서 제공 하려는 각 버전에 대해 적절한 initContainer에
curl
명령을 추가합니다.예를 들어 MongoDB
6.0.1
을(를) 제공하도록 Nginx를 구성하려면 다음을 수행합니다.- name: setting-up-rhel-mongodb image: curlimages/curl:latest command: - curl - -L - https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz - -o - /mongodb-ops-manager/mongodb-releases/linux/mongodb-linux-x86_64-rhel80-6.0.1.tgz 이 파일을
.yaml
파일 확장자로 저장합니다.생성한 Nginx 리소스 파일에서 다음
oc
명령을 호출하여 Nginx를 배포합니다.oc apply -f <nginix>.yaml
Kubernetes 서비스를 생성하여 cluster의 다른 파드에서 Nginx에 액세스할 수 있도록 합니다.
이 튜토리얼의 서비스는 80
포트를 통해 Kubernetes cluster 내 다른 노드의 트래픽에 Nginx를 노출합니다. 이렇게 하면 Kubernetes 연산자를 사용하여 배포하는 MongoDB 데이터베이스 리소스 포드가 Nginx에서 설치 아카이브를 다운로드할 수 있습니다.
다음 명령을 실행하여 Nginx 배포서버에 서비스를 생성합니다.
다음 예시 서비스를 텍스트 편집기에 붙여넣습니다.
1 2 apiVersion: v1 3 kind: Service 4 metadata: 5 name: nginx-svc 6 labels: 7 app: nginx 8 spec: 9 ports: 10 - port: 80 11 protocol: TCP 12 selector: 13 app: nginx 14 ... 이 파일을
.yaml
파일 확장자로 저장합니다.생성한 서비스 파일에서 다음
kubectl
명령을 호출하여 서비스를 생성합니다.kubectl apply -f <nginix-service>.yaml
이 Ops Manager 리소스의 강조 표시된 필드를 복사하고 업데이트합니다.
강조 표시된 섹션에서는 다음과 같은 Ops Manager 구성 설정을 사용합니다.
automation.versions.source: remote
spec.configuration
에서 원격 모드를 활성화합니다.automation.versions.download.baseUrl
spec.configuration
에 MongoDB 설치 아카이브를 제공하는 HTTP 리소스의 기본 URL을 제공합니다.이 줄을 업데이트하여
<namespace>
를 Kubernetes 연산자로 리소스를 배포할 네임스페이스로 바꾸세요.automation.versions.download.baseUrl.allowOnlyAvailableBuilds: "false"
spec.configuration
빌드에 문제가 없도록 하기 위한 것입니다.
1 2 apiVersion: mongodb.com/v1 3 kind: MongoDBOpsManager 4 metadata: 5 name: ops-manager-localmode 6 spec: 7 replicas: 1 8 version: "6.0.0" 9 adminCredentials: ops-manager-admin-secret 10 configuration: 11 # this enables remote mode in Ops Manager 12 automation.versions.source: remote 13 automation.versions.download.baseUrl: "http://nginx-svc.<namespace>.svc.cluster.local:8080" 14 15 backup: 16 enabled: false 17 18 applicationDatabase: 19 members: 3 20 ...
복사한 예시 섹션을 기존 Ops Manager 리소스에 붙여넣습니다.
원하는 텍스트 편집기를 열고 객체 사양을 리소스 파일의 적절한 위치에 붙여넣습니다.
Ops Manager 인스턴스의 상태를 추적합니다.
Ops Manager 리소스의 상태를 확인하려면 다음 명령을 호출합니다.
kubectl get om -o yaml -w
리소스 배포 상태에 대한 자세한 내용은 Kubernetes 연산자 문제 해결을 참조하세요.
Ops Manager 리소스가 Pending
단계를 완료한 후 이 명령은 다음과 유사한 출력을 반환합니다.
1 status: 2 applicationDatabase: 3 lastTransition: "2020-05-15T16:20:22Z" 4 members: 3 5 phase: Running 6 type: ReplicaSet 7 version: "4.4.5-ubi8" 8 backup: 9 phase: "" 10 opsManager: 11 lastTransition: "2020-05-15T16:20:26Z" 12 phase: Running 13 replicas: 1 14 url: http://ops-manager-localmode-svc.mongodb.svc.cluster.local:8080 15 version: "6.0.0"
리소스의 연결 URL 나타내는 status.opsManager.url
필드의 값을 복사합니다. 이 절차의 뒷부분에서 ConfigMap 을 만들 때 이 값을 사용합니다.
MongoDB database 리소스를 배포합니다.
아직 완료하지 않았다면 다음 전제 조건을 완료하세요.
Ops Manager를 배포한 것과 동일한 네임스페이스에 MongoDB database 리소스 를 배포합니다. 다음을 확인합니다.
리소스의
spec.opsManager.configMapRef.name
를 ConfigMap의metadata.name
와 일치시킵니다.리소스의
spec.credentials
을(를) Ops Manager 프로그래밍 방식 API 키 쌍을 포함하여 생성한 시크릿의 이름과 일치시킵니다.
Operator로 생성한 데이터베이스 리소스 컨테이너에서MongoDB Agent 실행 MongoDB Kubernetes MongoDB Ops Manager 는 인터넷 대신 Nginx를 통해 에서 설치 아카이브를 다운로드 합니다.