sigs.k8s.io/cluster-api-provider-azure@v1.14.3/api/v1beta1/azurecluster_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  	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
    22  )
    23  
    24  const (
    25  	// ClusterFinalizer allows ReconcileAzureCluster to clean up Azure resources associated with AzureCluster before
    26  	// removing it from the apiserver.
    27  	ClusterFinalizer = "azurecluster.infrastructure.cluster.x-k8s.io"
    28  
    29  	// ClusterLabelNamespace indicates the namespace of the cluster.
    30  	ClusterLabelNamespace = "azurecluster.infrastructure.cluster.x-k8s.io/cluster-namespace"
    31  )
    32  
    33  // AzureClusterSpec defines the desired state of AzureCluster.
    34  type AzureClusterSpec struct {
    35  	AzureClusterClassSpec `json:",inline"`
    36  
    37  	// NetworkSpec encapsulates all things related to Azure network.
    38  	// +optional
    39  	NetworkSpec NetworkSpec `json:"networkSpec,omitempty"`
    40  
    41  	// +optional
    42  	ResourceGroup string `json:"resourceGroup,omitempty"`
    43  
    44  	// BastionSpec encapsulates all things related to the Bastions in the cluster.
    45  	// +optional
    46  	BastionSpec BastionSpec `json:"bastionSpec,omitempty"`
    47  
    48  	// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. It is not recommended to set
    49  	// this when creating an AzureCluster as CAPZ will set this for you. However, if it is set, CAPZ will not change it.
    50  	// +optional
    51  	ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
    52  }
    53  
    54  // AzureClusterStatus defines the observed state of AzureCluster.
    55  type AzureClusterStatus struct {
    56  	// FailureDomains specifies the list of unique failure domains for the location/region of the cluster.
    57  	// A FailureDomain maps to Availability Zone with an Azure Region (if the region support them). An
    58  	// Availability Zone is a separate data center within a region and they can be used to ensure
    59  	// the cluster is more resilient to failure.
    60  	// See: https://learn.microsoft.com/azure/reliability/availability-zones-overview
    61  	// This list will be used by Cluster API to try and spread the machines across the failure domains.
    62  	// +optional
    63  	FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
    64  
    65  	// Ready is true when the provider resource is ready.
    66  	// +optional
    67  	Ready bool `json:"ready"`
    68  
    69  	// Conditions defines current service state of the AzureCluster.
    70  	// +optional
    71  	Conditions clusterv1.Conditions `json:"conditions,omitempty"`
    72  
    73  	// LongRunningOperationStates saves the states for Azure long-running operations so they can be continued on the
    74  	// next reconciliation loop.
    75  	// +optional
    76  	LongRunningOperationStates Futures `json:"longRunningOperationStates,omitempty"`
    77  }
    78  
    79  // +kubebuilder:object:root=true
    80  // +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AzureCluster belongs"
    81  // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
    82  // +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
    83  // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.conditions[?(@.type=='Ready')].message"
    84  // +kubebuilder:printcolumn:name="Resource Group",type="string",priority=1,JSONPath=".spec.resourceGroup"
    85  // +kubebuilder:printcolumn:name="SubscriptionID",type="string",priority=1,JSONPath=".spec.subscriptionID"
    86  // +kubebuilder:printcolumn:name="Location",type="string",priority=1,JSONPath=".spec.location"
    87  // +kubebuilder:printcolumn:name="Endpoint",type="string",priority=1,JSONPath=".spec.controlPlaneEndpoint.host",description="Control Plane Endpoint"
    88  // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of this AzureCluster"
    89  // +kubebuilder:resource:path=azureclusters,scope=Namespaced,categories=cluster-api
    90  // +kubebuilder:storageversion
    91  // +kubebuilder:subresource:status
    92  
    93  // AzureCluster is the Schema for the azureclusters API.
    94  type AzureCluster struct {
    95  	metav1.TypeMeta   `json:",inline"`
    96  	metav1.ObjectMeta `json:"metadata,omitempty"`
    97  
    98  	Spec   AzureClusterSpec   `json:"spec,omitempty"`
    99  	Status AzureClusterStatus `json:"status,omitempty"`
   100  }
   101  
   102  // +kubebuilder:object:root=true
   103  
   104  // AzureClusterList contains a list of AzureClusters.
   105  type AzureClusterList struct {
   106  	metav1.TypeMeta `json:",inline"`
   107  	metav1.ListMeta `json:"metadata,omitempty"`
   108  	Items           []AzureCluster `json:"items"`
   109  }
   110  
   111  // GetConditions returns the list of conditions for an AzureCluster API object.
   112  func (c *AzureCluster) GetConditions() clusterv1.Conditions {
   113  	return c.Status.Conditions
   114  }
   115  
   116  // SetConditions will set the given conditions on an AzureCluster object.
   117  func (c *AzureCluster) SetConditions(conditions clusterv1.Conditions) {
   118  	c.Status.Conditions = conditions
   119  }
   120  
   121  // GetFutures returns the list of long running operation states for an AzureCluster API object.
   122  func (c *AzureCluster) GetFutures() Futures {
   123  	return c.Status.LongRunningOperationStates
   124  }
   125  
   126  // SetFutures will set the given long running operation states on an AzureCluster object.
   127  func (c *AzureCluster) SetFutures(futures Futures) {
   128  	c.Status.LongRunningOperationStates = futures
   129  }
   130  
   131  func init() {
   132  	SchemeBuilder.Register(&AzureCluster{}, &AzureClusterList{})
   133  }