Skip to content

Commit

Permalink
Revert enabling overlay as default networking setup (#568)
Browse files Browse the repository at this point in the history
* Revert "fix values.yaml (#560)"

This reverts commit 67188b6.

* Revert "Automated cherry pick of #517 upstream release v1.31 (#558)"

This reverts commit 1ed4a63.
  • Loading branch information
kon-angelo authored Feb 8, 2023
1 parent d248743 commit 39cbdc3
Show file tree
Hide file tree
Showing 30 changed files with 70 additions and 2,251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ spec:
- --metrics-bind-address=:{{ .Values.global.metricsPort }}
{{- end }}
- --health-bind-address=:{{ .Values.global.healthPort }}
- --enable-overlay-as-default-for-calico={{ .Values.global.enableOverlayAsDefaultForCalico }}
- --enable-overlay-as-default-for-cilium={{ .Values.global.enableOverlayAsDefaultForCilium }}
livenessProbe:
httpGet:
path: /healthz
Expand Down
3 changes: 0 additions & 3 deletions charts/gardener-extension-admission-openstack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ global:
memory: 64Mi
updatePolicy:
updateMode: "Auto"
enableOverlayAsDefaultForCalico: true
enableOverlayAsDefaultForCilium: true
webhookConfig:
caBundle: |
-----BEGIN CERTIFICATE-----
Expand All @@ -38,7 +36,6 @@ global:
-----END RSA PRIVATE KEY-----
# Please make sure you are running `[email protected]` or later before setting this to true.
useObjectSelector: false

# Kubeconfig to the target cluster. In-cluster configuration will be used if not specified.
kubeconfig:

Expand Down
10 changes: 0 additions & 10 deletions cmd/gardener-extension-admission-openstack/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"

admissioncmd "github.com/gardener/gardener-extension-provider-openstack/pkg/admission/cmd"
"github.com/gardener/gardener-extension-provider-openstack/pkg/admission/mutator"
openstackinstall "github.com/gardener/gardener-extension-provider-openstack/pkg/apis/openstack/install"
provideropenstack "github.com/gardener/gardener-extension-provider-openstack/pkg/openstack"

Expand Down Expand Up @@ -56,9 +55,6 @@ func NewAdmissionCommand(ctx context.Context) *cobra.Command {
mgrOpts,
webhookOptions,
)

enableOverlayAsDefaultForCalico bool
enableOverlayAsDefaultForCilium bool
)

cmd := &cobra.Command{
Expand Down Expand Up @@ -104,16 +100,10 @@ func NewAdmissionCommand(ctx context.Context) *cobra.Command {
return fmt.Errorf("could not add readycheck of webhook to manager: %w", err)
}

mutator.EnableOverlayAsDefaultForCalico = enableOverlayAsDefaultForCalico
mutator.EnableOverlayAsDefaultForCilium = enableOverlayAsDefaultForCilium

return mgr.Start(ctx)
},
}

cmd.Flags().BoolVar(&enableOverlayAsDefaultForCalico, "enable-overlay-as-default-for-calico", true, "enables network overlay for all new calico shoot clusters")
cmd.Flags().BoolVar(&enableOverlayAsDefaultForCilium, "enable-overlay-as-default-for-cilium", true, "enables network overlay for all new cilium shoot clusters")

