k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/configuration.go (about)

     1  /*
     2  Copyright 2023 The Kubermatic Kubernetes Platform contributors.
     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 v1
    18  
    19  import (
    20  	"k8c.io/api/v3/pkg/semver"
    21  
    22  	corev1 "k8s.io/api/core/v1"
    23  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    24  )
    25  
    26  // +kubebuilder:validation:Enum=always;externalCloudProvider;inTreeProvider
    27  
    28  // ConditionType is the type defining the cluster or datacenter condition that must be met to block a specific version.
    29  type ConditionType string
    30  
    31  const (
    32  	// AlwaysCondition represent an always true matching condition used while checking provider incompatibilities.
    33  	ConditionAlways ConditionType = "always"
    34  	// ExternalCloudProviderCondition is an incompatibility condition that represents the usage of the external Cloud Provider.
    35  	ConditionExternalCloudProvider ConditionType = ClusterFeatureExternalCloudProvider
    36  	// InTreeCloudProviderCondition is an incompatibility condition that represents the usage of the in-tree Cloud Provider.
    37  	ConditionInTreeCloudProvider ConditionType = "inTreeProvider"
    38  )
    39  
    40  // +kubebuilder:validation:Enum=CREATE;UPGRADE;SUPPORT
    41  
    42  // OperationType is the type defining the operations triggering the compatibility check (CREATE or UPDATE).
    43  type OperationType string
    44  
    45  const (
    46  	// CreateOperation represents the creation of a new cluster.
    47  	OperationCreate OperationType = "CREATE"
    48  	// UpdateOperation represents the update of an existing cluster.
    49  	OperationUpdate OperationType = "UPGRADE"
    50  	// SupportOperation represents the possibility to enable a new feature on an existing cluster.
    51  	OperationSupport OperationType = "SUPPORT"
    52  )
    53  
    54  // +genclient
    55  // +kubebuilder:object:generate=true
    56  // +kubebuilder:object:root=true
    57  // +kubebuilder:subresource:status
    58  // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date"
    59  
    60  // KubermaticConfiguration is the configuration required for running Kubermatic.
    61  type KubermaticConfiguration struct {
    62  	metav1.TypeMeta   `json:",inline"`
    63  	metav1.ObjectMeta `json:"metadata,omitempty"`
    64  
    65  	Spec   KubermaticConfigurationSpec   `json:"spec,omitempty"`
    66  	Status KubermaticConfigurationStatus `json:"status,omitempty"`
    67  }
    68  
    69  // KubermaticConfigurationStatus stores status information about a KubermaticConfiguration.
    70  type KubermaticConfigurationStatus struct {
    71  	// KubermaticVersion current Kubermatic Version.
    72  	KubermaticVersion string `json:"kubermaticVersion,omitempty"`
    73  	// KubermaticEdition current Kubermatic Edition , i.e. Community Edition or Enterprise Edition.
    74  	KubermaticEdition string `json:"kubermaticEdition,omitempty"`
    75  }
    76  
    77  // KubermaticConfigurationSpec is the spec for a Kubermatic installation.
    78  type KubermaticConfigurationSpec struct {
    79  	// CABundle references a ConfigMap in the same namespace as the KubermaticConfiguration.
    80  	// This ConfigMap must contain a ca-bundle.pem with PEM-encoded certificates. This bundle
    81  	// automatically synchronized into each seed and each usercluster. APIGroup and Kind are
    82  	// currently ignored.
    83  	CABundle corev1.TypedLocalObjectReference `json:"caBundle,omitempty"`
    84  	// ImagePullSecret is used to authenticate against Docker registries.
    85  	ImagePullSecret string `json:"imagePullSecret,omitempty"`
    86  	// Auth defines keys and URLs for Dex. These must be defined unless the HeadlessInstallation
    87  	// feature gate is set, which will disable the UI/API and its need for an OIDC provider entirely.
    88  	Auth *KubermaticAuthConfiguration `json:"auth,omitempty"`
    89  	// FeatureGates are used to optionally enable certain features.
    90  	FeatureGates map[string]bool `json:"featureGates,omitempty"`
    91  	// UI configures the dashboard.
    92  	UI *KubermaticUIConfiguration `json:"ui,omitempty"`
    93  	// API configures the frontend REST API used by the dashboard.
    94  	API *KubermaticAPIConfiguration `json:"api,omitempty"`
    95  	// ControllerManager configures the kubermatic-controller-manager.
    96  	ControllerManager *KubermaticControllerManagerConfiguration `json:"controllerManager,omitempty"`
    97  	// Webhook configures the webhook.
    98  	Webhook *KubermaticWebhookConfiguration `json:"webhook,omitempty"`
    99  	// UserCluster configures various aspects of the user-created clusters.
   100  	UserCluster *KubermaticUserClusterConfiguration `json:"userCluster,omitempty"`
   101  	// ExposeStrategy is the strategy to expose the control planes of user clusters with.
   102  	ExposeStrategy ExposeStrategy `json:"exposeStrategy,omitempty"`
   103  	// NodeportProxy can be used to configure the NodePort proxy service that is
   104  	// responsible for making user-cluster control planes accessible from the outside. This only
   105  	// takes effect if the ExposeStrategy is set to NodePort.
   106  	NodeportProxy *NodeportProxyConfig `json:"nodeportProxy,omitempty"`
   107  	// Ingress contains settings for making the API and UI accessible remotely.
   108  	Ingress KubermaticIngressConfiguration `json:"ingress,omitempty"`
   109  	// Versions configures the available and default Kubernetes versions and updates.
   110  	Versions KubermaticVersioningConfiguration `json:"versions,omitempty"`
   111  	// VerticalPodAutoscaler configures the Kubernetes VPA integration.
   112  	VerticalPodAutoscaler *KubermaticVPAConfiguration `json:"verticalPodAutoscaler,omitempty"`
   113  	// Proxy allows to configure Kubermatic to use proxies to talk to the
   114  	// world outside of its cluster.
   115  	Proxy    *KubermaticProxyConfiguration `json:"proxy,omitempty"`
   116  	Metering *MeteringConfiguration        `json:"metering,omitempty"`
   117  }
   118  
   119  // KubermaticAuthConfiguration defines keys and URLs for Dex.
   120  // OIDC is later used to configure:
   121  // - access to User Cluster API-Servers (via user kubeconfigs) - https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens,
   122  // - access to User Cluster's Kubernetes Dashboards.
   123  type KubermaticAuthConfiguration struct {
   124  	ClientID string `json:"clientID,omitempty"`
   125  	// URL of the provider which allows the API server to discover public signing keys.
   126  	TokenIssuer       string `json:"tokenIssuer,omitempty"`
   127  	IssuerRedirectURL string `json:"issuerRedirectURL,omitempty"`
   128  	// IssuerClientID is the application's ID.
   129  	IssuerClientID string `json:"issuerClientID,omitempty"`
   130  	// IssuerClientSecret is the application's secret.
   131  	IssuerClientSecret string `json:"issuerClientSecret,omitempty"`
   132  	// IssuerCookieKey is required, used to authenticate the cookie value using HMAC.
   133  	// It is recommended to use a key with 32 or 64 bytes.
   134  	IssuerCookieKey   string `json:"issuerCookieKey,omitempty"`
   135  	ServiceAccountKey string `json:"serviceAccountKey,omitempty"`
   136  	// Optional: SkipTokenIssuerTLSVerify skip TLS verification for the token issuer.
   137  	SkipTokenIssuerTLSVerify bool `json:"skipTokenIssuerTLSVerify,omitempty"`
   138  
   139  	// Optional: OfflineAccessAsScope if true then "offline_access" scope will be used
   140  	// otherwise 'access_type=offline" query param will be passed.
   141  	OfflineAccessAsScope *bool `json:"offlineAccessAsScope,omitempty"`
   142  }
   143  
   144  // KubermaticAPIConfiguration configures the dashboard.
   145  type KubermaticAPIConfiguration struct {
   146  	// DockerRepository is the repository containing the Kubermatic REST API image.
   147  	DockerRepository string `json:"dockerRepository,omitempty"`
   148  	// AccessibleAddons is a list of addons that should be enabled in the API.
   149  	AccessibleAddons []string `json:"accessibleAddons,omitempty"`
   150  	// PProfEndpoint controls the port the API should listen on to provide pprof
   151  	// data. This port is never exposed from the container and only available via port-forwardings.
   152  	PProfEndpoint *string `json:"pprofEndpoint,omitempty"`
   153  	// Resources describes the requested and maximum allowed CPU/memory usage.
   154  	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
   155  	// DebugLog enables more verbose logging.
   156  	DebugLog bool `json:"debugLog,omitempty"`
   157  	// Replicas sets the number of pod replicas for the API deployment.
   158  	Replicas *int32 `json:"replicas,omitempty"`
   159  }
   160  
   161  // KubermaticUIConfiguration configures the dashboard.
   162  type KubermaticUIConfiguration struct {
   163  	// DockerRepository is the repository containing the Kubermatic dashboard image.
   164  	DockerRepository string `json:"dockerRepository,omitempty"`
   165  	// DockerTag is used to overwrite the dashboard Docker image tag and is only for development
   166  	// purposes. This field must not be set in production environments.
   167  	// ---
   168  	//nolint:staticcheck
   169  	//lint:ignore SA5008 omitgenyaml is used by the example-yaml-generator
   170  	DockerTag string `json:"dockerTag,omitempty,omitgenyaml"`
   171  	// DockerTagSuffix is appended to the KKP version used for referring to the custom dashboard image.
   172  	// If left empty, either the `DockerTag` if specified or the original dashboard Docker image tag will be used.
   173  	// With DockerTagSuffix the tag becomes <KKP_VERSION:SUFFIX> i.e. "v3.15.0-SUFFIX".
   174  	DockerTagSuffix string `json:"dockerTagSuffix,omitempty"`
   175  	// Config sets flags for various dashboard features.
   176  	Config string `json:"config,omitempty"`
   177  	// Resources describes the requested and maximum allowed CPU/memory usage.
   178  	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
   179  	// Replicas sets the number of pod replicas for the UI deployment.
   180  	Replicas *int32 `json:"replicas,omitempty"`
   181  	// ExtraVolumeMounts allows to mount additional volumes into the UI container.
   182  	ExtraVolumeMounts []corev1.VolumeMount `json:"extraVolumeMounts,omitempty"`
   183  	// ExtraVolumes allows to mount additional volumes into the UI container.
   184  	ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"`
   185  }
   186  
   187  // KubermaticControllerManagerConfiguration configures the Kubermatic seed controller-manager.
   188  type KubermaticControllerManagerConfiguration struct {
   189  	// DockerRepository is the repository containing the Kubermatic seed-controller-manager image.
   190  	DockerRepository string `json:"dockerRepository,omitempty"`
   191  	// BackupStoreContainer is the container used for shipping etcd snapshots to a backup location.
   192  	BackupStoreContainer string `json:"backupStoreContainer,omitempty"`
   193  	// BackupDeleteContainer is the container used for deleting etcd snapshots from a backup location.
   194  	// This container is only relevant when the new backup/restore controllers are enabled.
   195  	BackupDeleteContainer string `json:"backupDeleteContainer,omitempty"`
   196  	// BackupCleanupContainer is the container used for removing expired backups from the storage location.
   197  	// This container is only relevant when the old, deprecated backup controllers are enabled.
   198  	BackupCleanupContainer string `json:"backupCleanupContainer,omitempty"`
   199  	// MaximumParallelReconciles limits the number of cluster reconciliations
   200  	// that are active at any given time.
   201  	MaximumParallelReconciles int `json:"maximumParallelReconciles,omitempty"`
   202  	// ProjectsMigrator configures the migrator for user projects.
   203  	ProjectsMigrator *KubermaticProjectsMigratorConfiguration `json:"projectsMigrator,omitempty"`
   204  	// PProfEndpoint controls the port the seed-controller-manager should listen on to provide pprof
   205  	// data. This port is never exposed from the container and only available via port-forwardings.
   206  	PProfEndpoint *string `json:"pprofEndpoint,omitempty"`
   207  	// Resources describes the requested and maximum allowed CPU/memory usage.
   208  	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
   209  	// DebugLog enables more verbose logging.
   210  	DebugLog bool `json:"debugLog,omitempty"`
   211  	// Replicas sets the number of pod replicas for the seed-controller-manager.
   212  	Replicas *int32 `json:"replicas,omitempty"`
   213  }
   214  
   215  // KubermaticWebhookConfiguration configures the Kubermatic webhook.
   216  type KubermaticWebhookConfiguration struct {
   217  	// DockerRepository is the repository containing the Kubermatic webhook image.
   218  	DockerRepository string `json:"dockerRepository,omitempty"`
   219  	// PProfEndpoint controls the port the webhook should listen on to provide pprof
   220  	// data. This port is never exposed from the container and only available via port-forwardings.
   221  	PProfEndpoint *string `json:"pprofEndpoint,omitempty"`
   222  	// Resources describes the requested and maximum allowed CPU/memory usage.
   223  	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
   224  	// DebugLog enables more verbose logging.
   225  	DebugLog bool `json:"debugLog,omitempty"`
   226  	// Replicas sets the number of pod replicas for the webhook.
   227  	Replicas *int32 `json:"replicas,omitempty"`
   228  }
   229  
   230  // KubermaticUserClusterConfiguration controls various aspects of the user-created clusters.
   231  type KubermaticUserClusterConfiguration struct {
   232  	// This configures the base domain for all userclusters. Each usercluster will get a subdomain
   233  	// (named <clustername>.<basedomain>) to allow access to the cluster's controlplane. This
   234  	// domain should be different from the main ingress (which makes the KKP dashboard available),
   235  	// as cluster names might collide with other, well-known names and could interfere with the
   236  	// dashboard. If your dashboard is using "example.com", you could configure the usercluster
   237  	// base domain as "clusters.example.com".
   238  	BaseDomain string `json:"baseDomain"`
   239  	// DefaultCTemplate is the name of a cluster template that is used to default a new user cluster.
   240  	DefaultTemplate string `json:"defaultTemplate,omitempty"`
   241  	// KubermaticDockerRepository is the repository containing the Kubermatic user-cluster-controller-manager image.
   242  	KubermaticDockerRepository string `json:"kubermaticDockerRepository,omitempty"`
   243  	// DNATControllerDockerRepository is the repository containing the
   244  	// dnat-controller image.
   245  	DNATControllerDockerRepository string `json:"dnatControllerDockerRepository,omitempty"`
   246  	// EtcdLauncherDockerRepository is the repository containing the Kubermatic
   247  	// etcd-launcher image.
   248  	EtcdLauncherDockerRepository string `json:"etcdLauncherDockerRepository,omitempty"`
   249  	// OverwriteRegistry specifies a custom Docker registry which will be used for all images
   250  	// used for user clusters (user cluster control plane + addons). This also applies to
   251  	// the KubermaticDockerRepository and DNATControllerDockerRepository fields.
   252  	OverwriteRegistry string `json:"overwriteRegistry,omitempty"`
   253  	// Addons controls the optional additions installed into each user cluster.
   254  	Addons *KubermaticAddonsConfiguration `json:"addons,omitempty"`
   255  	// SystemApplications contains configuration for system Applications (such as CNI).
   256  	SystemApplications *SystemApplicationsConfiguration `json:"systemApplications,omitempty"`
   257  	// NodePortRange is the port range for user clusters - this must match the NodePort
   258  	// range of the seed cluster.
   259  	NodePortRange string `json:"nodePortRange,omitempty"`
   260  	// Monitoring can be used to fine-tune to in-cluster Prometheus.
   261  	Monitoring *KubermaticUserClusterMonitoringConfiguration `json:"monitoring,omitempty"`
   262  	// DisableAPIServerEndpointReconciling can be used to toggle the `--endpoint-reconciler-type` flag for
   263  	// the Kubernetes API server.
   264  	DisableAPIServerEndpointReconciling bool `json:"disableApiserverEndpointReconciling,omitempty"`
   265  	// EtcdVolumeSize configures the volume size to use for each etcd pod inside user clusters.
   266  	EtcdVolumeSize string `json:"etcdVolumeSize,omitempty"`
   267  	// APIServerReplicas configures the replica count for the API-Server deployment inside user clusters.
   268  	APIServerReplicas *int32 `json:"apiserverReplicas,omitempty"`
   269  	// MachineController configures the Machine Controller
   270  	MachineController *MachineControllerConfiguration `json:"machineController,omitempty"`
   271  	// OperatingSystemManager configures the image repo and the tag version for osm deployment.
   272  	OperatingSystemManager *OperatingSystemManager                `json:"operatingSystemManager,omitempty"`
   273  	MLA                    *KubermaticUserClusterMLAConfiguration `json:"mla,omitempty"`
   274  	// EtcdBackupRestore holds the configuration of the automatic etcd backup restores for the Seed;
   275  	// if this is set, the new backup/restore controllers are enabled for this Seed.
   276  	EtcdBackupRestore *EtcdBackupRestore `json:"etcdBackupRestore,omitempty"`
   277  	// Optional: ProxySettings can be used to configure HTTP proxy settings on the
   278  	// worker nodes in user clusters. However, proxy settings on nodes take precedence.
   279  	ProxySettings *ProxySettings `json:"proxySettings,omitempty"`
   280  }
   281  
   282  // KubermaticUserClusterMLAConfiguration allows configuring Monitoring, Logging & Alerting settings.
   283  type KubermaticUserClusterMLAConfiguration struct {
   284  	Enabled bool `json:"enabled"`
   285  }
   286  
   287  // KubermaticUserClusterMonitoringConfiguration can be used to fine-tune to in-cluster Prometheus.
   288  type KubermaticUserClusterMonitoringConfiguration struct {
   289  	// DisableDefaultRules disables the recording and alerting rules.
   290  	DisableDefaultRules bool `json:"disableDefaultRules,omitempty"`
   291  	// DisableDefaultScrapingConfigs disables the default scraping targets.
   292  	DisableDefaultScrapingConfigs bool `json:"disableDefaultScrapingConfigs,omitempty"`
   293  	// CustomRules can be used to inject custom recording and alerting rules. This field
   294  	// must be a YAML-formatted string with a `group` element at its root, as documented
   295  	// on https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/.
   296  	// This value is treated as a Go template, which allows to inject dynamic values like
   297  	// the internal cluster address or the cluster ID. Refer to pkg/resources/prometheus
   298  	// and the documentation for more information on the available fields.
   299  	CustomRules string `json:"customRules,omitempty"`
   300  	// CustomScrapingConfigs can be used to inject custom scraping rules. This must be a
   301  	// YAML-formatted string containing an array of scrape configurations as documented
   302  	// on https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config.
   303  	// This value is treated as a Go template, which allows to inject dynamic values like
   304  	// the internal cluster address or the cluster ID. Refer to pkg/resources/prometheus
   305  	// and the documentation for more information on the available fields.
   306  	CustomScrapingConfigs string `json:"customScrapingConfigs,omitempty"`
   307  	// ScrapeAnnotationPrefix (if set) is used to make the in-cluster Prometheus scrape pods
   308  	// inside the user clusters.
   309  	ScrapeAnnotationPrefix string `json:"scrapeAnnotationPrefix,omitempty"`
   310  }
   311  
   312  // MachineControllerConfiguration configures Machine Controller.
   313  type MachineControllerConfiguration struct {
   314  	// ImageRepository is used to override the Machine Controller image repository.
   315  	// It is only for development, tests and PoC purposes. This field must not be set in production environments.
   316  	ImageRepository string `json:"imageRepository,omitempty"`
   317  	// ImageTag is used to override the Machine Controller image.
   318  	// It is only for development, tests and PoC purposes. This field must not be set in production environments.
   319  	ImageTag string `json:"imageTag,omitempty"`
   320  }
   321  
   322  // OperatingSystemManager configures the image repo and the tag version for osm deployment.
   323  type OperatingSystemManager struct {
   324  	// ImageRepository is used to override the OperatingSystemManager image repository.
   325  	// It is recommended to use this field only for development, tests and PoC purposes. For production environments.
   326  	// it is not recommended, to use this field due to compatibility with the overall KKP stack.
   327  	ImageRepository string `json:"imageRepository,omitempty"`
   328  	// ImageTag is used to override the OperatingSystemManager image.
   329  	// It is recommended to use this field only for development, tests and PoC purposes. For production environments.
   330  	// it is not recommended, to use this field due to compatibility with the overall KKP stack.
   331  	ImageTag string `json:"imageTag,omitempty"`
   332  }
   333  
   334  // KubermaticAddonConfiguration describes the addons for a given cluster runtime.
   335  type KubermaticAddonsConfiguration struct {
   336  	// Default is the list of addons to be installed by default into each cluster.
   337  	// Mutually exclusive with "defaultManifests".
   338  	Default []string `json:"default,omitempty"`
   339  	// DefaultManifests is a list of addon manifests to install into all clusters.
   340  	// Mutually exclusive with "default".
   341  	DefaultManifests string `json:"defaultManifests,omitempty"`
   342  	// DockerRepository is the repository containing the Docker image containing
   343  	// the possible addon manifests.
   344  	DockerRepository string `json:"dockerRepository,omitempty"`
   345  	// DockerTagSuffix is appended to the tag used for referring to the addons image.
   346  	// If left empty, the tag will be the KKP version (e.g. "v3.15.0"), with a
   347  	// suffix it becomes "v3.15.0-SUFFIX".
   348  	DockerTagSuffix string `json:"dockerTagSuffix,omitempty"`
   349  }
   350  
   351  // SystemApplicationsConfiguration contains configuration for system Applications (e.g. CNI).
   352  type SystemApplicationsConfiguration struct {
   353  	// HelmRepository specifies OCI repository containing Helm charts of system Applications.
   354  	HelmRepository string `json:"helmRepository,omitempty"`
   355  	// HelmRegistryConfigFile optionally holds the ref and key in the secret for the OCI registry credential file.
   356  	// The value is dockercfg file that follows the same format rules as ~/.docker/config.json
   357  	// The Secret must exist in the namespace where KKP is installed (default is "kubermatic").
   358  	// The Secret must be annotated with `apps.kubermatic.k8c.io/secret-type:` set to "helm".
   359  	HelmRegistryConfigFile *corev1.SecretKeySelector `json:"helmRegistryConfigFile,omitempty"`
   360  }
   361  
   362  type KubermaticIngressConfiguration struct {
   363  	// Domain is the base domain where the dashboard shall be available. Even with
   364  	// a disabled Ingress, this must always be a valid hostname.
   365  	Domain string `json:"domain"`
   366  
   367  	// ClassName is the Ingress resource's class name, used for selecting the appropriate
   368  	// ingress controller.
   369  	ClassName string `json:"className,omitempty"`
   370  
   371  	// Disable will prevent an Ingress from being created at all. This is mostly useful
   372  	// during testing. If the Ingress is disabled, the CertificateIssuer setting can also
   373  	// be left empty, as no Certificate resource will be created.
   374  	Disable bool `json:"disable,omitempty"`
   375  
   376  	// CertificateIssuer is the name of a cert-manager Issuer or ClusterIssuer (default)
   377  	// that will be used to acquire the certificate for the configured domain.
   378  	// To use a namespaced Issuer, set the Kind to "Issuer" and manually create the
   379  	// matching Issuer in Kubermatic's namespace.
   380  	// Setting an empty name disables the automatic creation of certificates and disables
   381  	// the TLS settings on the Kubermatic Ingress.
   382  	CertificateIssuer *corev1.TypedLocalObjectReference `json:"certificateIssuer,omitempty"`
   383  }
   384  
   385  // KubermaticProjectsMigratorConfiguration configures the Kubermatic master controller-manager.
   386  type KubermaticProjectsMigratorConfiguration struct {
   387  	// DryRun makes the migrator only log the actions it would take.
   388  	DryRun bool `json:"dryRun,omitempty"`
   389  }
   390  
   391  // KubermaticVersioningConfiguration configures the available and default Kubernetes versions.
   392  type KubermaticVersioningConfiguration struct {
   393  	// Versions lists the available versions.
   394  	Versions []semver.Semver `json:"versions,omitempty"`
   395  	// Default is the default version to offer users.
   396  	Default *semver.Semver `json:"default,omitempty"`
   397  
   398  	// Updates is a list of available and automatic upgrades.
   399  	// All 'to' versions must be configured in the version list for this orchestrator.
   400  	// Each update may optionally be configured to be 'automatic: true', in which case the
   401  	// controlplane of all clusters whose version matches the 'from' directive will get
   402  	// updated to the 'to' version. If automatic is enabled, the 'to' version must be a
   403  	// version and not a version range.
   404  	// Also, updates may set 'automaticNodeUpdate: true', in which case Nodes will get
   405  	// updates as well. 'automaticNodeUpdate: true' implies 'automatic: true' as well,
   406  	// because Nodes may not have a newer version than the controlplane.
   407  	Updates []Update `json:"updates,omitempty"`
   408  
   409  	// ProviderIncompatibilities lists all the Kubernetes version incompatibilities
   410  	ProviderIncompatibilities []Incompatibility `json:"providerIncompatibilities,omitempty"`
   411  }
   412  
   413  // ExternalClusterProviderVersioningConfiguration configures the available and default Kubernetes versions for ExternalCluster Providers.
   414  type ExternalClusterProviderVersioningConfiguration struct {
   415  	// Versions lists the available versions.
   416  	Versions []semver.Semver `json:"versions,omitempty"`
   417  	// Default is the default version to offer users.
   418  	Default *semver.Semver `json:"default,omitempty"`
   419  	// Updates is a list of available upgrades.
   420  	Updates []semver.Semver `json:"updates,omitempty"`
   421  }
   422  
   423  // Update represents an update option for a user cluster.
   424  type Update struct {
   425  	// From is the version from which an update is allowed. Wildcards are allowed, e.g. "1.18.*".
   426  	From string `json:"from,omitempty"`
   427  	// To is the version to which an update is allowed.
   428  	// Must be a valid version if `automatic` is set to true, e.g. "1.20.13".
   429  	// Can be a wildcard otherwise, e.g. "1.20.*".
   430  	To string `json:"to,omitempty"`
   431  	// Automatic controls whether this update is executed automatically
   432  	// for the control plane of all matching user clusters.
   433  	// ---
   434  	//nolint:staticcheck
   435  	//lint:ignore SA5008 omitgenyaml is used by the example-yaml-generator
   436  	Automatic *bool `json:"automatic,omitempty,omitgenyaml"`
   437  	// Automatic controls whether this update is executed automatically
   438  	// for the worker nodes of all matching user clusters.
   439  	// ---
   440  	//nolint:staticcheck
   441  	//lint:ignore SA5008 omitgenyaml is used by the example-yaml-generator
   442  	AutomaticNodeUpdate *bool `json:"automaticNodeUpdate,omitempty,omitgenyaml"`
   443  }
   444  
   445  // Incompatibility represents a version incompatibility for a user cluster.
   446  type Incompatibility struct {
   447  	// Provider to which to apply the compatibility check. If this is not specified, the
   448  	// incompatibility is valid for all cloud providers.
   449  	Provider CloudProvider `json:"provider,omitempty"`
   450  	// Version is the Kubernetes version that must be checked. Wildcards are allowed, e.g. "1.25.*".
   451  	Version string `json:"version,omitempty"`
   452  	// Condition is the cluster or datacenter condition that must be met to block a specific version
   453  	Condition ConditionType `json:"condition,omitempty"`
   454  	// Operation is the operation triggering the compatibility check (CREATE or UPDATE)
   455  	Operation OperationType `json:"operation,omitempty"`
   456  }
   457  
   458  // KubermaticVPAConfiguration configures the Kubernetes VPA.
   459  type KubermaticVPAConfiguration struct {
   460  	Recommender         *KubermaticVPAComponent `json:"recommender,omitempty"`
   461  	Updater             *KubermaticVPAComponent `json:"updater,omitempty"`
   462  	AdmissionController *KubermaticVPAComponent `json:"admissionController,omitempty"`
   463  }
   464  
   465  type KubermaticVPAComponent struct {
   466  	// DockerRepository is the repository containing the component's image.
   467  	DockerRepository string `json:"dockerRepository,omitempty"`
   468  	// Resources describes the requested and maximum allowed CPU/memory usage.
   469  	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
   470  }
   471  
   472  // KubermaticProxyConfiguration can be used to control how the various
   473  // Kubermatic components reach external services / the Internet. These
   474  // settings are reflected as environment variables for the Kubermatic
   475  // pods.
   476  type KubermaticProxyConfiguration struct {
   477  	// HTTP is the full URL to the proxy to use for plaintext HTTP
   478  	// connections, e.g. "http://internalproxy.example.com:8080".
   479  	HTTP string `json:"http,omitempty"`
   480  	// HTTPS is the full URL to the proxy to use for encrypted HTTPS
   481  	// connections, e.g. "http://secureinternalproxy.example.com:8080".
   482  	HTTPS string `json:"https,omitempty"`
   483  	// NoProxy is a comma-separated list of hostnames / network masks
   484  	// for which no proxy shall be used. If you make use of proxies,
   485  	// this list should contain all local and cluster-internal domains
   486  	// and networks, e.g. "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,mydomain".
   487  	// The operator will always prepend the following elements to this
   488  	// list if proxying is configured (i.e. HTTP/HTTPS are not empty):
   489  	// "127.0.0.1/8", "localhost", ".local", ".local.", "kubernetes", ".default", ".svc"
   490  	NoProxy string `json:"noProxy,omitempty"`
   491  }
   492  
   493  // MeteringConfiguration contains all the configuration for the metering tool.
   494  type MeteringConfiguration struct {
   495  	Enabled bool `json:"enabled"`
   496  
   497  	// StorageClassName is the name of the storage class that the metering prometheus instance uses to store metric data for reporting.
   498  	StorageClassName string `json:"storageClassName"`
   499  	// StorageSize is the size of the storage class. Default value is 100Gi.
   500  	StorageSize string `json:"storageSize"`
   501  
   502  	// +kubebuilder:default:={weekly: {schedule: "0 1 * * 6", interval: 7}}
   503  
   504  	// ReportConfigurations is a map of report configuration definitions.
   505  	ReportConfigurations map[string]*MeteringReportConfiguration `json:"reports,omitempty"`
   506  }
   507  
   508  type MeteringReportConfiguration struct {
   509  	// +kubebuilder:default:=`0 1 * * 6`
   510  
   511  	// Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. Please take a note that Schedule is responsible
   512  	// only for setting the time when a report generation mechanism kicks off. The Interval MUST be set independently.
   513  	Schedule string `json:"schedule,omitempty"`
   514  
   515  	// +kubebuilder:default=7
   516  	// +kubebuilder:validation:Minimum:=1
   517  
   518  	// Interval defines the number of days consulted in the metering report.
   519  	Interval uint32 `json:"interval,omitempty"`
   520  
   521  	// +optional
   522  	// +kubebuilder:validation:Minimum:=1
   523  
   524  	// Retention defines a number of days after which reports are queued for removal. If not set, reports are kept forever.
   525  	// Please note that this functionality works only for object storage that supports an object lifecycle management mechanism.
   526  	Retention *uint32 `json:"retention,omitempty"`
   527  
   528  	// +optional
   529  	// +kubebuilder:default:={"cluster","namespace"}
   530  
   531  	// Types of reports to generate. Available report types are cluster and namespace. By default, all types of reports are generated.
   532  	Types []string `json:"type,omitempty"`
   533  }
   534  
   535  // EtcdBackupRestore holds the configuration of the automatic backup and restores.
   536  type EtcdBackupRestore struct {
   537  	// Destinations stores all the possible destinations where the backups for the Seed can be stored. If not empty,
   538  	// it enables automatic backup and restore for the seed.
   539  	Destinations map[string]*EtcdBackupDestination `json:"destinations,omitempty"`
   540  
   541  	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
   542  	// +kubebuilder:validation:MaxLength:=63
   543  	// +kubebuilder:validation:Type=string
   544  
   545  	// DefaultDestination marks the default destination that will be used for the default etcd backup config which is
   546  	// created for every user cluster. Has to correspond to a destination in Destinations.
   547  	// If removed, it removes the related default etcd backup configs.
   548  	DefaultDestination string `json:"defaultDestination,omitempty"`
   549  }
   550  
   551  // EtcdBackupDestination defines the bucket name and endpoint as a backup destination, and holds reference to the credentials secret.
   552  type EtcdBackupDestination struct {
   553  	// Endpoint is the API endpoint to use for backup and restore.
   554  	Endpoint string `json:"endpoint"`
   555  	// BucketName is the bucket name to use for backup and restore.
   556  	BucketName string `json:"bucketName"`
   557  	// Credentials hold the ref to the secret with backup credentials
   558  	Credentials *corev1.SecretReference `json:"credentials,omitempty"`
   559  }
   560  
   561  // IsEtcdAutomaticBackupEnabled returns true if etcd automatic backup is configured for the seed.
   562  func (c *KubermaticConfiguration) IsEtcdAutomaticBackupEnabled() bool {
   563  	if c.Spec.UserCluster == nil {
   564  		return false
   565  	}
   566  
   567  	if cfg := c.Spec.UserCluster.EtcdBackupRestore; cfg != nil {
   568  		return len(cfg.Destinations) > 0
   569  	}
   570  	return false
   571  }
   572  
   573  // IsDefaultEtcdAutomaticBackupEnabled returns true if etcd automatic backup with default destination is configured for the seed.
   574  func (c *KubermaticConfiguration) IsDefaultEtcdAutomaticBackupEnabled() bool {
   575  	return c.IsEtcdAutomaticBackupEnabled() && c.Spec.UserCluster.EtcdBackupRestore.DefaultDestination != ""
   576  }
   577  
   578  func (c *KubermaticConfiguration) GetEtcdBackupDestination(destinationName string) *EtcdBackupDestination {
   579  	if c.Spec.UserCluster == nil || c.Spec.UserCluster.EtcdBackupRestore == nil {
   580  		return nil
   581  	}
   582  
   583  	return c.Spec.UserCluster.EtcdBackupRestore.Destinations[destinationName]
   584  }
   585  
   586  type NodeportProxyConfig struct {
   587  	// Disable will prevent the Kubermatic Operator from creating a nodeport-proxy
   588  	// setup on the seed cluster. This should only be used if a suitable replacement
   589  	// is installed (like the nodeport-proxy Helm chart).
   590  	Disable bool `json:"disable,omitempty"`
   591  	// Annotations are used to further tweak the LoadBalancer integration with the
   592  	// cloud provider where the seed cluster is running.
   593  	// Deprecated: Use .envoy.loadBalancerService.annotations instead.
   594  	Annotations map[string]string `json:"annotations,omitempty"`
   595  	// Envoy configures the Envoy application itself.
   596  	Envoy *NodePortProxyComponentEnvoy `json:"envoy,omitempty"`
   597  	// EnvoyManager configures the Kubermatic-internal Envoy manager.
   598  	EnvoyManager *NodeportProxyComponent `json:"envoyManager,omitempty"`
   599  	// Updater configures the component responsible for updating the LoadBalancer
   600  	// service.
   601  	Updater *NodeportProxyComponent `json:"updater,omitempty"`
   602  }
   603  
   604  type EnvoyLoadBalancerService struct {
   605  	// Annotations are used to further tweak the LoadBalancer integration with the
   606  	// cloud provider.
   607  	Annotations map[string]string `json:"annotations,omitempty"`
   608  	// SourceRanges will restrict loadbalancer service to IP ranges specified using CIDR notation like 172.25.0.0/16.
   609  	// This field will be ignored if the cloud-provider does not support the feature.
   610  	// More info: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/
   611  	SourceRanges []CIDR `json:"sourceRanges,omitempty"`
   612  }
   613  
   614  type NodePortProxyComponentEnvoy struct {
   615  	NodeportProxyComponent `json:",inline"`
   616  	LoadBalancerService    *EnvoyLoadBalancerService `json:"loadBalancerService,omitempty"`
   617  }
   618  
   619  type NodeportProxyComponent struct {
   620  	// DockerRepository is the repository containing the component's image.
   621  	DockerRepository string `json:"dockerRepository,omitempty"`
   622  	// Resources describes the requested and maximum allowed CPU/memory usage.
   623  	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
   624  }
   625  
   626  // +kubebuilder:object:generate=true
   627  // +kubebuilder:object:root=true
   628  
   629  // KubermaticConfigurationList is a collection of KubermaticConfigurations.
   630  type KubermaticConfigurationList struct {
   631  	metav1.TypeMeta `json:",inline"`
   632  	metav1.ListMeta `json:"metadata,omitempty"`
   633  
   634  	Items []KubermaticConfiguration `json:"items"`
   635  }