github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/managedcluster.go (about)

     1  // Copyright (c) 2020-2021 Tigera, Inc. All rights reserved.
     2  
     3  package v3
     4  
     5  import (
     6  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     7  )
     8  
     9  const (
    10  	KindManagedCluster     = "ManagedCluster"
    11  	KindManagedClusterList = "ManagedClusterList"
    12  )
    13  
    14  type ManagedClusterStatusType string
    15  type ManagedClusterStatusValue string
    16  
    17  const (
    18  	// Status for Type ManagedClusterConnected will be Unknown when ManagedCluster is created,
    19  	// True when ManagedCluster is connected to ManagementCluster via tunnel,
    20  	// False when the tunnel drops
    21  	ManagedClusterStatusTypeConnected ManagedClusterStatusType  = "ManagedClusterConnected"
    22  	ManagedClusterStatusValueUnknown  ManagedClusterStatusValue = "Unknown"
    23  	ManagedClusterStatusValueTrue     ManagedClusterStatusValue = "True"
    24  	ManagedClusterStatusValueFalse    ManagedClusterStatusValue = "False"
    25  )
    26  
    27  // +genclient
    28  // +genclient:nonNamespaced
    29  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    30  
    31  // ManagedCluster represents a cluster that is being managed by the multi-cluster
    32  // management plane. This object configures how Tigera multi-cluster management
    33  // components communicate with the corresponding cluster.
    34  type ManagedCluster struct {
    35  	metav1.TypeMeta `json:",inline"`
    36  	// Standard object's metadata.
    37  	metav1.ObjectMeta `json:"metadata,omitempty"`
    38  	// Specification of the ManagedCluster.
    39  	Spec ManagedClusterSpec `json:"spec,omitempty"`
    40  	// Status of the ManagedCluster
    41  	Status ManagedClusterStatus `json:"status,omitempty"`
    42  }
    43  
    44  // ManagedClusterSpec contains the specification of a ManagedCluster resource.
    45  type ManagedClusterSpec struct {
    46  	// Field to store dynamically generated manifest for installing component into
    47  	// the actual application cluster corresponding to this Managed Cluster
    48  	InstallationManifest string `json:"installationManifest,omitempty"`
    49  	// The namespace of the managed cluster's operator. This value is used in
    50  	// the generation of the InstallationManifest.
    51  	OperatorNamespace string `json:"operatorNamespace,omitempty"`
    52  	// The certificate used to authenticate the managed cluster to the management cluster.
    53  	Certificate []byte `json:"certificate,omitempty"`
    54  }
    55  
    56  type ManagedClusterStatus struct {
    57  	Conditions []ManagedClusterStatusCondition `json:"conditions,omitempty"`
    58  }
    59  
    60  // Condition contains various status information
    61  type ManagedClusterStatusCondition struct {
    62  	Message string                    `json:"message,omitempty"`
    63  	Reason  string                    `json:"reason,omitempty"`
    64  	Status  ManagedClusterStatusValue `json:"status"`
    65  	Type    ManagedClusterStatusType  `json:"type"`
    66  }
    67  
    68  // +genclient:nonNamespaced
    69  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    70  
    71  // ManagedClusterList contains a list of ManagedCluster resources.
    72  type ManagedClusterList struct {
    73  	metav1.TypeMeta `json:",inline"`
    74  	metav1.ListMeta `json:"metadata"`
    75  	Items           []ManagedCluster `json:"items"`
    76  }
    77  
    78  // NewManagedCluster creates a new (zeroed) ManagedCluster struct with the TypeMetadata initialised to the current
    79  // version.
    80  func NewManagedCluster() *ManagedCluster {
    81  	return &ManagedCluster{
    82  		TypeMeta: metav1.TypeMeta{
    83  			Kind:       KindManagedCluster,
    84  			APIVersion: GroupVersionCurrent,
    85  		},
    86  	}
    87  }
    88  
    89  // NewManagedClusterList creates a new (zeroed) ManagedClusterList struct with the TypeMetadata initialised to the current
    90  // version.
    91  func NewManagedClusterList() *ManagedClusterList {
    92  	return &ManagedClusterList{
    93  		TypeMeta: metav1.TypeMeta{
    94  			Kind:       KindManagedClusterList,
    95  			APIVersion: GroupVersionCurrent,
    96  		},
    97  	}
    98  }