sigs.k8s.io/cluster-api@v1.7.1/bootstrap/kubeadm/controllers/alias.go (about)

     1  /*
     2  Copyright 2021 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package controllers
    18  
    19  import (
    20  	"context"
    21  	"time"
    22  
    23  	ctrl "sigs.k8s.io/controller-runtime"
    24  	"sigs.k8s.io/controller-runtime/pkg/client"
    25  	"sigs.k8s.io/controller-runtime/pkg/controller"
    26  
    27  	kubeadmbootstrapcontrollers "sigs.k8s.io/cluster-api/bootstrap/kubeadm/internal/controllers"
    28  	"sigs.k8s.io/cluster-api/controllers/remote"
    29  )
    30  
    31  // Following types provides access to reconcilers implemented in internal/controllers, thus
    32  // allowing users to provide a single binary "batteries included" with Cluster API and providers of choice.
    33  
    34  const (
    35  	// DefaultTokenTTL is the default TTL used for tokens.
    36  	DefaultTokenTTL = kubeadmbootstrapcontrollers.DefaultTokenTTL
    37  )
    38  
    39  // KubeadmConfigReconciler reconciles a KubeadmConfig object.
    40  type KubeadmConfigReconciler struct {
    41  	Client              client.Client
    42  	SecretCachingClient client.Client
    43  
    44  	Tracker *remote.ClusterCacheTracker
    45  
    46  	// WatchFilterValue is the label value used to filter events prior to reconciliation.
    47  	WatchFilterValue string
    48  
    49  	// TokenTTL is the amount of time a bootstrap token (and therefore a KubeadmConfig) will be valid.
    50  	TokenTTL time.Duration
    51  }
    52  
    53  // SetupWithManager sets up the reconciler with the Manager.
    54  func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
    55  	return (&kubeadmbootstrapcontrollers.KubeadmConfigReconciler{
    56  		Client:              r.Client,
    57  		SecretCachingClient: r.SecretCachingClient,
    58  		Tracker:             r.Tracker,
    59  		WatchFilterValue:    r.WatchFilterValue,
    60  		TokenTTL:            r.TokenTTL,
    61  	}).SetupWithManager(ctx, mgr, options)
    62  }