github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/api/v1alpha1/toolchaincluster_types.go (about) 1 package v1alpha1 2 3 // Most of the code was copied from the KubeFedCluster CRD of the KubeFed project https://github.com/kubernetes-sigs/kubefed 4 5 import ( 6 corev1 "k8s.io/api/core/v1" 7 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 8 ) 9 10 type ToolchainClusterConditionType string 11 12 // These are valid conditions of a cluster. 13 const ( 14 // ToolchainClusterReady means the cluster is ready to accept workloads. 15 ToolchainClusterReady ToolchainClusterConditionType = "Ready" 16 // ToolchainClusterOffline means the cluster is temporarily down or not reachable 17 ToolchainClusterOffline ToolchainClusterConditionType = "Offline" 18 19 ToolchainClusterClusterReadyReason = "ClusterReady" 20 ToolchainClusterClusterNotReadyReason = "ClusterNotReady" 21 ToolchainClusterClusterNotReachableReason = "ClusterNotReachable" 22 ToolchainClusterClusterReachableReason = "ClusterReachable" 23 ) 24 25 type TLSValidation string 26 27 const ( 28 TLSAll TLSValidation = "*" 29 TLSSubjectName TLSValidation = "SubjectName" 30 TLSValidityPeriod TLSValidation = "ValidityPeriod" 31 ) 32 33 // ToolchainClusterSpec defines the desired state of ToolchainCluster 34 // +k8s:openapi-gen=true 35 type ToolchainClusterSpec struct { 36 // The API endpoint of the member cluster. This can be a hostname, 37 // hostname:port, IP or IP:port. 38 APIEndpoint string `json:"apiEndpoint"` 39 40 // CABundle contains the certificate authority information. 41 // +optional 42 CABundle string `json:"caBundle,omitempty"` 43 44 // Name of the secret containing the token required to access the 45 // member cluster. The secret needs to exist in the same namespace 46 // as the control plane and should have a "token" key. 47 SecretRef LocalSecretReference `json:"secretRef"` 48 49 // DisabledTLSValidations defines a list of checks to ignore when validating 50 // the TLS connection to the member cluster. This can be any of *, SubjectName, or ValidityPeriod. 51 // If * is specified, it is expected to be the only option in list. 52 // +optional 53 // +listType=set 54 DisabledTLSValidations []TLSValidation `json:"disabledTLSValidations,omitempty"` 55 } 56 57 // LocalSecretReference is a reference to a secret within the enclosing 58 // namespace. 59 // +k8s:openapi-gen=true 60 type LocalSecretReference struct { 61 // Name of a secret within the enclosing 62 // namespace 63 Name string `json:"name"` 64 } 65 66 // ToolchainClusterStatus contains information about the current status of a 67 // cluster updated periodically by cluster controller. 68 // +k8s:openapi-gen=true 69 type ToolchainClusterStatus struct { 70 // Conditions is an array of current cluster conditions. 71 // +listType=atomic 72 Conditions []ToolchainClusterCondition `json:"conditions"` 73 } 74 75 //+kubebuilder:object:root=true 76 //+kubebuilder:subresource:status 77 78 // ToolchainCluster configures Toolchain to be aware of a Kubernetes 79 // cluster and encapsulates the details necessary to communicate with 80 // the cluster. 81 // +k8s:openapi-gen=true 82 // +kubebuilder:subresource:status 83 // +kubebuilder:resource:scope=Namespaced 84 // +kubebuilder:resource:path=toolchainclusters 85 // +kubebuilder:printcolumn:name=age,type=date,JSONPath=.metadata.creationTimestamp 86 // +kubebuilder:printcolumn:name=ready,type=string,JSONPath=.status.conditions[?(@.type=='Ready')].status 87 // +kubebuilder:subresource:status 88 // +kubebuilder:validation:XPreserveUnknownFields 89 // +operator-sdk:gen-csv:customresourcedefinitions.displayName="Toolchain Cluster" 90 type ToolchainCluster struct { 91 metav1.TypeMeta `json:",inline"` 92 metav1.ObjectMeta `json:"metadata,omitempty"` 93 94 Spec ToolchainClusterSpec `json:"spec"` 95 // +optional 96 Status ToolchainClusterStatus `json:"status,omitempty"` 97 } 98 99 // ToolchainClusterCondition describes current state of a cluster. 100 // +k8s:openapi-gen=true 101 type ToolchainClusterCondition struct { 102 // Type of cluster condition, Ready or Offline. 103 Type ToolchainClusterConditionType `json:"type"` 104 // Status of the condition, one of True, False, Unknown. 105 Status corev1.ConditionStatus `json:"status"` 106 // Last time the condition was checked. 107 // +optional 108 LastProbeTime metav1.Time `json:"lastProbeTime"` 109 // Last time the condition was updated 110 // +optional 111 LastUpdatedTime *metav1.Time `json:"lastUpdatedTime,omitempty"` 112 // Last time the condition transit from one status to another. 113 // +optional 114 LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` 115 // (brief) reason for the condition's last transition. 116 // +optional 117 Reason string `json:"reason,omitempty"` 118 // Human readable message indicating details about last transition. 119 // +optional 120 Message string `json:"message,omitempty"` 121 } 122 123 //+kubebuilder:object:root=true 124 125 // ToolchainClusterList contains a list of ToolchainCluster 126 type ToolchainClusterList struct { 127 metav1.TypeMeta `json:",inline"` 128 metav1.ListMeta `json:"metadata,omitempty"` 129 Items []ToolchainCluster `json:"items"` 130 } 131 132 func init() { 133 SchemeBuilder.Register(&ToolchainCluster{}, &ToolchainClusterList{}) 134 }