12.5.5. OLM 管理の Operator を使用したスコアカードの実行
スコアカードは ClusterServiceVersion (CSV) を使用して実行でき、クラスター対応および SDK 以外の Operator をテストする方法を提供します。
手順
スコアカードでは、Operator のログを読み取るために、Operator の
Deployment
Pod にプロキシーコンテナーが必要になります。OLM で Operator をデプロイする 前 に、CSV の変更および 1 つの追加オブジェクトの作成が必要になります。この手順は、bash 関数を使用して、手動または自動で実行できます。以下の方法のいずれかを選択します。
手動の方法:
ローカル kubeconfig を含むプロキシーサーバーシークレットを作成します。
スコアカードプロキシーの namespace を使用した所有者参照を使用してユーザー名を生成します。
$ echo '{"apiVersion":"","kind":"","name":"scorecard","uid":"","Namespace":"'<namespace>'"}' | base64 -w 0 1
- 1
<namespace>
を Operator がデプロイに使用する namespace に置き換えます。
以下のテンプレートを使用して
Config
マニフェストscorecard-config.yaml
を作成し、<username>
を直前の手順で生成される base64 ユーザー名に置き換えます。apiVersion: v1 kind: Config clusters: - cluster: insecure-skip-tls-verify: true server: http://<username>@localhost:8889 name: proxy-server contexts: - context: cluster: proxy-server user: admin/proxy-server name: <namespace>/proxy-server current-context: <namespace>/proxy-server preferences: {} users: - name: admin/proxy-server user: username: <username> password: unused
Config
を base64 としてエンコードします。$ cat scorecard-config.yaml | base64 -w 0
Secret
マニフェストの-secret.yaml
を作成します。apiVersion: v1 kind: Secret metadata: name: scorecard-kubeconfig namespace: <namespace> 1 data: kubeconfig: <kubeconfig_base64> 2
シークレットを適用します。
$ oc apply -f scorecard-secret.yaml
Secret
を参照するボリュームを Operator の Deployment に挿入します。spec: install: spec: deployments: - name: memcached-operator spec: ... template: ... spec: containers: ... volumes: - name: scorecard-kubeconfig 1 secret: secretName: scorecard-kubeconfig items: - key: kubeconfig path: config
- 1
- スコアカードの
kubeconfig
ボリューム。
ボリュームマウントおよび
KUBECONFIG
環境変数を Operator の Deployment の各コンテナーに挿入します。spec: install: spec: deployments: - name: memcached-operator spec: ... template: ... spec: containers: - name: container1 ... volumeMounts: - name: scorecard-kubeconfig 1 mountPath: /scorecard-secret env: - name: KUBECONFIG 2 value: /scorecard-secret/config - name: container2 3 ...
スコアカードプロキシーコンテナーを Operator の Deployment に挿入します。
spec: install: spec: deployments: - name: memcached-operator spec: ... template: ... spec: containers: ... - name: scorecard-proxy 1 command: - scorecard-proxy env: - name: WATCH_NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace image: quay.io/operator-framework/scorecard-proxy:master imagePullPolicy: Always ports: - name: proxy containerPort: 8889
- 1
- スコアカードプロキシーコンテナー。
自動的な方法:
community-operators
リポジトリーには、直前の手順を実行できるいくつかの bash 関数が含まれます。$ curl -Lo csv-manifest-modifiers.sh \ https://raw.githubusercontent.com/operator-framework/community-operators/master/scripts/lib/file $ . ./csv-manifest-modifiers.sh $ create_kubeconfig_secret_file scorecard-secret.yaml "<namespace>" 1 $ oc apply -f scorecard-secret.yaml $ insert_kubeconfig_volume "<csv_file>" 2 $ insert_kubeconfig_secret_mount "<csv_file>" $ insert_proxy_container "<csv_file>" "quay.io/operator-framework/scorecard-proxy:master"
- プロキシーコンテナーの挿入後に、Operator SDK の使用を開始するの手順に従い、CSV および CRD をバンドルし、Operator を OLM にデプロイします。
-
Operator が OLM にデプロイされた後に、
.osdk-scorecard.yaml
設定ファイルを Operator プロジェクトに定義し、csv-path: <csv_manifest_path>
およびolm-deployed
オプションの両方が設定されていることを確認します。 csv-path: <csv_manifest_path>
およびolm-deployed
オプションの両方をスコアカード設定ファイルに設定した状態でスコアカードを実行します。$ operator-sdk scorecard