10.8.5. 手動証明書管理による SPIRE フェデレーションの使用


SPIRE フェデレーションは、cert-manager やその他の証明書プロバイダーを使用して、カスタム証明書管理と組み合わせて使用できます。このアプローチは、証明書の発行管理、内部認証局 (CA) のサポート、または既存の証明書管理インフラストラクチャーとの統合を必要とする組織に柔軟性を提供します。

前提条件

  • フェデレーションに参加するすべてのクラスターに、ゼロトラスト Workload Identity マネージャーをインストールしました。
  • OpenShift CLI (oc) がインストールされている。
  • 参加しているすべてのクラスターに、cluster-admin 特権が存在します。
  • cert-manager Operator for Red Hat OpenShift がインストールされている。詳細は、cert-manager Operator for Red Hat OpenShift を参照してください。
  • 証明書の検証のため、フェデレーションのエンドポイントは一般に公開されている必要があります。
  • すべての連合クラスター間でネットワーク接続が確立されています。

手順

  1. 外部管理証明書を使用するクラスターに、cert-manager Operator をインストールしてください。

    名前空間を作成し、オペレーターをインストールします。

    apiVersion: v1
    kind: Namespace
    metadata:
      name: cert-manager-operator
    ---
    apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      name: openshift-cert-manager-operator
      namespace: cert-manager-operator
    spec:
      upgradeStrategy: Default
    ---
    apiVersion: operators.coreos.com/stable-v1
    kind: Subscription
    metadata:
      name: openshift-cert-manager-operator
      namespace: cert-manager-operator
    spec:
      source: redhat-operators
      sourceNamespace: openshift-marketplace
      name: openshift-cert-manager-operator
      channel: stable-v1
  2. 以下のコマンドを実行して、cert-manager のインストールを適用してください。

    $ oc apply -f cert-manager-install.yaml
  3. 以下のコマンドを入力して、cert-manager Operator のステータスを確認してください。

    $ oc get pods -n cert-manager

    すべての cert-managerPod は 実行 状態になっている必要があります。

  4. 証明書発行のための発行者を作成します。

    Let’s Encrypt の HTTP-01 チャレンジの場合:

    apiVersion: cert-manager.io/v1
    kind: Issuer
    metadata:
      name: letsencrypt-http01
      namespace: zero-trust-workload-identity-manager
    spec:
      acme:
        server: https://acme-v02.api.letsencrypt.org/directory
        privateKeySecretRef:
          name: letsencrypt-account-key
        solvers:
          - http01:
              ingress:
                ingressClassName: openshift-default

    または、内部 CA の場合:

    apiVersion: cert-manager.io/v1
    kind: Issuer
    metadata:
      name: internal-ca
      namespace: zero-trust-workload-identity-manager
    spec:
      ca:
        secretName: internal-ca-key-pair
  5. 以下のコマンドを実行して、発行者を適用します。

    $ oc apply -f issuer.yaml
  6. フェデレーションエンドポイントのドメイン名を特定します。

    managedRoutetrue に設定されている場合、フェデレーションルートは予測可能な命名パターンに従います。以下のコマンドを実行して、クラスターのアプリケーションドメインを取得します。

    $ CLUSTER_DOMAIN=$(oc get ingresses.config/cluster -o jsonpath='{.spec.domain}')
    $ FEDERATION_DOMAIN="federation.${CLUSTER_DOMAIN}"
    $ echo "Federation domain will be: $FEDERATION_DOMAIN"

    出力例

    Federation domain will be: federation.apps.cluster1.example.com

    注記

    後続の手順で SpireServer の 設定を適用する際に managedRoutetrue に設定すると、フェデレーションルートが自動的に作成されます。ルート名は spire-server-federation で、ホスト名は federation.<cluster- アプリケーション s-domain> です。

  7. TLS 証明書を要求するための証明書リソースを作成します。

    前の手順で決定したフェデレーションドメインを使用します。

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
      name: spire-server-federation-tls
      namespace: zero-trust-workload-identity-manager
    spec:
      secretName: spire-server-federation-tls
      duration: 2160h
      renewBefore: 360h
      commonName: federation.apps.cluster1.example.com
      dnsNames:
        - federation.apps.cluster1.example.com
      usages:
        - server auth
        - digital signature
        - key encipherment
      issuerRef:
        kind: Issuer
        name: letsencrypt-http01
    • secretName フィールドは、SpireServer の externalSecretRef の 値と一致している必要があります。
    • 有効 期間 欄には、証明書の有効期間が表示されます。証明書の有効期間は 90 日間です。
    • renewBefore フィールドは、証明書の有効期限が切れる前に更新する必要がある日数を示します。証明書の有効期限の 15 日前までに更新してください。
    • commonName フィールドは、前の手順で取得した実際のフェデレーションドメインに置き換える必要があります。
    • dnsNames フィールドは、commonName と作成された実際のルート ホスト名 と一致している必要があります。
    • 名前 欄には、以前に作成した発行者を参照する必要があります。
  8. 以下のコマンドを実行して、証明書リソースを適用します。

    $ oc apply -f certificate.yaml
  9. 以下のコマンドを実行して、証明書の発行状況を監視してください。

    $ oc get certificate spire-server-federation-tls \
        -n zero-trust-workload-identity-manager -w

    準備完了時の出力例

    NAME                            READY   SECRET                          AGE
    spire-server-federation-tls     True    spire-server-federation-tls     2m

  10. OpenShift Ingress Router が証明書シークレットにアクセスできるように、RBAC 権限を作成します。

    以下のコマンドを実行してロールを作成します。

    $ oc create role secret-reader \
        --verb=get,list,watch \
        --resource=secrets \
        --resource-name=spire-server-federation-tls \
        -n zero-trust-workload-identity-manager

    以下のコマンドを実行して、ロールバインディング を作成します。

    $ oc create rolebinding secret-reader-binding \
        --role=secret-reader \
        --serviceaccount=openshift-ingress:router \
        -n zero-trust-workload-identity-manager
  11. SpireServer の カスタムリソースを設定して、証明書の管理を手動で行うようにします。

    証明書の準備ができたので、SpireServer がそれを参照するように設定してください。

    apiVersion: operator.openshift.io/v1alpha1
    kind: SpireServer
    metadata:
      name: cluster
    spec:
      trustDomain: cluster1.example.com
      federation:
        bundleEndpoint:
          profile: https_web
          refreshHint: 300
          httpsWeb:
            servingCert:
              fileSyncInterval: 86400
              externalSecretRef: spire-server-federation-tls
        managedRoute: "true"
    • プロファイル フィールドでは、証明書ベースの認証のために https_web プロファイルを使用する必要があります。
    • fileSyncInterval フィールドは、24 時間 (86400 秒) ごとに証明書の更新を確認します。範囲:3600-7776000 秒。
    • externalSecretRef フィールドは、TLS 証明書と秘密鍵を含むシークレットの名前です。前の手順で作成した証明書の秘密鍵と一致している必要があります。
  12. 以下のコマンドを実行して設定を適用します。

    $ oc apply -f spireserver.yaml
  13. SPIRE サーバーの準備が整うまでお待ちください。

    $ oc get spireserver cluster -n zero-trust-workload-identity-manager -w

    ステータスが 準備完了 と表示されるまでお待ちください。

  14. 以下のコマンドを実行して、フェデレーションルートが作成されたことを確認してください。

    $ oc get route spire-server-federation -n zero-trust-workload-identity-manager

    出力例

    NAME                      HOST/PORT                                  PATH   SERVICES        PORT    TERMINATION
    spire-server-federation   federation.apps.cluster1.example.com              spire-server    8443    reencrypt

    ルートホスト名が証明書で使用されているドメイン名と一致していることを確認してください。

  15. 以下のコマンドを実行して、フェデレーションエンドポイントにアクセスできることを確認してください。

    $ curl https://$(oc get route spire-server-federation \
        -n zero-trust-workload-identity-manager \
        -o jsonpath='{.spec.host}')

    トラストバンドルを含む JSON レスポンスが返されるはずです。

  16. 連携したい各フェデレーションエンドポイントからトラストバンドルを取得します。

    各リモートクラスターについて、以下のコマンドを実行してトラストバンドルを取得します。

    $ curl https://federation.apps.cluster1.example.com > cluster1-bundle.json
    $ curl https://federation.apps.cluster2.example.com > cluster2-bundle.json

    トラストバンドルは JSON Web Key Set (JWKS) 形式です。

    トラストバンドルの例

    {
      "keys": [
        {
          "use": "x509-svid",
          "kty": "RSA",
          "n": "xGOzB...",
          "e": "AQAB",
          "x5c": ["MIIC..."]
        }
      ],
      "spiffe_sequence": 1,
      "refresh_hint": 300
    }

  17. フェデレーションを行う各リモート信頼ドメインごとに ClusterFederatedTrustDomain リソースを作成します。

    apiVersion: spire.spiffe.io/v1alpha1
    kind: ClusterFederatedTrustDomain
    metadata:
      name: cluster1-federation
    spec:
      trustDomain: cluster1.example.com
      bundleEndpointURL: https://federation.apps.cluster1.example.com
      bundleEndpointProfile:
        type: https_web
      className: zero-trust-workload-identity-manager-spire
      trustDomainBundle: |
        {
          "keys": [
            {
              "use": "x509-svid",
              "kty": "RSA",
              "n": "xGOzB...",
              "e": "AQAB",
              "x5c": ["MIIC..."]
            }
          ],
          "spiffe_sequence": 1
        }
    ---
    apiVersion: spire.spiffe.io/v1alpha1
    kind: ClusterFederatedTrustDomain
    metadata:
      name: cluster2-federation
    spec:
      trustDomain: cluster2.example.com
      bundleEndpointURL: https://federation.apps.cluster2.example.com
      bundleEndpointProfile:
        type: https_web
      className: zero-trust-workload-identity-manager-spire
      trustDomainBundle: |
        {
          "keys": [...],
          "spiffe_sequence": 1
        }
    • trustDomainBundle フィールドには、前の手順で取得した完全なトラストバンドル JSON が含まれています。
    • spec.className フィールドには、CR を監視する対象となるクラスの名前が含まれます。Spire-controller-manager は、spec.classNameが zero-trust-workload- アイデンティティー -manager-spire に設定されている場合にのみリソースを監視します。
  18. 以下のコマンドを実行して、ClusterFederatedTrustDomain リソースを適用します。

    $ oc apply -f clusterfederatedtrustdomains.yaml
  19. SpireServer リソースを更新して、federatesWith 設定を追加します。

    apiVersion: operator.openshift.io/v1alpha1
    kind: SpireServer
    metadata:
      name: cluster
    spec:
      trustDomain: cluster3.example.com
      federation:
        bundleEndpoint:
          profile: https_web
          refreshHint: 300
          httpsWeb:
            servingCert:
              fileSyncInterval: 86400
              externalSecretRef: spire-server-federation-tls
        federatesWith:
          - trustDomain: cluster1.example.com
            bundleEndpointUrl: https://federation.apps.cluster1.example.com
            bundleEndpointProfile: https_web
    
          - trustDomain: cluster2.example.com
            bundleEndpointUrl: https://federation.apps.cluster2.example.com
            bundleEndpointProfile: https_web
        managedRoute: "true"
    • federatesWith フィールドには、このクラスターがフェデレーションを行うべきすべてのリモート信頼ドメインがリスト表示されます。
  20. 以下のコマンドを実行して、更新された設定を適用してください。

    $ oc apply -f spireserver.yaml
  21. 連盟に参加する各クラスターで手順 1-15 を繰り返し、以下の点を確認してください。

    • 各クラスターには cert-manager がインストールされ、設定されています。
    • SpireServer 設定を適用する前に、各クラスターには独自の証明書が作成され、準備されています。
    • 各クラスターには、イングレスルーター用の RBAC が設定されています。
    • 各クラスターは、フェデレーションを行う他のすべてのクラスターに対して ClusterFederatedTrustDomain リソースを持つ。
    • 各クラスターの SpireServer には、フェデレートウィズの リストがすべて含まれています。

