github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/remoteclusterconfig.go (about) 1 // Copyright (c) 2018,2020-2021 Tigera, Inc. All rights reserved. 2 3 package v3 4 5 import ( 6 k8sv1 "k8s.io/api/core/v1" 7 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 8 ) 9 10 const ( 11 KindRemoteClusterConfiguration = "RemoteClusterConfiguration" 12 KindRemoteClusterConfigurationList = "RemoteClusterConfigurationList" 13 ) 14 15 // +genclient 16 // +genclient:nonNamespaced 17 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 18 19 // RemoteClusterConfiguration contains the configuration for remote clusters. 20 type RemoteClusterConfiguration struct { 21 metav1.TypeMeta `json:",inline"` 22 // Standard object's metadata. 23 metav1.ObjectMeta `json:"metadata,omitempty"` 24 // Specification of the RemoteClusterConfiguration. 25 Spec RemoteClusterConfigurationSpec `json:"spec,omitempty"` 26 } 27 28 // It's desirable to keep the list of things configurable here in sync with the other mechanism in apiconfig.go 29 30 // RemoteClusterConfigurationSpec contains the values of describing the cluster. 31 type RemoteClusterConfigurationSpec struct { 32 // Indicates the datastore to use. If unspecified, defaults to etcdv3 33 DatastoreType string `json:"datastoreType,omitempty" validate:"omitempty,datastoreType"` 34 35 // Specifies a Secret to read for the RemoteClusterconfiguration. 36 // If defined all datastore configuration in this struct will be cleared 37 // and overwritten with the appropriate fields in the Secret. 38 ClusterAccessSecret *k8sv1.ObjectReference `json:"clusterAccessSecret,omitempty" validate:"omitempty,clusterAccessSecret"` 39 40 // Inline the ectd config fields 41 EtcdConfig `json:",inline"` 42 43 // Inline the k8s config fields. 44 KubeConfig `json:",inline"` 45 46 // Configuration options that do not relate to the underlying datastore connection. These fields relate to the 47 // syncing of resources once the connection is established. These fields can be set independent of the other 48 // connection-oriented fields, e.g. they can be set when ClusterAccessSecret is non-nil. 49 // +kubebuilder:default={overlayRoutingMode: "Disabled"} 50 SyncOptions RemoteClusterSyncOptions `json:"syncOptions,omitempty"` 51 } 52 53 type RemoteClusterSyncOptions struct { 54 // Determines whether overlay routing will be established between federated clusters. If unspecified during create or 55 // update of RemoteClusterConfiguration, this field will default based on the encapsulation mode of the local cluster 56 // at the time of RemoteClusterConfiguration application: "Enabled" if VXLAN, "Disabled" otherwise. If upgrading from 57 // a version that predates this field, this field will default to "Disabled". 58 // +kubebuilder:default=Disabled 59 OverlayRoutingMode OverlayRoutingMode `json:"overlayRoutingMode,omitempty" validate:"omitempty,oneof=Enabled Disabled"` 60 } 61 62 type OverlayRoutingMode string 63 64 const ( 65 OverlayRoutingModeEnabled OverlayRoutingMode = "Enabled" 66 OverlayRoutingModeDisabled OverlayRoutingMode = "Disabled" 67 ) 68 69 type EtcdConfig struct { 70 // A comma separated list of etcd endpoints. Valid if DatastoreType is etcdv3. [Default: ] 71 EtcdEndpoints string `json:"etcdEndpoints,omitempty" validate:"omitempty,etcdEndpoints"` 72 // User name for RBAC. Valid if DatastoreType is etcdv3. 73 EtcdUsername string `json:"etcdUsername,omitempty" validate:"omitempty"` 74 // Password for the given user name. Valid if DatastoreType is etcdv3. 75 EtcdPassword string `json:"etcdPassword,omitempty" validate:"omitempty"` 76 // Path to the etcd key file. Valid if DatastoreType is etcdv3. 77 EtcdKeyFile string `json:"etcdKeyFile,omitempty" validate:"omitempty,file"` 78 // Path to the etcd client certificate. Valid if DatastoreType is etcdv3. 79 EtcdCertFile string `json:"etcdCertFile,omitempty" validate:"omitempty,file"` 80 // Path to the etcd Certificate Authority file. Valid if DatastoreType is etcdv3. 81 EtcdCACertFile string `json:"etcdCACertFile,omitempty" validate:"omitempty,file"` 82 // These config file parameters are to support inline certificates, keys and CA / Trusted certificate. 83 EtcdKey string `json:"etcdKey,omitempty" ignored:"true"` 84 EtcdCert string `json:"etcdCert,omitempty" ignored:"true"` 85 EtcdCACert string `json:"etcdCACert,omitempty" ignored:"true"` 86 } 87 88 type KubeConfig struct { 89 // When using the Kubernetes datastore, the location of a kubeconfig file. Valid if DatastoreType is kubernetes. 90 Kubeconfig string `json:"kubeconfig,omitempty" validate:"omitempty,file"` 91 // Location of the Kubernetes API. Not required if using kubeconfig. Valid if DatastoreType is kubernetes. 92 K8sAPIEndpoint string `json:"k8sAPIEndpoint,omitempty" validate:"omitempty,k8sEndpoint"` 93 // Location of a client key for accessing the Kubernetes API. Valid if DatastoreType is kubernetes. 94 K8sKeyFile string `json:"k8sKeyFile,omitempty" validate:"omitempty,file"` 95 // Location of a client certificate for accessing the Kubernetes API. Valid if DatastoreType is kubernetes. 96 K8sCertFile string `json:"k8sCertFile,omitempty" validate:"omitempty,file"` 97 // Location of a CA for accessing the Kubernetes API. Valid if DatastoreType is kubernetes. 98 K8sCAFile string `json:"k8sCAFile,omitempty" validate:"omitempty,file"` 99 // Token to be used for accessing the Kubernetes API. Valid if DatastoreType is kubernetes. 100 K8sAPIToken string `json:"k8sAPIToken,omitempty" validate:"omitempty"` 101 K8sInsecureSkipTLSVerify bool `json:"k8sInsecureSkipTLSVerify,omitempty" validate:"omitempty"` 102 // This is an alternative to Kubeconfig and if specified overrides Kubeconfig. 103 // This contains the contents that would normally be in the file pointed at by Kubeconfig. 104 KubeconfigInline string `json:"kubeconfigInline,omitempty" ignored:"true"` 105 } 106 107 // +genclient:nonNamespaced 108 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 109 110 // RemoteClusterConfigurationList contains a list of RemoteClusterConfiguration resources 111 type RemoteClusterConfigurationList struct { 112 metav1.TypeMeta `json:",inline"` 113 metav1.ListMeta `json:"metadata"` 114 Items []RemoteClusterConfiguration `json:"items"` 115 } 116 117 // New RemoteClusterConfiguration creates a new (zeroed) RemoteClusterConfiguration struct with the TypeMetadata 118 // initialized to the current version. 119 func NewRemoteClusterConfiguration() *RemoteClusterConfiguration { 120 return &RemoteClusterConfiguration{ 121 TypeMeta: metav1.TypeMeta{ 122 Kind: KindRemoteClusterConfiguration, 123 APIVersion: GroupVersionCurrent, 124 }, 125 } 126 } 127 128 // NewRemoteClusterConfigurationList creates a new (zeroed) RemoteClusterConfigurationList struct with the TypeMetadata 129 // initialized to the current version. 130 func NewRemoteClusterConfigurationList() *RemoteClusterConfigurationList { 131 return &RemoteClusterConfigurationList{ 132 TypeMeta: metav1.TypeMeta{ 133 Kind: KindRemoteClusterConfigurationList, 134 APIVersion: GroupVersionCurrent, 135 }, 136 } 137 }