4.5.2.2. 認証の手動設定

レポート Operator で OAuth を手動で設定するか、または無効にするには、MeteringConfig リソースで spec.tls.enabled: false を設定する必要があります。

警告

これは、レポート Operator、Presto、および Hive 間のすべての TLS および認証も無効にします。これらのリソースは手動で設定する必要があります。

認証を有効にするには、以下のオプションを設定します。認証を有効にすると、レポート Operator Pod が OpenShift 認証プロキシーを Pod のサイドカーコンテナーとして実行するように設定されます。これによりポートが調整され、レポート API が直接公開されず、代わりに認証プロキシーサイドカーコンテナーでプロキシーされます。

  • reporting-operator.spec.authProxy.enabled
  • reporting-operator.spec.authProxy.cookie.createSecret
  • reporting-operator.spec.authProxy.cookie.seed

reporting-operator.spec.authProxy.enabled および reporting-operator.spec.authProxy.cookie.createSecrettrue に設定し、reporting-operator.spec.authProxy.cookie.seed を 32 文字のランダムな文字列に設定する必要があります。

以下のコマンドを使用して、32 文字のランダムな文字列を生成できます。

$ openssl rand -base64 32 | head -c32; echo.
4.5.2.2.1. トークン認証

以下のオプションが true に設定されている場合、ベアラートークンを使用する認証がレポート REST API に対して有効になります。ベアラートークンはサービスアカウントまたはユーザーから送られる場合があります。

  • reporting-operator.spec.authProxy.subjectAccessReview.enabled
  • reporting-operator.spec.authProxy.delegateURLs.enabled

認証が有効にされると、ユーザーまたはサービスアカウントのレポート API をクエリーするために使用されるベアラートークンに、以下のロールのいずれかを使用するアクセスが付与される必要があります。

  • report-exporter
  • reporting-admin
  • reporting-viewer
  • metering-admin
  • metering-viewer

メータリング Operator は、spec.permissions セクションにサブジェクトの一覧を指定して、ロールバインディングを作成し、これらのパーミッションを付与できます。たとえば、以下の advanced-auth.yaml の設定例を参照してください。

apiVersion: metering.openshift.io/v1
kind: MeteringConfig
metadata:
  name: "operator-metering"
spec:
  permissions:
    # anyone in the "metering-admins" group can create, update, delete, etc any
    # metering.openshift.io resources in the namespace.
    # This also grants permissions to get query report results from the reporting REST API.
    meteringAdmins:
    - kind: Group
      name: metering-admins
    # Same as above except read only access and for the metering-viewers group.
    meteringViewers:
    - kind: Group
      name: metering-viewers
    # the default serviceaccount in the namespace "my-custom-ns" can:
    # create, update, delete, etc reports.
    # This also gives permissions query the results from the reporting REST API.
    reportingAdmins:
    - kind: ServiceAccount
      name: default
      namespace: my-custom-ns
    # anyone in the group reporting-readers can get, list, watch reports, and
    # query report results from the reporting REST API.
    reportingViewers:
    - kind: Group
      name: reporting-readers
    # anyone in the group cluster-admins can query report results
    # from the reporting REST API. So can the user bob-from-accounting.
    reportExporters:
    - kind: Group
      name: cluster-admins
    - kind: User
      name: bob-from-accounting

  reporting-operator:
    spec:
      authProxy:
        # htpasswd.data can contain htpasswd file contents for allowing auth
        # using a static list of usernames and their password hashes.
        #
        # username is 'testuser' password is 'password123'
        # generated htpasswdData using: `htpasswd -nb -s testuser password123`
        # htpasswd:
        #   data: |
        #     testuser:{SHA}y/2sYAj5yrQIN4TL0YdPdmGNKpc=
        #
        # change REPLACEME to the output of your htpasswd command
        htpasswd:
          data: |
            REPLACEME

または、get パーミッションを reports/export に付与するルールを持つすべてのロールを使用できます。これは、レポート Operator の namespace の Report リソースの export サブリソースに対する get アクセスです。例: admin および cluster-admin

デフォルトで、レポート Operator およびメータリング Operator サービスアカウントにはどちらにもこれらのパーミッションがあり、それらのトークンを認証に使用することができます。