はじめに
Open Cluster Management (OCM) がClusterProfile APIに対応しているという情報を見かけたので、実際に動作を確認してみました。
環境セットアップ
OCMの開発環境セットアップガイドに従って環境を構築しました。
このガイドに従うことで、ローカルにOCMのハブクラスタと複数のマネージドクラスタを簡単に立ち上げることができます。
ClusterProfile機能の有効化
ClusterProfile機能はfeature gateで制御されているため、ClusterManagerリソースで明示的に有効化する必要があります。
apiVersion: operator.open-cluster-management.io/v1
kind: ClusterManager
metadata:
name: cluster-manager
spec:
registrationConfiguration:
featureGates:
- feature: ClusterProfile
mode: Enable
この設定を適用すると、既存のManagedClusterが自動的にClusterProfileリソースとして同期されます。
確認結果
feature gateを有効化した後、ClusterProfileリソースを確認すると以下のような結果が得られました。
kubectl get clusterprofile -n open-cluster-management
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ClusterProfile
metadata:
name: cluster1
namespace: open-cluster-management
labels:
multicluster.x-k8s.io/clusterset: ""
x-k8s.io/cluster-manager: open-cluster-management
spec:
clusterManager:
name: open-cluster-management
displayName: cluster1
status:
conditions:
- type: ControlPlaneHealthy
status: "True"
reason: ManagedClusterAvailable
message: Managed cluster is available
- type: Joined
status: "True"
reason: ManagedClusterJoined
message: Managed cluster joined
version:
kubernetes: v1.34.0
ポイント
- ManagedClusterの状態がClusterProfileの
status.conditions
に適切にマッピングされている -
ControlPlaneHealthy
とJoined
という2つのconditionでクラスタの状態を表現 - Kubernetesバージョン情報も同期されている
-
multicluster.x-k8s.io/clusterset
ラベルが付与されている(ClusterSet識別用)
元のManagedCluster
参考までに、元のManagedClusterリソースには以下の情報が含まれています。
- クラスタのcapacity/allocatable情報
- 詳細なconditions (HubAcceptedManagedCluster, ManagedClusterJoined, ManagedClusterConditionAvailable, ManagedClusterConditionClockSynced)
- API Serverへの接続情報 (caBundle, url)
ClusterProfileはこれらの情報から必要な部分を抽出し、よりシンプルなインターフェースでクラスタの状態を提供しています。
まとめ
OCMはClusterProfile APIをサポートしており、既存のManagedClusterをClusterProfileとして公開できることが確認できました。