4.16. シークレットをファイルまたは環境変数として Red Hat CodeReady Workspaces コンテナーにマウントする
シークレットは、ユーザー名、パスワード、認証トークン、設定などの機密データを暗号化された形式で保存する OpenShift オブジェクトです。
ユーザーは、機密データが含まれる OpenShift シークレットを Red Hat CodeReady Workspaces コンテナーにマウントできます。
- ファイル
- 環境変数
マウントプロセスでは、標準の OpenShift マウントメカニズムを使用しますが、追加のアノテーションとラベル付けが必要です。
4.16.1. シークレットをファイルとして Red Hat CodeReady Workspaces コンテナーにマウントする
前提条件
- CodeReady Workspaces の実行中のインスタンス。CodeReady Workspaces のインスタンスをインストールするには、CodeReady Workspaces のインストールについて参照してください。
手順
CodeReady Workspaces ワークスペースがデプロイされる OpenShift プロジェクトで新規の OpenShift シークレットを作成します。作成される予定のシークレットのラベルは、ラベルのセットと一致する必要があります。
-
app.kubernetes.io/part-of: che.eclipse.org -
app.kubernetes.io/component: <DEPLOYMENT_NAME>-secret
-
ここで、 <DEPLOYMENT_NAME> は、 postgres、keycloak、devfile-registry、 plugin-registry または codeready のデプロイメントのいずれかになります。
例4.5 たとえば、以下のようになります。
apiVersion: v1
kind: Secret
metadata:
name: custom-certificate
labels:
app.kubernetes.io/part-of: che.eclipse.org
app.kubernetes.io/component: codeready-secret
...アノテーションは、指定されるシークレットがファイルとしてマウントされていることを示す必要があります。アノテーションの値を設定します。
-
che.eclipse.org/mount-as: file: シークレットがファイルとしてマウントされていることを示します。 -
che.eclipse.org/mount-path: <FOO_ENV>: 必要なマウントパスを指定します。
apiVersion: v1
kind: Secret
metadata:
name: custom-certificate
annotations:
che.eclipse.org/mount-path: /custom-certificates
che.eclipse.org/mount-as: file
labels:
...OpenShift シークレットには複数の項目が含まれる可能性があり、その名前はコンテナーにマウントされる必要なファイル名と一致する必要があります。
apiVersion: v1
kind: Secret
metadata:
name: custom-certificate
labels:
app.kubernetes.io/part-of: che.eclipse.org
app.kubernetes.io/component: codeready-secret
annotations:
che.eclipse.org/mount-path: /custom-certificates
che.eclipse.org/mount-as: file
data:
ca.crt: <base64 encoded data content here>
これにより、ca.crt という名前のファイルが CodeReady Workspaces コンテナーの /custom-certificates パスにマウントされます。