3.5.6.2.2. --inlined フラグでの odo link の使用
odo link コマンドで --inlined フラグを使用すると、これがバインディング情報を挿入するというフラグなしに odo link コマンドと同じ効果があります。ただし、上記の場合は、kubernetes/ ディレクトリーに 2 つのマニフェストファイルがあります。1 つは Postgres サービス用で、もう 1 つは backend コンポーネントとこのサービス間のリンク用です。ただし、-inlined フラグを渡すと、odo は kubernetes/ ディレクトリーの下に YAML マニフェストを保存するファイルを作成せず、devfile.yaml ファイルにインラインで保存します。
これを確認するには、最初に PostgreSQL サービスからコンポーネントをリンク解除します。
$ odo unlink PostgresCluster/hippo
出力例:
✓ Successfully unlinked component "backend" from service "PostgresCluster/hippo"
To apply the changes, please use `odo push`
クラスターでそれらをリンクするには、odo push を実行します。kubernetes/ ディレクトリーを検査すると、1 つのファイルのみが表示されます。
$ ls kubernetes
odo-service-hippo.yaml
次に、--inlined フラグを使用してリンクを作成します。
$ odo link PostgresCluster/hippo --inlined
出力例:
✓ Successfully created link between component "backend" and service "PostgresCluster/hippo"
To apply the link, please use `odo push`
--inlined フラグを省略する手順など、クラスターで作成されるリンクを取得するために odo push を実行する必要があります。odo は設定を devfile.yaml に保存します。このファイルに以下のようなエントリーが表示されます。
kubernetes:
inlined: |
apiVersion: binding.operators.coreos.com/v1alpha1
kind: ServiceBinding
metadata:
creationTimestamp: null
name: backend-postgrescluster-hippo
spec:
application:
group: apps
name: backend-app
resource: deployments
version: v1
bindAsFiles: false
detectBindingResources: true
services:
- group: postgres-operator.crunchydata.com
id: hippo
kind: PostgresCluster
name: hippo
version: v1beta1
status:
secret: ""
name: backend-postgrescluster-hippo
odo unlink PostgresCluster/hippo を実行する場合に、odo はまず devfile.yaml からリンク情報を削除し、後続の odo push はクラスターからリンクを削除するようになりました。