Skip to content

Commit

Permalink
chore: sync vCluster config
Browse files Browse the repository at this point in the history
  • Loading branch information
loft-bot committed Jul 23, 2024
1 parent 8f0c5cc commit 0541349
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 149 deletions.
7 changes: 1 addition & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ func (c *Config) Distro() string {
return K0SDistro
} else if c.ControlPlane.Distro.K8S.Enabled {
return K8SDistro
} else if c.ControlPlane.Distro.EKS.Enabled {
return EKSDistro
}

return K8SDistro
Expand Down Expand Up @@ -259,7 +257,7 @@ func (c *Config) IsProFeatureEnabled() bool {
return true
}

if c.Distro() == K8SDistro || c.Distro() == EKSDistro {
if c.Distro() == K8SDistro {
if c.ControlPlane.BackingStore.Database.External.Enabled {
return true
}
Expand Down Expand Up @@ -754,9 +752,6 @@ type Distro struct {

// K0S holds k0s relevant configuration.
K0S DistroK0s `json:"k0s,omitempty"`

// EKS holds eks relevant configuration.
EKS DistroK8s `json:"eks,omitempty"`
}

type DistroK3s struct {
Expand Down
66 changes: 0 additions & 66 deletions config/default_extra_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const (
K3SDistro = "k3s"
K8SDistro = "k8s"
K0SDistro = "k0s"
EKSDistro = "eks"
Unknown = "unknown"
)

Expand Down Expand Up @@ -72,30 +71,6 @@ var K8SEtcdVersionMap = map[string]string{
"1.27": "registry.k8s.io/etcd:3.5.7-0",
}

// EKSAPIVersionMap holds the supported eks api servers
var EKSAPIVersionMap = map[string]string{
"1.28": "public.ecr.aws/eks-distro/kubernetes/kube-apiserver:v1.28.2-eks-1-28-6",
"1.27": "public.ecr.aws/eks-distro/kubernetes/kube-apiserver:v1.27.6-eks-1-27-13",
"1.26": "public.ecr.aws/eks-distro/kubernetes/kube-apiserver:v1.26.9-eks-1-26-19",
"1.25": "public.ecr.aws/eks-distro/kubernetes/kube-apiserver:v1.25.14-eks-1-25-23",
}

// EKSControllerVersionMap holds the supported eks controller managers
var EKSControllerVersionMap = map[string]string{
"1.28": "public.ecr.aws/eks-distro/kubernetes/kube-controller-manager:v1.28.2-eks-1-28-6",
"1.27": "public.ecr.aws/eks-distro/kubernetes/kube-controller-manager:v1.27.6-eks-1-27-13",
"1.26": "public.ecr.aws/eks-distro/kubernetes/kube-controller-manager:v1.26.9-eks-1-26-19",
"1.25": "public.ecr.aws/eks-distro/kubernetes/kube-controller-manager:v1.25.14-eks-1-25-23",
}

// EKSSchedulerVersionMap holds the supported eks controller managers
var EKSSchedulerVersionMap = map[string]string{
"1.28": "public.ecr.aws/eks-distro/kubernetes/kube-scheduler:v1.28.2-eks-1-28-6",
"1.27": "public.ecr.aws/eks-distro/kubernetes/kube-scheduler:v1.27.6-eks-1-27-13",
"1.26": "public.ecr.aws/eks-distro/kubernetes/kube-scheduler:v1.26.9-eks-1-26-19",
"1.25": "public.ecr.aws/eks-distro/kubernetes/kube-scheduler:v1.25.14-eks-1-25-23",
}

// ExtraValuesOptions holds the chart options
type ExtraValuesOptions struct {
Distro string
Expand Down Expand Up @@ -155,12 +130,6 @@ func getExtraValues(options *ExtraValuesOptions) (*Config, error) {
return nil, err
}

// apply eks values
err = applyEKSExtraValues(vConfig, options)
if err != nil {
return nil, err
}

// add common release values
addCommonReleaseValues(vConfig, options)
return vConfig, nil
Expand Down Expand Up @@ -198,39 +167,6 @@ func applyK0SExtraValues(vConfig *Config, options *ExtraValuesOptions) error {
return nil
}

func applyEKSExtraValues(vConfig *Config, options *ExtraValuesOptions) error {
// get api server image
apiImage, err := getImageByVersion(options.KubernetesVersion, EKSAPIVersionMap)
if err != nil {
return err
}

// get controller image
controllerImage, err := getImageByVersion(options.KubernetesVersion, EKSControllerVersionMap)
if err != nil {
return err
}

// get scheduler image
schedulerImage, err := getImageByVersion(options.KubernetesVersion, EKSSchedulerVersionMap)
if err != nil {
return err
}

// build values
if apiImage != "" {
vConfig.ControlPlane.Distro.EKS.APIServer.Image = parseImage(apiImage)
}
if controllerImage != "" {
vConfig.ControlPlane.Distro.EKS.ControllerManager.Image = parseImage(controllerImage)
}
if schedulerImage != "" {
vConfig.ControlPlane.Distro.EKS.Scheduler.Image = parseImage(schedulerImage)
}

return nil
}

func applyK8SExtraValues(vConfig *Config, options *ExtraValuesOptions) error {
// get api server image
apiImage, err := getImageByVersion(options.KubernetesVersion, K8SAPIVersionMap)
Expand Down Expand Up @@ -386,8 +322,6 @@ func addCommonReleaseValues(config *Config, options *ExtraValuesOptions) {
config.ControlPlane.Distro.K3S.Enabled = true
case K0SDistro:
config.ControlPlane.Distro.K0S.Enabled = true
case EKSDistro:
config.ControlPlane.Distro.EKS.Enabled = true
case K8SDistro:
}
}
Expand Down
11 changes: 5 additions & 6 deletions config/legacyconfig/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ func MigrateLegacyConfig(distro, oldValues string) (string, error) {
if err != nil {
return "", fmt.Errorf("migrate legacy %s values: %w", distro, err)
}
case config.K8SDistro, config.EKSDistro:
case config.K8SDistro:
err = migrateK8sAndEKS(distro, oldValues, toConfig)
if err != nil {
return "", fmt.Errorf("migrate legacy %s values: %w", distro, err)
}
default:
if distro == "eks" {
return "", fmt.Errorf("eks distro is not supported anymore. Instead use the k8s distro with the eks images")
}

return "", fmt.Errorf("migrating distro %s is not supported", distro)
}

Expand All @@ -52,11 +56,6 @@ func migrateK8sAndEKS(distro, oldValues string, newConfig *config.Config) error
convertAPIValues(oldConfig.API, &newConfig.ControlPlane.Distro.K8S.APIServer)
convertControllerValues(oldConfig.Controller, &newConfig.ControlPlane.Distro.K8S.ControllerManager)
convertSchedulerValues(oldConfig.Scheduler, &newConfig.ControlPlane.Distro.K8S.Scheduler)
} else if distro == config.EKSDistro {
newConfig.ControlPlane.Distro.EKS.Enabled = true
convertAPIValues(oldConfig.API, &newConfig.ControlPlane.Distro.EKS.APIServer)
convertControllerValues(oldConfig.Controller, &newConfig.ControlPlane.Distro.EKS.ControllerManager)
convertSchedulerValues(oldConfig.Scheduler, &newConfig.ControlPlane.Distro.EKS.Scheduler)
}

// convert etcd
Expand Down
31 changes: 3 additions & 28 deletions config/legacyconfig/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,6 @@ plugin:
statefulSet:
scheduling:
podManagementPolicy: OrderedReady
sync:
fromHost:
ingressClasses:
enabled: true
toHost:
ingresses:
enabled: true`,
},
{
Name: "Simple eks",
Distro: "eks",
In: `sync:
ingresses:
enabled: true`,
Expected: `controlPlane:
backingStore:
etcd:
deploy:
enabled: true
distro:
eks:
enabled: true
statefulSet:
scheduling:
podManagementPolicy: OrderedReady
sync:
fromHost:
ingressClasses:
Expand Down Expand Up @@ -395,9 +370,9 @@ syncer:
{
Name: "binariesVolume",
Distro: "k3s",
In: `syncer:
storage:
binariesVolume:
In: `syncer:
storage:
binariesVolume:
- name: binaries
persistentVolumeClaim:
claimName: my-pvc`,
Expand Down
40 changes: 1 addition & 39 deletions config/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ controlPlane:
image:
registry: registry.k8s.io
repository: "kube-scheduler"
tag: "v1.29.0"
tag: "v1.30.2"
env: []
securityContext: {}
resources:
Expand Down Expand Up @@ -146,44 +146,6 @@ controlPlane:
cpu: 40m
memory: 64Mi

eks:
enabled: false
apiServer:
enabled: true
command: []
extraArgs: []
imagePullPolicy: ""
image:
registry: "public.ecr.aws"
repository: "eks-distro/kubernetes/kube-apiserver"
tag: "v1.28.2-eks-1-28-6"
controllerManager:
enabled: true
command: []
extraArgs: []
imagePullPolicy: ""
image:
registry: "public.ecr.aws"
repository: "eks-distro/kubernetes/kube-controller-manager"
tag: "v1.28.2-eks-1-28-6"
scheduler:
command: []
extraArgs: []
imagePullPolicy: ""
image:
registry: "public.ecr.aws"
repository: "eks-distro/kubernetes/kube-scheduler"
tag: "v1.28.2-eks-1-28-6"
env: []
securityContext: {}
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 40m
memory: 64Mi

backingStore:
database:
embedded:
Expand Down
4 changes: 0 additions & 4 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,6 @@
"k0s": {
"$ref": "#/$defs/DistroK0s",
"description": "K0S holds k0s relevant configuration."
},
"eks": {
"$ref": "#/$defs/DistroK8s",
"description": "EKS holds eks relevant configuration."
}
},
"additionalProperties": false,
Expand Down

0 comments on commit 0541349

Please sign in to comment.