AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

cert-manager 統合を設定する

cert-manager simplifies and automates the management of security certificates for Kubernetes. The following procedure describes how to configure cert-manager to generate certificates for MongoDB Kubernetes Operator resources.

オブジェクトを使用してレプリカセットを配置するには、以下を行う必要があります。

注意

Kubernetes の単一クラスター配置でシークレットが保存されないようにするには、 すべてのシークレットシークレットストレージツールに移行 します。複数のKubernetesクラスターでの配置では、HashiCorp Vault などのシークレットストレージツールへのシークレットの保存はサポートされていません。

  • 次のコンポーネントごとに 1 つのTLS証明書を生成します。

    • レプリカセット。 レプリカセットのノードをホストする各 Kubernetes ポッドのSANを証明書に追加することを確認します。

      TLS証明書では、各ポッドのSANは次の形式を使用する必要があります。

      <pod-name>.<metadata.name>-svc.<namespace>.svc.cluster.local

      重要

      If you're using an ACME based service provider such as Let's Encrypt to issue TLS certificates, the provider might prohibit you from adding the Pod's default FQDNs (*.svc.cluster.local) to SANs in the certificate.

      ACMEベースの証明書を使用するには、レプリカセット リソースの証明書を構成する必要があります。 詳細については、手順の 「 ACMEベースのTLS証明書」 に関するステップを参照してください

    • プロジェクトの MongoDB Agent。 MongoDB Agent 証明書については、次の要件を満たしていることを確認してください。

      • TLS証明書のコモン ネームが空ではない。

      • TLS証明書内の組織と組織単位の組み合わせは、レプリカセット ノードのTLS証明書内の組織と組織単位とは異なります。

  • You must have the CA certificate file and name it ca-pem.

  • TLS証明書の署名に使用したキーが必要です。

重要

The Kubernetes Operator uses kubernetes.io/tls secrets to store TLS certificates and private keys for Ops Manager and MongoDB resources. Starting in Kubernetes Operator version 1.17.0, the Kubernetes Operator doesn't support concatenated PEM files stored as Opaque secrets.

オブジェクトを使用してレプリカセットを配置するには、以下を行う必要があります。

注意

Kubernetes の単一クラスター配置でシークレットが保存されないようにするには、 すべてのシークレットシークレットストレージツールに移行 します。複数のKubernetesクラスターでの配置では、HashiCorp Vault などのシークレットストレージツールへのシークレットの保存はサポートされていません。

1

注意

The following steps assume that you have already created a custom CA along with the corresponding tls.key private key and tls.crt signed certificate.

CAデータを保存するためのシークレットを作成します。

apiVersion: v1
kind: Secret
metadata:
name: ca-key-pair
namespace: <namespace>
data:
tls.crt: <your-CA-certificate>
tls.key: <your-CA-private-key>
2

If your Ops Manager TLS certificate is signed by a custom CA, the CA certificate must also contain additional certificates that allow Ops Manager Backup Daemon to download MongoDB binaries from the Internet. To create the TLS certificate(s), create a ConfigMap to hold the CA certificate:

重要

Kubernetes Operator では、ConfigMap 内のMongoDB Ops Manager証明書の名前が mms-ca.crt である必要があります。

  1. Obtain the entire TLS certificate chain for Ops Manager from downloads.mongodb.com. The following openssl command outputs the certificate in the chain to your current working directory, in .crt format:

    openssl s_client -showcerts -verify 2 \
    -connect downloads.mongodb.com:443 -servername downloads.mongodb.com < /dev/null \
    | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; out="cert"a".crt"; print >out}'
  2. Concatenate your CA's certificate file for Ops Manager with the entire TLS certificate chain from downloads.mongodb.com that you obtained in the previous step:

    cat <custom_ca_cert.pem> cert2.crt cert3.crt cert4.crt >> mms-ca.crt

    注意

    • プレースホルダー <custom_ca_cert.pem> を カスタム CA 証明書 PEMファイルに置き換えます。

    • MongoDBのサーバー証明書は含めることができないため、cert1.crtファイルを含めないでください。

  3. ConfigMap を 作成するMongoDB Ops Manager の場合

    kubectl create configmap om-http-cert-ca --from-file="mms-ca.crt"
3
  1. CA シークレットを参照する CA 発行者を作成します。

    apiVersion: cert-manager.io/v1
    kind: Issuer
    metadata:
    name: ca-issuer
    namespace: <namespace>
    spec:
    ca:
    secretName: ca-key-pair
  2. 発行者が準備できていることを確認します。

    kubectl get issuer ca-issuer

    出力のREADYフィールドの値はTrueである必要があります。

4

Create a ConfigMap containing your CA. It must have two fields, ca-pem and mms-ca.crt, both pointing to your CA certificate. Replace <CA-certificate> with the path to your CA certificate.

kubectl create cm ca-issuer --from-file=ca-pem=<CA-certificate> \
--from-file=mms-ca.crt=<CA-certificate>
5

