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
パスにマウントされます。