4.4.2. ラベルまたは式によるカタログの選択
クラスターカタログのカスタムリソース (CR) 内のラベルを使用すると、カタログにメタデータを追加できます。その後、割り当てられたラベルを指定するか、クラスター拡張機能の CR で式を使用して、カタログ選択をフィルタリングできます。
次のクラスターカタログ CR では、値が true の example.com/support ラベルを catalog-a クラスターカタログに追加します。
ラベルを使用したクラスターカタログ CR の例
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: catalog-a
labels:
example.com/support: "true"
spec:
source:
type: Image
image:
ref: quay.io/example/content-management-a:latest
次のクラスター拡張機能 CR では、matchLabels セレクターを使用して、example.com/support ラベルと true の値を持つカタログを選択します。
matchLabels セレクターを使用したクラスター拡張機能 CR の例
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <example_extension>
spec:
namespace: <example_namespace>
serviceAccount:
name: <example_extension>-installer
source:
sourceType: Catalog
catalog:
packageName: <example_extension>-operator
selector:
matchLabels:
example.com/support: "true"
matchExpressions フィールドを使用すると、ラベルに対してより複雑なフィルタリングを実行できます。次のクラスター拡張機能 CR では、example.com/support ラベルと production または supported という値を持つカタログを選択します。
matchExpression セレクターを使用したクラスター拡張機能 CR の例
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <example_extension>
spec:
namespace: <example_namespace>
serviceAccount:
name: <example_extension>-installer
source:
sourceType: Catalog
catalog:
packageName: <example_extension>-operator
selector:
matchExpressions:
- key: example.com/support
operator: In
values:
- "production"
- "supported"
matchLabels フィールドと matchExpressions フィールドの両方を使用する場合、カタログが選択されるには、指定されたすべての条件を満たしている必要があります。