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