Skip to content

Commit

Permalink
Only set ETCD capacity and storage class initially. (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Apr 15, 2024
1 parent e66a8c4 commit 9f84afd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type AuditToSplunk struct {
HECCAFile string
}

// StorageConfiguration contains the configuration for provider specfic storage solutions.
// StorageConfiguration contains the configuration for provider specific storage solutions.
type StorageConfiguration struct {
// Duros contains the configuration for duros cloud storage
Duros DurosConfiguration
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/config/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ type AuditToSplunk struct {
HECCAFile string `json:"hecCAFile"`
}

// StorageConfiguration contains the configuration for provider specfic storage solutions.
// StorageConfiguration contains the configuration for provider specific storage solutions.
type StorageConfiguration struct {
// Duros contains the configuration for duros cloud storage
Duros DurosConfiguration `json:"duros"`
Expand Down
35 changes: 24 additions & 11 deletions pkg/webhook/controlplaneexposure/ensurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/gardener/gardener/extensions/pkg/webhook/controlplane/genericmutator"
"github.com/go-logr/logr"
"github.com/metal-stack/gardener-extension-provider-metal/pkg/apis/config"
"github.com/metal-stack/metal-lib/pkg/pointer"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -68,30 +69,42 @@ func (e *ensurer) EnsureKubeAPIServerDeployment(ctx context.Context, gctx gconte

// EnsureETCD ensures that the etcd conform to the provider requirements.
func (e *ensurer) EnsureETCD(ctx context.Context, gctx gcontext.GardenContext, new, old *druidv1alpha1.Etcd) error {
capacity := resource.MustParse("16Gi")
class := ""
new.Spec.StorageCapacity = pointer.Pointer(resource.MustParse("16Gi"))

if new.Name == v1beta1constants.ETCDMain && e.c != nil {
if e.c.Storage.Capacity != nil {
capacity = *e.c.Storage.Capacity
}
if e.c.Storage.ClassName != nil {
class = *e.c.Storage.ClassName
if e.c == nil {
return nil
}

if new.Name == v1beta1constants.ETCDMain {
if old == nil {
// capacity and storage class can only be set on initial deployment
// after that the stateful set prevents the update.

if e.c.Storage.Capacity != nil {
new.Spec.StorageCapacity = e.c.Storage.Capacity
}
if e.c.Storage.ClassName != nil {
new.Spec.StorageClass = e.c.Storage.ClassName
}
} else {
// ensure values stay as the were

new.Spec.StorageCapacity = old.Spec.StorageCapacity
new.Spec.StorageClass = old.Spec.StorageClass
}

if e.c.Backup.DeltaSnapshotPeriod != nil {
d, err := time.ParseDuration(*e.c.Backup.DeltaSnapshotPeriod)
if err != nil {
return fmt.Errorf("unable to set delta snapshot period %w", err)
}
new.Spec.Backup.DeltaSnapshotPeriod = &v1.Duration{Duration: d}
}

if e.c.Backup.Schedule != nil {
new.Spec.Backup.FullSnapshotSchedule = e.c.Backup.Schedule
}
}

new.Spec.StorageClass = &class
new.Spec.StorageCapacity = &capacity

return nil
}

0 comments on commit 9f84afd

Please sign in to comment.