生成された証明書でMongoDBリソースを保護するには、リソース自体とMongoDB Agentの両方の証明書を作成する必要があります。

  1. MongoDB リソース証明書を作成します。 次の例では、3 つのノードを含むmy-replica-setという名前のレプリカセットが想定されています。

    注意

    spec.issuerRef.nameパラメータは過去に作成されたCA ConfigMap を参照します。

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
    name: my-replica-set-certificate
    namespace: mongodb
    spec:
    dnsNames:
    - my-replica-set-0
    - my-replica-set-0.my-replica-set-svc.mongodb.svc.cluster.local
    - my-replica-set-1
    - my-replica-set-1.my-replica-set-svc.mongodb.svc.cluster.local
    - my-replica-set-2
    - my-replica-set-2.my-replica-set-svc.mongodb.svc.cluster.local
    duration: 240h0m0s
    issuerRef:
    name: ca-issuer
    renewBefore: 120h0m0s
    secretName: mdb-my-replica-set-cert
    usages:
    - server auth
    - client auth

    シャーディングされたクラスターの場合、 Atlas App Services は 1 つの証明書を作成する必要があります。シャーディングされたクラスターの構成の詳細については、シャードクラスタの配置 を参照してください。

  2. MongoDB Agent証明書を作成します。

    注意

    spec.issuerRef.nameパラメータは過去に作成されたCA ConfigMap を参照します。

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
    name: agent-certs
    namespace: mongodb
    spec:
    commonName: automation
    dnsNames:
    - automation
    duration: 240h0m0s
    issuerRef:
    name: ca-issuer
    renewBefore: 120h0m0s
    secretName: mdb-my-replica-set-agent-certs
    usages:
    - digital signature
    - key encipherment
    - client auth
    subject:
    countries:
    - US
    localities:
    - NY
    organizationalUnits:
    - a-1635241837-m5yb81lfnrz
    organizations:
    - cluster.local-agent
    provinces:
    - NY
  3. MongoDB リソースを作成します。

    注意

    spec.security.tls.caパラメータを指定しない場合、デフォルトは{replica-set}-caになります。

    apiVersion: mongodb.com/v1
    kind: MongoDB
    metadata:
    name: my-replica-set
    namespace: mongodb
    spec:
    type: ReplicaSet
    members: 3
    version: 8.0.0
    opsManager:
    configMapRef:
    name: my-project
    credentials: my-credentials
    security:
    certsSecretPrefix: mdb
    authentication:
    enabled: true
    modes:
    - X509
    tls:
    ca: ca-issuer
    enabled: true
6

MongoDB Ops Manager リソースを保護するには、まず MongoDB Ops Manager と AppDB の証明書を作成し、次に MongoDB Ops Manager リソースを作成する必要があります。

  1. MongoDB Ops Manager 証明書を作成します。

    注意

    spec.issuerRef.nameパラメータは過去に作成されたCA ConfigMap を参照します。

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
    name: cert-for-ops-manager
    namespace: mongodb
    spec:
    dnsNames:
    - om-with-https-svc.mongodb.svc.cluster.local
    duration: 240h0m0s
    issuerRef:
    name: ca-issuer
    renewBefore: 120h0m0s
    secretName: mdb-om-with-https-cert
    usages:
    - server auth
    - client auth
  2. AppDB 証明書を作成します。

    注意

    spec.issuerRef.nameパラメータは過去に作成されたCA ConfigMap を参照します。

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
    name: appdb-om-with-https-db-cert
    namespace: mongodb
    spec:
    dnsNames:
    - om-with-https-db-0
    - om-with-https-db-0.om-with-https-db-svc.mongodb.svc.cluster.local
    - om-with-https-db-1
    - om-with-https-db-1.om-with-https-db-svc.mongodb.svc.cluster.local
    - om-with-https-db-2
    - om-with-https-db-2.om-with-https-db-svc.mongodb.svc.cluster.local
    duration: 240h0m0s
    issuerRef:
    name: ca-issuer
    renewBefore: 120h0m0s
    secretName: appdb-om-with-https-db-cert
    usages:
    - server auth
    - client auth
  3. MongoDB Ops Managerリソースを作成します。

    apiVersion: mongodb.com/v1
    kind: MongoDBOpsManager
    metadata:
    name: om-with-https
    namespace: mongodb
    spec:
    adminCredentials: ops-manager-admin-secret
    version: "8.0.0"
    applicationDatabase:
    members: 3
    security:
    certsSecretPrefix: appdb
    tls:
    ca: ca-issuer
    version: 8.0.0-ubi8
    replicas: 1
    security:
    certsSecretPrefix: mdb
    tls:
    ca: ca-issuer

証明書マネージャーは、次の状況で証明書を更新します。

  • 証明書は、spec.duration spec.renewBeforeフィールドと フィールドに従って期限切れになります。

  • 証明書を保持しているシークレットを削除します。 この場合、cert-manager は証明書カスタム リソースの構成に従ってシークレットを再作成します。

  • 証明書カスタム リソースの構成を変更します。 この場合、証明書マネージャーは、構成に対する変更を検出するときに、証明書を含むシークレットを再作成します。