0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

karpenter-provider-cluster-apiの実装状況

Last updated at Posted at 2025-04-10

概要

KarpenterのCluster API統合「karpenter-provider-cluster-api」は、Cluster APIを通じたノードの自動スケーリングを可能にするプロジェクトで、現在はPoCの段階です。確認した所、現在の実装では、単一のコントローラーで監視できるワークロードクラスタは1つだけです。

アーキテクチャ

karpenter-provider-cluster-apiは2つのクラスタと連携します:

  1. ワークロードクラスタ - Podが実行される場所
  2. 管理クラスタ - Cluster APIリソースが存在する場所

ソースコードから見た制約の理由

単一のワークロードクラスタ接続

// pkg/operator/operator.go
func buildManagementClusterKubeClient(ctx context.Context, operator *operator.Operator) (client.Client, error) {
    if options.FromContext(ctx).ClusterAPIKubeConfigFile != "" {
        clusterAPIKubeConfig, err := clientcmd.BuildConfigFromFlags("", options.FromContext(ctx).ClusterAPIKubeConfigFile)
        // ...
        return mgmtCluster.GetClient(), nil
    }
    return operator.GetClient(), nil
}

MachineProviderの初期化

// pkg/operator/operator.go
func NewOperator(ctx context.Context, operator *operator.Operator) (context.Context, *Operator) {
    mgmtCluster, err := buildManagementClusterKubeClient(ctx, operator)
    // ...
    machineProvider := machine.NewDefaultProvider(ctx, mgmtCluster)
    machineDeploymentProvider := machinedeployment.NewDefaultProvider(ctx, mgmtCluster)
    // ...
}

MachineProviderとMachineDeploymentProviderはmgmtClusterのClientを使用して初期化されます。これにより、管理クラスタのkubeconfigを使った操作が実現されています。

CloudProviderへのクライアント受け渡し

// cmd/controller/main.go
cloudProvider := clusterapi.NewCloudProvider(ctx, op.GetClient(), op.MachineProvider, op.MachineDeploymentProvider)

CloudProviderは、ワークロードクラスタへのアクセス用にメインのクライアント(op.GetClient())を使い、Cluster APIリソース操作用にMachineProviderとMachineDeploymentProviderを使用します。

影響

複数のワークロードクラスタを管理する場合、クラスタごとに1つのkarpenter-provider-cluster-apiのコントローラーが必要です。10個のクラスタを管理するには、10個のコントローラーが必要になります。

まとめ

karpenter-provider-cluster-apiは現在、1つのインスタンスで1つのワークロードクラスタのみを監視できます。PoC段階における設計選択だと考えられます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?