検証

  1. 以下のコマンドを実行して、証明書が正常に発行されたことを確認してください。

    $ oc get certificate spire-server-federation-tls \
        -n zero-trust-workload-identity-manager

    出力例

    NAME                            READY   SECRET                          AGE
    spire-server-federation-tls     True    spire-server-federation-tls     5m

  2. 以下のコマンドを実行して、証明書の詳細と有効期限を確認してください。

    $ oc get secret spire-server-federation-tls \
        -n zero-trust-workload-identity-manager \
        -o jsonpath='{.data.tls\.crt}' | base64 -d | openssl x509 -noout -dates

    出力例

    notBefore=Dec 16 10:00:00 2025 GMT
    notAfter=Mar 16 10:00:00 2026 GMT

  3. 以下のコマンドを実行して、RBAC 権限が正しく設定されていることを確認してください。

    $ oc get role,rolebinding -n zero-trust-workload-identity-manager \
        | grep secret-reader

    出力例

    role.rbac.authorization.k8s.io/secret-reader
    rolebinding.rbac.authorization.k8s.io/secret-reader-binding

    以下のコマンドを実行して、RoleBinding が正しい ServiceAccount を参照していることを確認してください。

    $ oc describe rolebinding secret-reader-binding \
        -n zero-trust-workload-identity-manager

    出力例

    Name:         secret-reader-binding
    Namespace:    zero-trust-workload-identity-manager
    Role:
      Kind:  Role
      Name:  secret-reader
    Subjects:
      Kind            Name    Namespace
      ----            ----    ---------
      ServiceAccount  router  openshift-ingress

  4. 以下のコマンドを実行して、ClusterFederatedTrustDomain リソースが作成されていることを確認してください。

    $ oc get clusterfederatedtrustdomains

    出力例

    NAME                  TRUST DOMAIN           ENDPOINT URL                                      AGE
    cluster1-federation   cluster1.example.com   https://federation.apps.cluster1.example.com     5m
    cluster2-federation   cluster2.example.com   https://federation.apps.cluster2.example.com     5m

  5. 次のコマンドを実行して、ClusterFederatedTrustDomain のステータスを確認し、バンドルの同期が正しく機能していることを確認します。

    $ oc describe clusterfederatedtrustdomain cluster1-federation

    トラストバンドルが同期されたことを示す、正常なステータス条件を探してください。

  6. フェデレーションエンドポイントにアクセス可能であり、正しい証明書が使用されていることを確認するには、次のコマンドを実行します。

    $ curl -v https://$(oc get route spire-server-federation \
        -n zero-trust-workload-identity-manager \
        -o jsonpath='{.spec.host}')

    出力結果で、表示されている証明書が、設定済みの認証局 (Let’s Encrypt または内部認証局) によって発行されたものであることを確認してください。

  7. 以下のコマンドを実行して、SPIRE サーバーのログを確認してください。

    • フェデレーションはリモートの信頼ドメインと連携して有効です。
    • トラストバンドルが同期されています
    • バンドルエンドポイントは正しく動作しています

      $ oc logs -n zero-trust-workload-identity-manager \
          statefulset/spire-server -c spire-server --tail=100

      フェデレーションバンドルの同期が成功したことを示すログメッセージを探してください。

  8. 以下のコマンドを実行して、すべての SPIRE コンポーネントが実行されていることを確認してください。

    $ oc get pods -n zero-trust-workload-identity-manager

    出力例

    NAME                                    READY   STATUS    RESTARTS   AGE
    spire-agent-abc123                      1/1     Running   0          10m
    spire-server-0                          2/2     Running   0          10m

  9. オプション: 異なるクラスターに SPIFFE アイデンティティーを持つワークロードをデプロイし、フェデレーション信頼を使用して相互に認証できることを確認することで、クラスター間ワークロード認証をテストします。
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る