@@ -36,6 +36,7 @@ import (
3636 "github.com/pkg/errors"
3737 istionetworkv1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1"
3838 appsv1 "k8s.io/api/apps/v1"
39+ corev1 "k8s.io/api/core/v1"
3940 "k8s.io/apimachinery/pkg/runtime"
4041 "k8s.io/apimachinery/pkg/runtime/serializer"
4142 "k8s.io/client-go/rest"
@@ -48,6 +49,8 @@ import (
4849 "github.com/stackitcloud/gardener-extension-acl/pkg/extensionspec"
4950 "github.com/stackitcloud/gardener-extension-acl/pkg/helper"
5051 "github.com/stackitcloud/gardener-extension-acl/pkg/imagevector"
52+
53+ apierrors "k8s.io/apimachinery/pkg/api/errors"
5154)
5255
5356const (
@@ -147,6 +150,16 @@ func (a *actuator) Reconcile(ctx context.Context, log logr.Logger, ex *extension
147150
148151 alwaysAllowedCIDRs = append (alwaysAllowedCIDRs , helper .GetSeedSpecificAllowedCIDRs (cluster .Seed )... )
149152
153+ // On Seeds using cilium as the kube-proxy replacement we need the egress IP
154+ // of the cluster to be allowed in order for the alertmanager
155+ // ApiServerNoteReachable check to work. In that case the traffic to the
156+ // kubernetes API will be externally routed and not dnatted.
157+ egressCIDRs , err := a .getSeedEgressIPOnManagedSeeds (ctx )
158+ if err != nil {
159+ return err
160+ }
161+ alwaysAllowedCIDRs = append (alwaysAllowedCIDRs , egressCIDRs ... )
162+
150163 if len (a .extensionConfig .AdditionalAllowedCIDRs ) >= 1 {
151164 alwaysAllowedCIDRs = append (alwaysAllowedCIDRs , a .extensionConfig .AdditionalAllowedCIDRs ... )
152165 }
@@ -446,3 +459,36 @@ func (a *actuator) findDefaultIstioLabels(
446459
447460 return gw .Spec .Selector , nil
448461}
462+
463+ // getSeedEgressIPOnManagedSeeds returns the egressIP CIDRs of the ManagedSeed, if the
464+ // Seed is not a shoot, it will return an empty list
465+ func (a * actuator ) getSeedEgressIPOnManagedSeeds (ctx context.Context ) ([]string , error ) {
466+ cm := corev1.ConfigMap {}
467+ if err := a .client .Get (ctx ,
468+ client.ObjectKey {
469+ Name : v1beta1constants .ConfigMapNameShootInfo ,
470+ Namespace : "kube-system" ,
471+ },
472+ & cm ); err != nil {
473+ if apierrors .IsNotFound (err ) {
474+ return []string {}, nil
475+ }
476+ return nil , err
477+ }
478+
479+ cidrsStr , ok := cm .Data ["egressCIDRs" ]
480+ if ! ok {
481+ return nil , errors .New ("unable to get egress CIDRs from shoot-info ConfigMap" )
482+ }
483+
484+ var cidrs []string
485+ for _ , i := range strings .Split (cidrsStr , "," ) {
486+ _ , _ , err := net .ParseCIDR (i )
487+ if err != nil {
488+ return nil , err
489+ }
490+ cidrs = append (cidrs , i )
491+ }
492+
493+ return cidrs , nil
494+ }
0 commit comments