7.2. Clair v4 の設定


Clair v4 の試用のために、実行中の Clair v2 インスタンスで Red Hat Quay クラスターを立ち上げます。次に、以下の手順を使用してこれと共に Clair v4 を実行します。以下は、AWS クラウドで OpenShift v4.2 以降のクラスターでこれを実行する方法です。

  1. 現在のプロジェクトを Red Hat Quay が実行されているプロジェクトの名前に設定します。以下は例になります。

    $ oc project quay-enterprise
  2. Clair v4 用の Postgres デプロイファイル (例: clairv4-postgres.yaml) を以下のように作成します。

    clairv4-postgres.yaml

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: clairv4-postgres
      namespace: quay-enterprise
      labels:
        quay-component: clairv4-postgres
    spec:
      replicas: 1
      selector:
        matchLabels:
          quay-component: clairv4-postgres
      template:
        metadata:
          labels:
            quay-component: clairv4-postgres
        spec:
          volumes:
            - name: postgres-data
              persistentVolumeClaim:
                claimName: clairv4-postgres
          containers:
            - name: postgres
              image: postgres:11.5
              imagePullPolicy: "IfNotPresent"
              ports:
                - containerPort: 5432
              env:
                - name: POSTGRES_USER
                  value: "postgres"
                - name: POSTGRES_DB
                  value: "clair"
                - name: POSTGRES_PASSWORD
                  value: "postgres"
                - name: PGDATA
                  value: "/etc/postgres/data"
              volumeMounts:
                - name: postgres-data
                  mountPath: "/etc/postgres"
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: clairv4-postgres
      labels:
        quay-component: clairv4-postgres
    spec:
      accessModes:
        - "ReadWriteOnce"
      resources:
        requests:
          storage: "5Gi"
        volumeName: "clairv4-postgres"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: clairv4-postgres
      labels:
        quay-component: clairv4-postgres
    spec:
      type: ClusterIP
      ports:
        - port: 5432
          protocol: TCP
          name: postgres
          targetPort: 5432
      selector:
        quay-component: clairv4-postgres

  3. 以下のように postgres データベースをデプロイします。

    $ oc create -f ./clairv4-postgres.yaml
  4. Clair v4 に使用する Clair の config.yaml ファイルを作成します。例を以下に示します。

    config.yaml

    introspection_addr: :8089
    http_listen_addr: :8080
    log_level: debug
    indexer:
      connstring: host=clairv4-postgres port=5432 dbname=clair user=postgres password=postgres sslmode=disable
      scanlock_retry: 10
      layer_scan_concurrency: 5
      migrations: true
    matcher:
      connstring: host=clairv4-postgres port=5432 dbname=clair user=postgres password=postgres sslmode=disable
      max_conn_pool: 100
      run: ""
      migrations: true
      indexer_addr: clair-indexer
    # tracing and metrics
    trace:
      name: "jaeger"
      probability: 1
      jaeger:
        agent_endpoint: "localhost:6831"
        service_name: "clair"
    metrics:
      name: "prometheus"

  5. Clair の config.yaml からシークレットを作成します。

    $ oc create secret generic clairv4-config-secret --from-file=./config.yaml
  6. Clair v4 デプロイメントファイル (例: clair-combo.yaml) を作成し、必要に応じてこれを変更します。

    clair-combo.yaml

    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        quay-component: clair-combo
      name: clair-combo
    spec:
      replicas: 1
      selector:
        matchLabels:
          quay-component: clair-combo
      template:
        metadata:
          labels:
            quay-component: clair-combo
        spec:
          containers:
            - image: quay.io/redhat/clair:v3.3.4  
    1
    
              imagePullPolicy: IfNotPresent
              name: clair-combo
              env:
                - name: CLAIR_CONF
                  value: /clair/config.yaml
                - name: CLAIR_MODE
                  value: combo
              ports:
                - containerPort: 8080
                  name: clair-http
                  protocol: TCP
                - containerPort: 8089
                  name: clair-intro
                  protocol: TCP
              volumeMounts:
                - mountPath: /clair/
                  name: config
          imagePullSecrets:
            - name: redhat-pull-secret
          restartPolicy: Always
          volumes:
            - name: config
              secret:
                secretName: clairv4-config-secret
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: clairv4 
    2
    
      labels:
        quay-component: clair-combo
    spec:
      ports:
        - name: clair-http
          port: 80
          protocol: TCP
          targetPort: 8080
        - name: clair-introspection
          port: 8089
          protocol: TCP
          targetPort: 8089
      selector:
        quay-component: clair-combo
      type: ClusterIP

    1
    イメージを最新の clair イメージ名とバージョンに変更します。
    2
    Service が clairv4 に設定されると、Clair v4 のスキャナーエンドポイントは、後に http://clairv4 として SECURITY_SCANNER_V4_ENDPOINT の Red Hat Quay config.yaml に入力されます。
  7. 以下のように Clair v4 デプロイメントを作成します。

    $ oc create -f ./clair-combo.yaml
  8. Red Hat Quay 配置の config.yaml ファイルを変更して、最後に以下のエントリーを追加します。

    ...
    FEATURE_SECURITY_SCANNER: true
    SECURITY_SCANNER_V4_ENDPOINT: http://clairv4 
    1
    
    SECURITY_SCANNER_V4_NAMESPACE_WHITELIST: 
    2
    
      - "clairv4-org"
      - "foo-org"
    1
    Clair v4 サービスエンドポイントを特定します。
    2
    Clair v4 スキャンを使用する Red Hat Quay クラスターの namespace (組織およびユーザー) に clair4-org および foo-org を置き換えます。
  9. 変更された config.yaml を、そのファイルを含むシークレットに再デプロイします (例: quay-enterprise-config-secret)。

    $ oc delete secret quay-enterprise-config-secret
    $ oc create secret generic quay-enterprise-config-secret --from-file=./config.yaml
  10. 新しい config.yaml を有効にするには、Red Hat Quay の Pod を再起動する必要があります。quay-app Pod を削除するだけで、更新された設定を持つ Pod がデプロイされます。

この時点で、namespace ホワイトリストで特定される組織内のイメージが Clair v4 によってスキャンされます。

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

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

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

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

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

Legal Notice

Theme

© 2026 Red Hat
トップに戻る