sigs.k8s.io/cluster-api@v1.6.3/controlplane/kubeadm/api/v1beta1/kubeadmcontrolplanetemplate_types.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 v1beta1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  
    22  	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
    23  	bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
    24  )
    25  
    26  // KubeadmControlPlaneTemplateSpec defines the desired state of KubeadmControlPlaneTemplate.
    27  type KubeadmControlPlaneTemplateSpec struct {
    28  	Template KubeadmControlPlaneTemplateResource `json:"template"`
    29  }
    30  
    31  // +kubebuilder:object:root=true
    32  // +kubebuilder:resource:path=kubeadmcontrolplanetemplates,scope=Namespaced,categories=cluster-api
    33  // +kubebuilder:storageversion
    34  // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KubeadmControlPlaneTemplate"
    35  
    36  // KubeadmControlPlaneTemplate is the Schema for the kubeadmcontrolplanetemplates API.
    37  type KubeadmControlPlaneTemplate struct {
    38  	metav1.TypeMeta   `json:",inline"`
    39  	metav1.ObjectMeta `json:"metadata,omitempty"`
    40  
    41  	Spec KubeadmControlPlaneTemplateSpec `json:"spec,omitempty"`
    42  }
    43  
    44  // +kubebuilder:object:root=true
    45  
    46  // KubeadmControlPlaneTemplateList contains a list of KubeadmControlPlaneTemplate.
    47  type KubeadmControlPlaneTemplateList struct {
    48  	metav1.TypeMeta `json:",inline"`
    49  	metav1.ListMeta `json:"metadata,omitempty"`
    50  	Items           []KubeadmControlPlaneTemplate `json:"items"`
    51  }
    52  
    53  func init() {
    54  	objectTypes = append(objectTypes, &KubeadmControlPlaneTemplate{}, &KubeadmControlPlaneTemplateList{})
    55  }
    56  
    57  // KubeadmControlPlaneTemplateResource describes the data needed to create a KubeadmControlPlane from a template.
    58  type KubeadmControlPlaneTemplateResource struct {
    59  	// Standard object's metadata.
    60  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    61  	// +optional
    62  	ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
    63  
    64  	Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec"`
    65  }
    66  
    67  // KubeadmControlPlaneTemplateResourceSpec defines the desired state of KubeadmControlPlane.
    68  // NOTE: KubeadmControlPlaneTemplateResourceSpec is similar to KubeadmControlPlaneSpec but
    69  // omits Replicas and Version fields. These fields do not make sense on the KubeadmControlPlaneTemplate,
    70  // because they are calculated by the Cluster topology reconciler during reconciliation and thus cannot
    71  // be configured on the KubeadmControlPlaneTemplate.
    72  type KubeadmControlPlaneTemplateResourceSpec struct {
    73  	// MachineTemplate contains information about how machines
    74  	// should be shaped when creating or updating a control plane.
    75  	// +optional
    76  	MachineTemplate *KubeadmControlPlaneTemplateMachineTemplate `json:"machineTemplate,omitempty"`
    77  
    78  	// KubeadmConfigSpec is a KubeadmConfigSpec
    79  	// to use for initializing and joining machines to the control plane.
    80  	KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"`
    81  
    82  	// RolloutBefore is a field to indicate a rollout should be performed
    83  	// if the specified criteria is met.
    84  	//
    85  	// +optional
    86  	RolloutBefore *RolloutBefore `json:"rolloutBefore,omitempty"`
    87  
    88  	// RolloutAfter is a field to indicate a rollout should be performed
    89  	// after the specified time even if no changes have been made to the
    90  	// KubeadmControlPlane.
    91  	//
    92  	// +optional
    93  	RolloutAfter *metav1.Time `json:"rolloutAfter,omitempty"`
    94  
    95  	// The RolloutStrategy to use to replace control plane machines with
    96  	// new ones.
    97  	// +optional
    98  	// +kubebuilder:default={type: "RollingUpdate", rollingUpdate: {maxSurge: 1}}
    99  	RolloutStrategy *RolloutStrategy `json:"rolloutStrategy,omitempty"`
   100  
   101  	// The RemediationStrategy that controls how control plane machine remediation happens.
   102  	// +optional
   103  	RemediationStrategy *RemediationStrategy `json:"remediationStrategy,omitempty"`
   104  }
   105  
   106  // KubeadmControlPlaneTemplateMachineTemplate defines the template for Machines
   107  // in a KubeadmControlPlaneTemplate object.
   108  // NOTE: KubeadmControlPlaneTemplateMachineTemplate is similar to KubeadmControlPlaneMachineTemplate but
   109  // omits ObjectMeta and InfrastructureRef fields. These fields do not make sense on the KubeadmControlPlaneTemplate,
   110  // because they are calculated by the Cluster topology reconciler during reconciliation and thus cannot
   111  // be configured on the KubeadmControlPlaneTemplate.
   112  type KubeadmControlPlaneTemplateMachineTemplate struct {
   113  	// Standard object's metadata.
   114  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   115  	// +optional
   116  	ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
   117  
   118  	// NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane node
   119  	// The default value is 0, meaning that the node can be drained without any time limitations.
   120  	// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
   121  	// +optional
   122  	NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
   123  
   124  	// NodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
   125  	// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
   126  	// +optional
   127  	NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
   128  
   129  	// NodeDeletionTimeout defines how long the machine controller will attempt to delete the Node that the Machine
   130  	// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
   131  	// If no value is provided, the default value for this property of the Machine resource will be used.
   132  	// +optional
   133  	NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"`
   134  }