Skip to content

Commit 397242c

Browse files
committed
chore: sync config/*.go and values.schema.json to vCluster version v0.26.1-rc.2
1 parent 3827797 commit 397242c

File tree

1,821 files changed

+819014
-709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,821 files changed

+819014
-709
lines changed

config/config.go

Lines changed: 751 additions & 106 deletions
Large diffs are not rendered by default.

config/config_test.go

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package config
22

33
import (
44
_ "embed"
5-
"fmt"
6-
"os"
75
"strings"
86
"testing"
97

@@ -281,40 +279,6 @@ func TestConfig_IsProFeatureEnabled(t *testing.T) {
281279
},
282280
expected: true,
283281
},
284-
{
285-
name: "Pro Sync Settings not used",
286-
config: &Config{
287-
Experimental: Experimental{
288-
SyncSettings: ExperimentalSyncSettings{
289-
DisableSync: false,
290-
RewriteKubernetesService: false,
291-
},
292-
},
293-
},
294-
expected: false,
295-
},
296-
{
297-
name: "Pro Sync Setting disableSync used",
298-
config: &Config{
299-
Experimental: Experimental{
300-
SyncSettings: ExperimentalSyncSettings{
301-
DisableSync: true,
302-
},
303-
},
304-
},
305-
expected: true,
306-
},
307-
{
308-
name: "Pro Sync Setting rewriteKubernetesService used",
309-
config: &Config{
310-
Experimental: Experimental{
311-
SyncSettings: ExperimentalSyncSettings{
312-
RewriteKubernetesService: true,
313-
},
314-
},
315-
},
316-
expected: true,
317-
},
318282
{
319283
name: "Isolated Control Plane not used",
320284
config: &Config{
@@ -398,6 +362,21 @@ func TestConfig_IsProFeatureEnabled(t *testing.T) {
398362
},
399363
expected: true,
400364
},
365+
{
366+
name: "Hybrid scheduling is enabled",
367+
config: &Config{
368+
Sync: Sync{
369+
ToHost: SyncToHost{
370+
Pods: SyncPods{
371+
HybridScheduling: HybridScheduling{
372+
Enabled: true,
373+
},
374+
},
375+
},
376+
},
377+
},
378+
expected: true,
379+
},
401380
}
402381

403382
for _, tt := range tests {
@@ -406,24 +385,3 @@ func TestConfig_IsProFeatureEnabled(t *testing.T) {
406385
})
407386
}
408387
}
409-
410-
func TestIfDefaultImagesVersionsAreInSync(t *testing.T) {
411-
defaultConfig, err := NewDefaultConfig()
412-
assert.NilError(t, err)
413-
// this will fail when this test is moved or _init-containers.tpl is moved
414-
initContainersTplFilePath := "../chart/templates/_init-containers.tpl"
415-
tplBytes, err := os.ReadFile(initContainersTplFilePath)
416-
417-
assert.NilError(t, err)
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)
422-
got := strings.Count(string(tplBytes), expectedDefaultTag)
423-
assert.Equal(
424-
t, got, 3,
425-
fmt.Sprintf("please update $defaultTag in %s so it's equal to the "+
426-
".Values.controlPlane.distro.k8s.controllerManager.image.tag",
427-
initContainersTplFilePath),
428-
)
429-
}

config/default_extra_values.go

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
const (
99
K3SDistro = "k3s"
1010
K8SDistro = "k8s"
11-
K0SDistro = "k0s"
1211
Unknown = "unknown"
1312
)
1413

@@ -17,6 +16,7 @@ type StoreType string
1716
const (
1817
StoreTypeEmbeddedEtcd StoreType = "embedded-etcd"
1918
StoreTypeExternalEtcd StoreType = "external-etcd"
19+
StoreTypeDeployedEtcd StoreType = "deployed-etcd"
2020
StoreTypeEmbeddedDatabase StoreType = "embedded-database"
2121
StoreTypeExternalDatabase StoreType = "external-database"
2222
)
@@ -26,59 +26,20 @@ var K3SVersionMap = map[string]string{
2626
"1.32": "rancher/k3s:v1.32.1-k3s1",
2727
"1.31": "rancher/k3s:v1.31.1-k3s1",
2828
"1.30": "rancher/k3s:v1.30.2-k3s1",
29-
"1.29": "rancher/k3s:v1.29.6-k3s1",
30-
"1.28": "rancher/k3s:v1.28.11-k3s1",
31-
"1.27": "rancher/k3s:v1.27.16-k3s1",
3229
}
3330

34-
// K0SVersionMap holds the supported k0s versions
35-
var K0SVersionMap = map[string]string{
36-
"1.32": "k0sproject/k0s:v1.30.2-k0s.0",
37-
"1.31": "k0sproject/k0s:v1.30.2-k0s.0",
38-
"1.30": "k0sproject/k0s:v1.30.2-k0s.0",
39-
"1.29": "k0sproject/k0s:v1.29.6-k0s.0",
40-
"1.28": "k0sproject/k0s:v1.28.11-k0s.0",
41-
"1.27": "k0sproject/k0s:v1.27.16-k0s.0",
42-
}
43-
44-
// K8SAPIVersionMap holds the supported k8s api servers
45-
var K8SAPIVersionMap = map[string]string{
46-
"1.32": "registry.k8s.io/kube-apiserver:v1.32.1",
47-
"1.31": "registry.k8s.io/kube-apiserver:v1.31.1",
48-
"1.30": "registry.k8s.io/kube-apiserver:v1.30.2",
49-
"1.29": "registry.k8s.io/kube-apiserver:v1.29.6",
50-
"1.28": "registry.k8s.io/kube-apiserver:v1.28.11",
51-
"1.27": "registry.k8s.io/kube-apiserver:v1.27.16",
52-
}
53-
54-
// K8SControllerVersionMap holds the supported k8s controller managers
55-
var K8SControllerVersionMap = map[string]string{
56-
"1.32": "registry.k8s.io/kube-controller-manager:v1.32.1",
57-
"1.31": "registry.k8s.io/kube-controller-manager:v1.31.1",
58-
"1.30": "registry.k8s.io/kube-controller-manager:v1.30.2",
59-
"1.29": "registry.k8s.io/kube-controller-manager:v1.29.6",
60-
"1.28": "registry.k8s.io/kube-controller-manager:v1.28.11",
61-
"1.27": "registry.k8s.io/kube-controller-manager:v1.27.16",
62-
}
63-
64-
// K8SSchedulerVersionMap holds the supported k8s schedulers
65-
var K8SSchedulerVersionMap = map[string]string{
66-
"1.32": "registry.k8s.io/kube-scheduler:v1.32.1",
67-
"1.31": "registry.k8s.io/kube-scheduler:v1.31.1",
68-
"1.30": "registry.k8s.io/kube-scheduler:v1.30.2",
69-
"1.29": "registry.k8s.io/kube-scheduler:v1.29.6",
70-
"1.28": "registry.k8s.io/kube-scheduler:v1.28.11",
71-
"1.27": "registry.k8s.io/kube-scheduler:v1.27.16",
31+
// K8SVersionMap holds the supported k8s api servers
32+
var K8SVersionMap = map[string]string{
33+
"1.32": "ghcr.io/loft-sh/kubernetes:v1.32.1",
34+
"1.31": "ghcr.io/loft-sh/kubernetes:v1.31.1",
35+
"1.30": "ghcr.io/loft-sh/kubernetes:v1.30.2",
7236
}
7337

7438
// K8SEtcdVersionMap holds the supported etcd
7539
var K8SEtcdVersionMap = map[string]string{
76-
"1.32": "registry.k8s.io/etcd:3.5.17-0",
40+
"1.32": "registry.k8s.io/etcd:3.5.21-0",
7741
"1.31": "registry.k8s.io/etcd:3.5.15-0",
7842
"1.30": "registry.k8s.io/etcd:3.5.13-0",
79-
"1.29": "registry.k8s.io/etcd:3.5.10-0",
80-
"1.28": "registry.k8s.io/etcd:3.5.9-0",
81-
"1.27": "registry.k8s.io/etcd:3.5.7-0",
8243
}
8344

8445
// ExtraValuesOptions holds the chart options
@@ -176,8 +137,6 @@ func addCommonReleaseValues(config *Config, options *ExtraValuesOptions) {
176137
switch options.Distro {
177138
case K3SDistro:
178139
config.ControlPlane.Distro.K3S.Enabled = true
179-
case K0SDistro:
180-
config.ControlPlane.Distro.K0S.Enabled = true
181140
case K8SDistro:
182141
}
183142
}

config/diff.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"reflect"
77
"strconv"
8+
"strings"
89

910
"sigs.k8s.io/yaml"
1011
)
@@ -166,3 +167,10 @@ func (f *StrBool) MarshalJSON() ([]byte, error) {
166167
return []byte("\"" + *f + "\""), nil
167168
}
168169
}
170+
171+
func (f *StrBool) Bool() bool {
172+
if f == nil {
173+
return false
174+
}
175+
return strings.ToLower(string(*f)) == "true"
176+
}

config/experimental_helper.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55

66
"github.com/ghodss/yaml"
77
"github.com/loft-sh/log"
8+
"github.com/loft-sh/vcluster/pkg/upgrade"
9+
"golang.org/x/mod/semver"
810
)
911

1012
type (
@@ -13,7 +15,11 @@ type (
1315
}
1416
)
1517

16-
func ExperimentalWarning(logger log.Logger, currentValues []byte, advisors map[string]func() string) string {
18+
var advisors = map[string]func() (warning string){
19+
"sleepMode": SleepModeWarning,
20+
}
21+
22+
func ExperimentalWarning(logger log.Logger, currentValues []byte) string {
1723
exp := &ExperimentalConfig{}
1824
if err := yaml.Unmarshal(currentValues, exp); err != nil {
1925
logger.Warn(err)
@@ -36,3 +42,25 @@ func ExperimentalWarning(logger log.Logger, currentValues []byte, advisors map[s
3642
expWarning := "An experimental feature you were using has been promoted! 🎉 See below on tips to update."
3743
return strings.Join(append([]string{expWarning}, advice...), "\n")
3844
}
45+
46+
const v24 = "v0.24.0-alpha.0"
47+
48+
func SleepModeWarning() string {
49+
// if we're not upgrading to v0.24+ no warning
50+
if semver.Compare("v"+upgrade.GetVersion(), v24) == -1 {
51+
return ""
52+
}
53+
54+
return `
55+
sleepMode configuration is no longer under experimental. Please update your values and specify them with --values.
56+
57+
For example
58+
59+
|experimental: |sleepMode:
60+
| sleepMode: | enabled: true
61+
| enabled: true ----> | autoSleep:
62+
| autoSleep: | afterInactivity: 24h
63+
| afterInactivity: 24h |
64+
65+
`
66+
}

config/legacyconfig/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/loft-sh/vcluster-config/config"
55
)
66

7-
type LegacyK0sAndK3s struct {
7+
type LegacyK3s struct {
88
BaseHelm
99
AutoDeletePersistentVolumeClaims bool `json:"autoDeletePersistentVolumeClaims,omitempty"`
1010
K3sToken string `json:"k3sToken,omitempty"`
@@ -14,7 +14,7 @@ type LegacyK0sAndK3s struct {
1414
Storage Storage `json:"storage,omitempty"`
1515
}
1616

17-
func (c *LegacyK0sAndK3s) UnmarshalYAMLStrict(data []byte) error {
17+
func (c *LegacyK3s) UnmarshalYAMLStrict(data []byte) error {
1818
return config.UnmarshalYAMLStrict(data, c)
1919
}
2020

config/legacyconfig/config_test.go

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,6 @@ import (
44
"testing"
55
)
66

7-
func TestLegacyK0sAndK3s_UnmarshalYAMLStrict(t *testing.T) {
8-
type args struct {
9-
data []byte
10-
}
11-
tests := []struct {
12-
name string
13-
args args
14-
wantErr bool
15-
}{
16-
{
17-
name: "Valid: k3s",
18-
args: args{
19-
data: []byte(`
20-
sync:
21-
nodes:
22-
enabled: true
23-
telemetry:
24-
disabled: false
25-
`),
26-
},
27-
wantErr: false,
28-
},
29-
{
30-
name: "Invalid: k8s",
31-
args: args{
32-
data: []byte(`
33-
api:
34-
image: registry.k8s.io/kube-apiserver:v1.29.0
35-
controller:
36-
image: registry.k8s.io/kube-controller-manager:v1.29.0
37-
etcd:
38-
image: registry.k8s.io/etcd:3.5.10-0
39-
scheduler:
40-
image: registry.k8s.io/kube-scheduler:v1.29.0
41-
service:
42-
type: NodePort
43-
serviceCIDR: 10.96.0.0/16
44-
sync:
45-
nodes:
46-
enabled: true
47-
telemetry:
48-
disabled: false
49-
`),
50-
},
51-
wantErr: true,
52-
},
53-
}
54-
for _, tt := range tests {
55-
t.Run(tt.name, func(t *testing.T) {
56-
c := &LegacyK0sAndK3s{}
57-
if err := c.UnmarshalYAMLStrict(tt.args.data); (err != nil) != tt.wantErr {
58-
t.Errorf("LegacyK0sAndK3s.UnmarshalYAMLStrict() error = %v, wantErr %v", err, tt.wantErr)
59-
}
60-
})
61-
}
62-
}
63-
647
func TestLegacyK8s_UnmarshalYAMLStrict(t *testing.T) {
658
type args struct {
669
data []byte
@@ -131,14 +74,14 @@ telemetry:
13174
wantErr: true,
13275
},
13376
{
134-
name: "Invalid: k0s",
77+
name: "Invalid: k3s",
13578
args: args{
13679
data: []byte(`
13780
sync:
13881
nodes:
13982
enabled: true
14083
vcluster:
141-
image: k0sproject/k0s:v1.29.1-k0s.0
84+
image: k3sproject/k3s:v1.29.1-k3s.0
14285
telemetry:
14386
disabled: false
14487
`),

0 commit comments

Comments
 (0)