verflag.AddFlags(cmd.Flags())
aggOption.AddFlags(cmd.Flags())

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2
github.com/gardener/etcd-druid v0.12.3
github.com/gardener/gardener v1.59.0
github.com/gardener/gardener-extension-networking-calico v1.28.0
github.com/gardener/gardener-extension-networking-cilium v1.20.0
github.com/gardener/gardener-extension-networking-calico v1.27.1
github.com/gardener/machine-controller-manager v0.45.0
github.com/go-logr/logr v1.2.3
github.com/golang/mock v1.6.0
Expand Down Expand Up @@ -46,6 +45,7 @@ require (
github.com/cyphar/filepath-securejoin v0.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
Expand Down Expand Up @@ -76,6 +76,7 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kubernetes-csi/external-snapshotter/v2 v2.1.4 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
Expand All @@ -100,7 +101,6 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdf
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484 h1:pEtiCjIXx3RvGjlUJuCNxNOw0MNblyR9Wi+vJGBFh+8=
github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful/v3 v3.8.0 h1:eCZ8ulSerjdAiaNpF7GxXIE7ZCMo1moN1qX+S609eVw=
Expand Down Expand Up @@ -161,10 +163,8 @@ github.com/gardener/etcd-druid v0.12.3 h1:FBpsEe+FrBwJ1a2VhaPlXjZsfIAcHGSsF5DvDO
github.com/gardener/etcd-druid v0.12.3/go.mod h1:EJF6z4Ghv2FGUe1UzZWOEF1MxCA186fxvjBO44oSJX4=
github.com/gardener/gardener v1.59.0 h1:9T8C2lPwaFTKxUi3afpVjmbao/uDcn5lfYRmFqMFoYw=
github.com/gardener/gardener v1.59.0/go.mod h1:4vopE/Pg4LJud1CRg80rAcp94v83MJIgktlHNcSKO84=
github.com/gardener/gardener-extension-networking-calico v1.28.0 h1:eeUYuYjRB3xSww+fmCnyF+RPPqsO4Zro7Gg0MfMDfFk=
github.com/gardener/gardener-extension-networking-calico v1.28.0/go.mod h1:DhaXVgUF4LAsS+6UlBK8kUKM8mhI+YHl/9/+WK3zfMk=
github.com/gardener/gardener-extension-networking-cilium v1.20.0 h1:4s+eXjX34M2S4WfKqWnj3T48B/CeKwOjwoNFiTO3N/g=
github.com/gardener/gardener-extension-networking-cilium v1.20.0/go.mod h1:bXE/CwHLju+AMsqYXdFIQTt1r+GRHOTW8hJ9EIR84Z0=
github.com/gardener/gardener-extension-networking-calico v1.27.1 h1:q/lsdqbwV+qlwNPxlqFxGeqKMDwPk+dPhUGXjxObzGE=
github.com/gardener/gardener-extension-networking-calico v1.27.1/go.mod h1:MURFRmYPHiXSfmJ82S3nXH3qGcszeYQwhMVKn/J5XoU=
github.com/gardener/hvpa-controller/api v0.5.0 h1:f4F3O7YUrenwh4S3TgPREPiB287JjjUiUL18OqPLyAA=
github.com/gardener/hvpa-controller/api v0.5.0/go.mod h1:QQl3ELkCaki+8RhXl0FZMfvnm0WCGwGJlGmrxJj6lvM=
github.com/gardener/machine-controller-manager v0.45.0 h1:rpf0PHRXJMGY93oMruNP+tnMawKJXhhzCACyNJsT8Lo=
Expand Down Expand Up @@ -374,6 +374,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down Expand Up @@ -493,6 +494,7 @@ github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
Expand Down
109 changes: 17 additions & 92 deletions pkg/admission/mutator/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ import (
"reflect"

calicov1alpha1 "github.com/gardener/gardener-extension-networking-calico/pkg/apis/calico/v1alpha1"
"github.com/gardener/gardener-extension-networking-calico/pkg/calico"
ciliumv1alpha1 "github.com/gardener/gardener-extension-networking-cilium/pkg/apis/cilium/v1alpha1"
"github.com/gardener/gardener-extension-networking-cilium/pkg/cilium"

extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook"
gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -40,13 +37,6 @@ type shoot struct {
decoder runtime.Decoder
}

var (
// EnableOverlayAsDefaultForCalico enables the overlay network for all new calico shoot clusters on openstack
EnableOverlayAsDefaultForCalico bool
// EnableOverlayAsDefaultForCilium enables the overlay network for all new cilium shoot clusters on openstack
EnableOverlayAsDefaultForCilium bool
)

// InjectScheme injects the given scheme into the validator.
func (s *shoot) InjectScheme(scheme *runtime.Scheme) error {
s.decoder = serializer.NewCodecFactory(scheme, serializer.EnableStrict).UniversalDecoder()
Expand All @@ -55,6 +45,7 @@ func (s *shoot) InjectScheme(scheme *runtime.Scheme) error {

// Mutate mutates the given shoot object.
func (s *shoot) Mutate(ctx context.Context, new, old client.Object) error {
overlay := &calicov1alpha1.Overlay{Enabled: false}

shoot, ok := new.(*gardencorev1beta1.Shoot)
if !ok {
Expand Down Expand Up @@ -88,88 +79,32 @@ func (s *shoot) Mutate(ctx context.Context, new, old client.Object) error {
return nil
}

switch shoot.Spec.Networking.Type {
case calico.ReleaseName:
overlay := &calicov1alpha1.Overlay{Enabled: false}

networkConfig, err := s.decodeCalicoNetworkConfig(shoot.Spec.Networking.ProviderConfig)
if err != nil {
return err
}

if oldShoot == nil && networkConfig.Overlay == nil {
networkConfig.Overlay = overlay
}

if oldShoot != nil && networkConfig.Overlay == nil {
oldNetworkConfig, err := s.decodeCalicoNetworkConfig(oldShoot.Spec.Networking.ProviderConfig)
if err != nil {
return err
}

if oldNetworkConfig.Overlay != nil {
networkConfig.Overlay = oldNetworkConfig.Overlay
}
}

if networkConfig.Overlay != nil && !networkConfig.Overlay.Enabled {
networkConfig.SnatToUpstreamDNS = &calicov1alpha1.SnatToUpstreamDNS{Enabled: true}
} else {
networkConfig.SnatToUpstreamDNS = &calicov1alpha1.SnatToUpstreamDNS{Enabled: false}
}

if networkConfig.Overlay != nil && EnableOverlayAsDefaultForCalico {
networkConfig.Overlay = &calicov1alpha1.Overlay{Enabled: true}
networkConfig.SnatToUpstreamDNS = &calicov1alpha1.SnatToUpstreamDNS{Enabled: false}
}

shoot.Spec.Networking.ProviderConfig = &runtime.RawExtension{
Object: networkConfig,
}
networkConfig, err := s.decodeNetworkingConfig(shoot.Spec.Networking.ProviderConfig)
if err != nil {
return err
}

case cilium.ReleaseName:
overlay := &ciliumv1alpha1.Overlay{Enabled: false}
if oldShoot == nil && networkConfig.Overlay == nil {
networkConfig.Overlay = overlay
}

networkConfig, err := s.decodeCiliumNetworkConfig(shoot.Spec.Networking.ProviderConfig)
if oldShoot != nil && networkConfig.Overlay == nil {
oldNetworkConfig, err := s.decodeNetworkingConfig(oldShoot.Spec.Networking.ProviderConfig)
if err != nil {
return err
}

if oldShoot == nil && networkConfig.Overlay == nil {
networkConfig.Overlay = overlay
}

if oldShoot != nil && networkConfig.Overlay == nil {
oldNetworkConfig, err := s.decodeCiliumNetworkConfig(oldShoot.Spec.Networking.ProviderConfig)
if err != nil {
return err
}

if oldNetworkConfig.Overlay != nil {
networkConfig.Overlay = oldNetworkConfig.Overlay
}
}

if networkConfig.Overlay != nil && !networkConfig.Overlay.Enabled {
networkConfig.SnatToUpstreamDNS = &ciliumv1alpha1.SnatToUpstreamDNS{Enabled: true}
} else {
networkConfig.SnatToUpstreamDNS = &ciliumv1alpha1.SnatToUpstreamDNS{Enabled: false}
}

if networkConfig.Overlay != nil && EnableOverlayAsDefaultForCilium {
networkConfig.Overlay = &ciliumv1alpha1.Overlay{Enabled: true}
networkConfig.SnatToUpstreamDNS = &ciliumv1alpha1.SnatToUpstreamDNS{Enabled: false}
}

shoot.Spec.Networking.ProviderConfig = &runtime.RawExtension{
Object: networkConfig,
if oldNetworkConfig.Overlay != nil {
networkConfig.Overlay = oldNetworkConfig.Overlay
}
}
shoot.Spec.Networking.ProviderConfig = &runtime.RawExtension{
Object: networkConfig,
}

return nil
}

func (s *shoot) decodeCalicoNetworkConfig(network *runtime.RawExtension) (*calicov1alpha1.NetworkConfig, error) {
func (s *shoot) decodeNetworkingConfig(network *runtime.RawExtension) (*calicov1alpha1.NetworkConfig, error) {
networkConfig := &calicov1alpha1.NetworkConfig{}
if network != nil && network.Raw != nil {
if _, _, err := s.decoder.Decode(network.Raw, nil, networkConfig); err != nil {
Expand All @@ -179,16 +114,6 @@ func (s *shoot) decodeCalicoNetworkConfig(network *runtime.RawExtension) (*calic
return networkConfig, nil
}

func (s *shoot) decodeCiliumNetworkConfig(network *runtime.RawExtension) (*ciliumv1alpha1.NetworkConfig, error) {
networkConfig := &ciliumv1alpha1.NetworkConfig{}
if network != nil && network.Raw != nil {
if _, _, err := s.decoder.Decode(network.Raw, nil, networkConfig); err != nil {
return nil, err
}
}
return networkConfig, nil
}

// wasShootRescheduledToNewSeed returns true if the shoot.Spec.SeedName has been changed, but the migration operation has not started yet.
func wasShootRescheduledToNewSeed(shoot *gardencorev1beta1.Shoot) bool {
return shoot.Status.LastOperation != nil &&
Expand Down
Loading

0 comments on commit 39cbdc3

Please sign in to comment.