Skip to content

Commit 843b413

Browse files
committed
chore: sync config/*.go and values.schema.json to vCluster version v0.23.2
1 parent f78e5d1 commit 843b413

File tree

7 files changed

+186
-538
lines changed

7 files changed

+186
-538
lines changed

config/config.go

Lines changed: 43 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ type Config struct {
7777

7878
// Plugin specifies which vCluster plugins to enable. Use "plugins" instead. Do not use this option anymore.
7979
Plugin map[string]Plugin `json:"plugin,omitempty"`
80-
81-
// SleepMode holds the native sleep mode configuration for Pro clusters
82-
SleepMode *SleepMode `json:"sleepMode,omitempty"`
8380
}
8481

8582
// Integrations holds config for vCluster integrations with other operators or tools running on the host cluster
@@ -90,19 +87,13 @@ type Integrations struct {
9087
// KubeVirt reuses a host kubevirt and makes certain CRDs from it available inside the vCluster
9188
KubeVirt KubeVirt `json:"kubeVirt,omitempty"`
9289

93-
// ExternalSecrets reuses a host external secret operator and makes certain CRDs from it available inside the vCluster.
94-
// - ExternalSecrets will be synced from the virtual cluster to the host cluster.
95-
// - SecretStores will be synced from the virtual cluster to the host cluster and then bi-directionally.
96-
// - ClusterSecretStores will be synced from the host cluster to the virtual cluster.
90+
// ExternalSecrets reuses a host external secret operator and makes certain CRDs from it available inside the vCluster
9791
ExternalSecrets ExternalSecrets `json:"externalSecrets,omitempty"`
9892

9993
// CertManager reuses a host cert-manager and makes its CRDs from it available inside the vCluster.
10094
// - Certificates and Issuers will be synced from the virtual cluster to the host cluster.
10195
// - ClusterIssuers will be synced from the host cluster to the virtual cluster.
10296
CertManager CertManager `json:"certManager,omitempty"`
103-
104-
// Istio syncs DestinationRules, Gateways and VirtualServices from virtual cluster to the host.
105-
Istio Istio `json:"istio,omitempty"`
10697
}
10798

10899
// CertManager reuses a host cert-manager and makes its CRDs from it available inside the vCluster
@@ -137,23 +128,6 @@ type ClusterIssuersSyncConfig struct {
137128
Selector LabelSelector `json:"selector,omitempty"`
138129
}
139130

140-
type Istio struct {
141-
EnableSwitch
142-
Sync IstioSync `json:"sync,omitempty"`
143-
}
144-
145-
type IstioSync struct {
146-
ToHost IstioSyncToHost `json:"toHost,omitempty"`
147-
}
148-
149-
type IstioSyncToHost struct {
150-
DestinationRules EnableSwitch `json:"destinationRules,omitempty"`
151-
152-
Gateways EnableSwitch `json:"gateways,omitempty"`
153-
154-
VirtualServices EnableSwitch `json:"virtualServices,omitempty"`
155-
}
156-
157131
// ExternalSecrets reuses a host external secret operator and makes certain CRDs from it available inside the vCluster
158132
type ExternalSecrets struct {
159133
// Enabled defines whether the external secret integration is enabled or not
@@ -165,11 +139,11 @@ type ExternalSecrets struct {
165139
}
166140

167141
type ExternalSecretsSync struct {
168-
// ExternalSecrets defines if external secrets should get synced from the virtual cluster to the host cluster.
142+
// ExternalSecrets defines whether to sync external secrets or not
169143
ExternalSecrets EnableSwitch `json:"externalSecrets,omitempty"`
170-
// Stores defines if secret stores should get synced from the virtual cluster to the host cluster and then bi-directionally.
144+
// Stores defines whether to sync stores or not
171145
Stores EnableSwitch `json:"stores,omitempty"`
172-
// ClusterStores defines if cluster secrets stores should get synced from the host cluster to the virtual cluster.
146+
// ClusterStores defines whether to sync cluster stores or not
173147
ClusterStores ClusterStoresSyncConfig `json:"clusterStores,omitempty"`
174148
}
175149

@@ -297,10 +271,8 @@ func (c *Config) BackingStoreType() StoreType {
297271
switch {
298272
case c.ControlPlane.BackingStore.Etcd.Embedded.Enabled:
299273
return StoreTypeEmbeddedEtcd
300-
case c.ControlPlane.BackingStore.Etcd.External.Enabled:
301-
return StoreTypeExternalEtcd
302274
case c.ControlPlane.BackingStore.Etcd.Deploy.Enabled:
303-
return StoreTypeDeployedEtcd
275+
return StoreTypeExternalEtcd
304276
case c.ControlPlane.BackingStore.Database.Embedded.Enabled:
305277
return StoreTypeEmbeddedDatabase
306278
case c.ControlPlane.BackingStore.Database.External.Enabled:
@@ -311,7 +283,7 @@ func (c *Config) BackingStoreType() StoreType {
311283
}
312284

313285
func (c *Config) EmbeddedDatabase() bool {
314-
return !c.ControlPlane.BackingStore.Database.External.Enabled && !c.ControlPlane.BackingStore.Etcd.Embedded.Enabled && !c.ControlPlane.BackingStore.Etcd.Deploy.Enabled && !c.ControlPlane.BackingStore.Etcd.External.Enabled
286+
return !c.ControlPlane.BackingStore.Database.External.Enabled && !c.ControlPlane.BackingStore.Etcd.Embedded.Enabled && !c.ControlPlane.BackingStore.Etcd.Deploy.Enabled
315287
}
316288

317289
func (c *Config) Distro() string {
@@ -345,15 +317,15 @@ func ValidateChanges(oldCfg, newCfg *Config) error {
345317

346318
// ValidateStoreAndDistroChanges checks whether migrating from one store to the other is allowed.
347319
func ValidateStoreAndDistroChanges(currentStoreType, previousStoreType StoreType, currentDistro, previousDistro string) error {
348-
if currentDistro != previousDistro && !(previousDistro == "eks" && currentDistro == K8SDistro) && !(previousDistro == K3SDistro && currentDistro == K8SDistro) {
320+
if currentDistro != previousDistro && !(previousDistro == "eks" && currentDistro == K8SDistro) {
349321
return fmt.Errorf("seems like you were using %s as a distro before and now have switched to %s, please make sure to not switch between vCluster distros", previousDistro, currentDistro)
350322
}
351323

352324
if currentStoreType != previousStoreType {
353-
if currentStoreType != StoreTypeDeployedEtcd && currentStoreType != StoreTypeEmbeddedEtcd {
325+
if currentStoreType != StoreTypeEmbeddedEtcd {
354326
return fmt.Errorf("seems like you were using %s as a store before and now have switched to %s, please make sure to not switch between vCluster stores", previousStoreType, currentStoreType)
355327
}
356-
if previousStoreType != StoreTypeExternalEtcd && previousStoreType != StoreTypeDeployedEtcd && previousStoreType != StoreTypeEmbeddedDatabase {
328+
if previousStoreType != StoreTypeExternalEtcd && previousStoreType != StoreTypeEmbeddedDatabase {
357329
return fmt.Errorf("seems like you were using %s as a store before and now have switched to %s, please make sure to not switch between vCluster stores", previousStoreType, currentStoreType)
358330
}
359331
}
@@ -428,41 +400,6 @@ func UnmarshalYAMLStrict(data []byte, i any) error {
428400

429401
// ExportKubeConfig describes how vCluster should export the vCluster kubeconfig.
430402
type ExportKubeConfig struct {
431-
ExportKubeConfigProperties
432-
433-
// Declare in which host cluster secret vCluster should store the generated virtual cluster kubeconfig.
434-
// If this is not defined, vCluster will create it with `vc-NAME`. If you specify another name,
435-
// vCluster creates the config in this other secret.
436-
//
437-
// Deprecated: Use AdditionalSecrets instead.
438-
Secret ExportKubeConfigSecretReference `json:"secret,omitempty"`
439-
440-
// AdditionalSecrets specifies the additional host cluster secrets in which vCluster will store the
441-
// generated virtual cluster kubeconfigs.
442-
AdditionalSecrets []ExportKubeConfigAdditionalSecretReference `json:"additionalSecrets,omitempty"`
443-
}
444-
445-
// GetAdditionalSecrets returns optional additional kubeconfig Secrets.
446-
//
447-
// If the deprecated Secret property is set, GetAdditionalSecrets only returns that secret, and
448-
// AdditionalSecrets is ignored. On the other hand, if the AdditionalSecrets property is set,
449-
// GetAdditionalSecrets returns the secrets config from the AdditionalSecrets, and Secret property
450-
// is ignored.
451-
func (e *ExportKubeConfig) GetAdditionalSecrets() []ExportKubeConfigAdditionalSecretReference {
452-
if e.Secret.IsSet() {
453-
return []ExportKubeConfigAdditionalSecretReference{
454-
{
455-
ExportKubeConfigProperties: e.ExportKubeConfigProperties,
456-
Namespace: e.Secret.Namespace,
457-
Name: e.Secret.Name,
458-
},
459-
}
460-
}
461-
462-
return e.AdditionalSecrets
463-
}
464-
465-
type ExportKubeConfigProperties struct {
466403
// Context is the name of the context within the generated kubeconfig to use.
467404
Context string `json:"context,omitempty"`
468405

@@ -474,6 +411,11 @@ type ExportKubeConfigProperties struct {
474411

475412
// ServiceAccount can be used to generate a service account token instead of the default certificates.
476413
ServiceAccount ExportKubeConfigServiceAccount `json:"serviceAccount,omitempty"`
414+
415+
// Declare in which host cluster secret vCluster should store the generated virtual cluster kubeconfig.
416+
// If this is not defined, vCluster will create it with `vc-NAME`. If you specify another name,
417+
// vCluster creates the config in this other secret.
418+
Secret ExportKubeConfigSecretReference `json:"secret,omitempty"`
477419
}
478420

479421
type ExportKubeConfigServiceAccount struct {
@@ -500,24 +442,6 @@ type ExportKubeConfigSecretReference struct {
500442
Namespace string `json:"namespace,omitempty"`
501443
}
502444

503-
// IsSet checks if at least one ExportKubeConfigSecretReference property is set.
504-
func (s *ExportKubeConfigSecretReference) IsSet() bool {
505-
return *s != (ExportKubeConfigSecretReference{})
506-
}
507-
508-
// ExportKubeConfigAdditionalSecretReference defines the additional host cluster secret in which
509-
// vCluster stores the generated virtual cluster kubeconfigs.
510-
type ExportKubeConfigAdditionalSecretReference struct {
511-
ExportKubeConfigProperties
512-
513-
// Name is the name of the secret where the kubeconfig is stored.
514-
Name string `json:"name,omitempty"`
515-
516-
// Namespace where vCluster stores the kubeconfig secret. If this is not equal to the namespace
517-
// where you deployed vCluster, you need to make sure vCluster has access to this other namespace.
518-
Namespace string `json:"namespace,omitempty"`
519-
}
520-
521445
type Sync struct {
522446
// Configure resources to sync from the virtual cluster to the host cluster.
523447
ToHost SyncToHost `json:"toHost,omitempty"`
@@ -1125,7 +1049,15 @@ type DistroK8s struct {
11251049
Enabled bool `json:"enabled,omitempty"`
11261050

11271051
// Version specifies k8s components (scheduler, kube-controller-manager & apiserver) version.
1128-
// It is a shortcut for controlPlane.distro.k8s.image.tag
1052+
// It is a shortcut for controlPlane.distro.k8s.apiServer.image.tag,
1053+
// controlPlane.distro.k8s.controllerManager.image.tag and
1054+
// controlPlane.distro.k8s.scheduler.image.tag
1055+
// If e.g. controlPlane.distro.k8s.version is set to v1.30.1 and
1056+
// controlPlane.distro.k8s.scheduler.image.tag
1057+
//(or controlPlane.distro.k8s.controllerManager.image.tag or controlPlane.distro.k8s.apiServer.image.tag)
1058+
// is set to v1.31.0,
1059+
// value from controlPlane.distro.k8s.(controlPlane-component).image.tag will be used
1060+
// (where controlPlane-component is apiServer, controllerManager and scheduler).
11291061
Version string `json:"version,omitempty"`
11301062

11311063
// APIServer holds configuration specific to starting the api server.
@@ -1152,12 +1084,6 @@ type DistroK0s struct {
11521084
}
11531085

11541086
type DistroCommon struct {
1155-
// Image is the distro image
1156-
Image Image `json:"image,omitempty"`
1157-
1158-
// ImagePullPolicy is the pull policy for the distro image
1159-
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
1160-
11611087
// Env are extra environment variables to use for the main container and NOT the init container.
11621088
Env []map[string]interface{} `json:"env,omitempty"`
11631089

@@ -1167,7 +1093,14 @@ type DistroCommon struct {
11671093
// Security options can be used for the distro init container
11681094
SecurityContext map[string]interface{} `json:"securityContext,omitempty"`
11691095
}
1096+
11701097
type DistroContainer struct {
1098+
// Image is the distro image
1099+
Image Image `json:"image,omitempty"`
1100+
1101+
// ImagePullPolicy is the pull policy for the distro image
1102+
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
1103+
11711104
// Command is the command to start the distro binary. This will override the existing command.
11721105
Command []string `json:"command,omitempty"`
11731106

@@ -1179,6 +1112,12 @@ type DistroContainerEnabled struct {
11791112
// Enabled signals this container should be enabled.
11801113
Enabled bool `json:"enabled,omitempty"`
11811114

1115+
// Image is the distro image
1116+
Image Image `json:"image,omitempty"`
1117+
1118+
// ImagePullPolicy is the pull policy for the distro image
1119+
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
1120+
11821121
// Command is the command to start the distro binary. This will override the existing command.
11831122
Command []string `json:"command,omitempty"`
11841123

@@ -1286,47 +1225,18 @@ type Etcd struct {
12861225

12871226
// Deploy defines to use an external etcd that is deployed by the helm chart
12881227
Deploy EtcdDeploy `json:"deploy,omitempty"`
1289-
1290-
// External defines to use a self-hosted external etcd that is not deployed by the helm chart
1291-
External EtcdExternal `json:"external,omitempty"`
12921228
}
12931229

12941230
func (e Etcd) JSONSchemaExtend(base *jsonschema.Schema) {
12951231
addProToJSONSchema(base, reflect.TypeOf(e))
12961232
}
12971233

1298-
type EtcdExternal struct {
1299-
// Enabled defines if the external etcd should be used.
1300-
Enabled bool `json:"enabled,omitempty"`
1301-
1302-
// Endpoint holds the endpoint of the external etcd server, e.g. my-example-service:2379
1303-
Endpoint string `json:"endpoint,omitempty"`
1304-
1305-
// TLS defines the tls configuration for the external etcd server
1306-
TLS EtcdExternalTLS `json:"tls,omitempty"`
1307-
}
1308-
1309-
// EtcdExternalTLS defines tls for external etcd server
1310-
type EtcdExternalTLS struct {
1311-
// CaFile is the path to the ca file
1312-
CaFile string `json:"caFile,omitempty"`
1313-
1314-
// CertFile is the path to the cert file
1315-
CertFile string `json:"certFile,omitempty"`
1316-
1317-
// KeyFile is the path to the key file
1318-
KeyFile string `json:"keyFile,omitempty"`
1319-
}
1320-
13211234
type EtcdEmbedded struct {
13221235
// Enabled defines if the embedded etcd should be used.
13231236
Enabled bool `json:"enabled,omitempty" product:"pro"`
13241237

13251238
// MigrateFromDeployedEtcd signals that vCluster should migrate from the deployed external etcd to embedded etcd.
13261239
MigrateFromDeployedEtcd bool `json:"migrateFromDeployedEtcd,omitempty"`
1327-
1328-
// SnapshotCount defines the number of snapshots to keep for the embedded etcd. Defaults to 10000 if less than 1.
1329-
SnapshotCount int `json:"snapshotCount,omitempty"`
13301240
}
13311241

13321242
func (e EtcdEmbedded) JSONSchemaExtend(base *jsonschema.Schema) {
@@ -1818,18 +1728,9 @@ type NetworkPolicy struct {
18181728
// Enabled defines if the network policy should be deployed by vCluster.
18191729
Enabled bool `json:"enabled,omitempty"`
18201730

1821-
// FallbackDNS is the fallback DNS server to use if the virtual cluster does not have a DNS server.
1822-
FallbackDNS string `json:"fallbackDns,omitempty"`
1823-
1824-
// OutgoingConnections are the outgoing connections options for the vCluster workloads.
1731+
FallbackDNS string `json:"fallbackDns,omitempty"`
18251732
OutgoingConnections OutgoingConnections `json:"outgoingConnections,omitempty"`
18261733

1827-
// ExtraControlPlaneRules are extra allowed rules for the vCluster control plane.
1828-
ExtraControlPlaneRules []map[string]interface{} `json:"extraControlPlaneRules,omitempty"`
1829-
1830-
// ExtraWorkloadRules are extra allowed rules for the vCluster workloads.
1831-
ExtraWorkloadRules []map[string]interface{} `json:"extraWorkloadRules,omitempty"`
1832-
18331734
LabelsAndAnnotations `json:",inline"`
18341735
}
18351736

@@ -2072,6 +1973,9 @@ type Experimental struct {
20721973
// DenyProxyRequests denies certain requests in the vCluster proxy.
20731974
DenyProxyRequests []DenyRule `json:"denyProxyRequests,omitempty" product:"pro"`
20741975

1976+
// SleepMode holds the native sleep mode configuration for Pro clusters
1977+
SleepMode *SleepMode `json:"sleepMode,omitempty"`
1978+
20751979
// ReuseNamespace allows reusing the same namespace to create multiple vClusters.
20761980
// This flag is deprecated, as this scenario will be removed entirely in upcoming releases.
20771981
ReuseNamespace bool `json:"reuseNamespace,omitempty"`
@@ -2500,8 +2404,6 @@ type SleepMode struct {
25002404
TimeZone string `json:"timeZone,omitempty"`
25012405
// AutoSleep holds autoSleep details
25022406
AutoSleep SleepModeAutoSleep `json:"autoSleep,omitempty"`
2503-
// AutoWakeup holds configuration for waking the vCluster on a schedule rather than waiting for some activity.
2504-
AutoWakeup AutoWakeup `json:"autoWakeup,omitempty"`
25052407
}
25062408

25072409
// SleepModeAutoSleep holds configuration for allowing a vCluster to sleep its workloads
@@ -2513,6 +2415,9 @@ type SleepModeAutoSleep struct {
25132415
// Schedule represents a cron schedule for when to sleep workloads
25142416
Schedule string `json:"schedule,omitempty"`
25152417

2418+
// Wakeup holds configuration for waking the vCluster on a schedule rather than waiting for some activity.
2419+
Wakeup AutoWakeup `json:"wakeup,omitempty"`
2420+
25162421
// Exclude holds configuration for labels that, if present, will prevent a workload from going to sleep
25172422
Exclude AutoSleepExclusion `json:"exclude,omitempty"`
25182423
}

config/config_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,15 @@ func TestIfDefaultImagesVersionsAreInSync(t *testing.T) {
415415
tplBytes, err := os.ReadFile(initContainersTplFilePath)
416416

417417
assert.NilError(t, err)
418-
assert.Equal(t, defaultConfig.ControlPlane.Distro.K8S.Image.Tag, defaultConfig.ControlPlane.Distro.K8S.Image.Tag)
419-
expectedDefaultTag := fmt.Sprintf("{{- $defaultTag := %q -}}", defaultConfig.ControlPlane.Distro.K8S.Image.Tag)
418+
assert.Equal(t, defaultConfig.ControlPlane.Distro.K8S.ControllerManager.Image.Tag, defaultConfig.ControlPlane.Distro.K8S.APIServer.Image.Tag)
419+
assert.Equal(t, defaultConfig.ControlPlane.Distro.K8S.ControllerManager.Image.Tag, defaultConfig.ControlPlane.Distro.K8S.Scheduler.Image.Tag)
420+
assert.Equal(t, defaultConfig.ControlPlane.Distro.K8S.APIServer.Image.Tag, defaultConfig.ControlPlane.Distro.K8S.Scheduler.Image.Tag)
421+
expectedDefaultTag := fmt.Sprintf("{{- $defaultTag := %q -}}", defaultConfig.ControlPlane.Distro.K8S.ControllerManager.Image.Tag)
420422
got := strings.Count(string(tplBytes), expectedDefaultTag)
421423
assert.Equal(
422-
t, got, 1,
424+
t, got, 3,
423425
fmt.Sprintf("please update $defaultTag in %s so it's equal to the "+
424-
".Values.controlPlane.distro.k8s.image.tag",
426+
".Values.controlPlane.distro.k8s.controllerManager.image.tag",
425427
initContainersTplFilePath),
426428
)
427429
}

0 commit comments

Comments
 (0)