Skip to content

Commit 0172bad

Browse files
committed
chore: sync config/*.go and values.schema.json to vCluster version v0.27.0-beta.3
1 parent bcb0968 commit 0172bad

File tree

243 files changed

+107
-55879
lines changed

Some content is hidden

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

243 files changed

+107
-55879
lines changed

config/config.go

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/invopop/jsonschema"
15+
yamlv3 "gopkg.in/yaml.v3"
1516
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1617
"k8s.io/apimachinery/pkg/labels"
1718
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -382,8 +383,9 @@ type AutoUpgrade struct {
382383
}
383384

384385
type Kubelet struct {
385-
// CgroupDriver defines the cgroup driver to use for the kubelet.
386-
CgroupDriver string `json:"cgroupDriver,omitempty"`
386+
// Config is the config for the kubelet that will be merged into the default kubelet config. More information can be found here:
387+
// https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/#kubelet-config-k8s-io-v1beta1-KubeletConfiguration
388+
Config map[string]interface{} `json:"config,omitempty"`
387389
}
388390

389391
type KubeProxy struct {
@@ -410,6 +412,10 @@ type KubeProxy struct {
410412

411413
// ExtraArgs are additional arguments to pass to the kube-proxy.
412414
ExtraArgs []string `json:"extraArgs,omitempty"`
415+
416+
// Config is the config for the kube-proxy that will be merged into the default kube-proxy config. More information can be found here:
417+
// https://kubernetes.io/docs/reference/config-api/kube-proxy-config.v1alpha1/#kubeproxy-config-k8s-io-v1alpha1-KubeProxyConfiguration
418+
Config map[string]interface{} `json:"config,omitempty"`
413419
}
414420

415421
type Konnectivity struct {
@@ -1668,7 +1674,7 @@ type DistroK8s struct {
16681674
// ControllerManager holds configuration specific to starting the controller manager.
16691675
ControllerManager DistroContainerEnabled `json:"controllerManager,omitempty"`
16701676

1671-
// Scheduler holds configuration specific to starting the scheduler. Enable this via controlPlane.advanced.virtualScheduler.enabled
1677+
// Scheduler holds configuration specific to starting the scheduler.
16721678
Scheduler DistroContainerEnabled `json:"scheduler,omitempty"`
16731679

16741680
DistroCommon `json:",inline"`
@@ -1721,7 +1727,44 @@ type Image struct {
17211727
Tag string `json:"tag,omitempty"`
17221728
}
17231729

1724-
func (i Image) String() (ref string) {
1730+
// UnmarshalJSON makes the schema change from string to Image backwards compatible
1731+
func (i *Image) UnmarshalJSON(data []byte) error {
1732+
var str string
1733+
if err := json.Unmarshal(data, &str); err == nil {
1734+
ParseImageRef(str, i)
1735+
return nil
1736+
}
1737+
1738+
type Alias Image
1739+
var aux Alias
1740+
if err := json.Unmarshal(data, &aux); err != nil {
1741+
return err
1742+
}
1743+
*i = Image(aux)
1744+
return nil
1745+
}
1746+
1747+
// UnmarshalYAML makes the schema change from string to Image backwards compatible
1748+
func (i *Image) UnmarshalYAML(node *yamlv3.Node) error {
1749+
if node.Kind == yamlv3.ScalarNode {
1750+
ParseImageRef(node.Value, i)
1751+
return nil
1752+
}
1753+
1754+
type Alias Image
1755+
var aux Alias
1756+
if err := node.Decode(&aux); err != nil {
1757+
return err
1758+
}
1759+
*i = Image(aux)
1760+
return nil
1761+
}
1762+
1763+
func (i *Image) String() (ref string) {
1764+
if i == nil {
1765+
return
1766+
}
1767+
17251768
if i.Registry != "" {
17261769
ref = i.Registry + "/"
17271770
}

config/config_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"gotest.tools/assert"
99
"gotest.tools/assert/cmp"
10+
"sigs.k8s.io/yaml"
1011
)
1112

1213
func TestConfig_Diff(t *testing.T) {
@@ -387,6 +388,46 @@ func TestConfig_IsProFeatureEnabled(t *testing.T) {
387388
}
388389
}
389390

391+
// We changed sync.toHost.pods.rewriteHosts.initContainer.image from a string to an object in 0.27.0.
392+
// We parse the previously used config on upgrade, so it must be backwards compatible.
393+
func TestImage_UnmarshalYAML(t *testing.T) {
394+
tests := []struct {
395+
name string
396+
yaml string
397+
expected Image
398+
}{
399+
{
400+
name: "image as object",
401+
yaml: `registry: registry:5000
402+
repository: some/repo
403+
tag: sometag`,
404+
expected: Image{
405+
Registry: "registry:5000",
406+
Repository: "some/repo",
407+
Tag: "sometag",
408+
},
409+
},
410+
{
411+
name: "image as string",
412+
yaml: "registry:5000/some/repo:sometag",
413+
expected: Image{
414+
Registry: "registry:5000",
415+
Repository: "some/repo",
416+
Tag: "sometag",
417+
},
418+
},
419+
}
420+
421+
for _, tt := range tests {
422+
t.Run(tt.name, func(t *testing.T) {
423+
var actual Image
424+
err := yaml.Unmarshal([]byte(tt.yaml), &actual)
425+
assert.NilError(t, err)
426+
assert.DeepEqual(t, actual, tt.expected)
427+
})
428+
}
429+
}
430+
390431
func TestImage_String(t *testing.T) {
391432
testCases := []struct {
392433
name string

config/experimental_helper.go

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ 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"
108
)
119

1210
type (
@@ -15,11 +13,7 @@ type (
1513
}
1614
)
1715

18-
var advisors = map[string]func() (warning string){
19-
"sleepMode": SleepModeWarning,
20-
}
21-
22-
func ExperimentalWarning(logger log.Logger, currentValues []byte) string {
16+
func ExperimentalWarning(logger log.Logger, currentValues []byte, advisors map[string]func() string) string {
2317
exp := &ExperimentalConfig{}
2418
if err := yaml.Unmarshal(currentValues, exp); err != nil {
2519
logger.Warn(err)
@@ -42,25 +36,3 @@ func ExperimentalWarning(logger log.Logger, currentValues []byte) string {
4236
expWarning := "An experimental feature you were using has been promoted! 🎉 See below on tips to update."
4337
return strings.Join(append([]string{expWarning}, advice...), "\n")
4438
}
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/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ controlPlane:
433433
privateNodes:
434434
enabled: false
435435
importNodeBinaries: true
436+
kubelet:
437+
config: {}
436438
autoUpgrade:
437439
enabled: true
438440
concurrency: 1
@@ -454,6 +456,7 @@ deploy:
454456
tolerations: []
455457
extraEnv: []
456458
extraArgs: []
459+
config: {}
457460
metallb:
458461
enabled: false
459462
ipAddressPool:

go.mod

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ require (
66
github.com/ghodss/yaml v1.0.0
77
github.com/invopop/jsonschema v0.12.0
88
github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac
9-
github.com/loft-sh/vcluster v0.23.0
109
github.com/xeipuuv/gojsonschema v1.2.0
11-
golang.org/x/mod v0.24.0
10+
gopkg.in/yaml.v3 v3.0.1
1211
gotest.tools v2.2.0+incompatible
1312
k8s.io/apimachinery v0.32.1
1413
sigs.k8s.io/controller-runtime v0.20.1
@@ -20,8 +19,8 @@ require (
2019
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
2120
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
2221
github.com/bahlo/generic-list-go v0.2.0 // indirect
23-
github.com/blang/semver v3.5.1+incompatible // indirect
2422
github.com/buger/jsonparser v1.1.1 // indirect
23+
github.com/creack/pty v1.1.21 // indirect
2524
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2625
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
2726
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
@@ -34,11 +33,8 @@ require (
3433
github.com/golang/protobuf v1.5.4 // indirect
3534
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
3635
github.com/google/go-cmp v0.6.0 // indirect
37-
github.com/google/go-github/v30 v30.1.0 // indirect
38-
github.com/google/go-querystring v1.1.0 // indirect
3936
github.com/google/gofuzz v1.2.0 // indirect
4037
github.com/google/uuid v1.6.0 // indirect
41-
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
4238
github.com/josharian/intern v1.0.0 // indirect
4339
github.com/json-iterator/go v1.1.12 // indirect
4440
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
@@ -52,15 +48,11 @@ require (
5248
github.com/modern-go/reflect2 v1.0.2 // indirect
5349
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5450
github.com/pkg/errors v0.9.1 // indirect
55-
github.com/rhysd/go-github-selfupdate v1.2.3 // indirect
5651
github.com/sirupsen/logrus v1.9.3 // indirect
57-
github.com/tcnksm/go-gitconfig v0.1.2 // indirect
58-
github.com/ulikunitz/xz v0.5.11 // indirect
5952
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
6053
github.com/x448/float16 v0.8.4 // indirect
6154
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
6255
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
63-
golang.org/x/crypto v0.32.0 // indirect
6456
golang.org/x/net v0.34.0 // indirect
6557
golang.org/x/oauth2 v0.23.0 // indirect
6658
golang.org/x/sys v0.29.0 // indirect
@@ -71,8 +63,8 @@ require (
7163
gopkg.in/inf.v0 v0.9.1 // indirect
7264
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
7365
gopkg.in/yaml.v2 v2.4.0 // indirect
74-
gopkg.in/yaml.v3 v3.0.1 // indirect
7566
k8s.io/api v0.32.1 // indirect
67+
k8s.io/apiextensions-apiserver v0.32.1 // indirect
7668
k8s.io/client-go v0.32.1 // indirect
7769
k8s.io/klog/v2 v2.130.1 // indirect
7870
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect

0 commit comments

Comments
 (0)