Skip to content

Commit

Permalink
Add annotation to mark seeds containing a metal-api shoot to fix Netw…
Browse files Browse the repository at this point in the history
…orkPolicies (#83)
  • Loading branch information
Nuckal777 authored Nov 25, 2024
1 parent 33e7842 commit 862aeda
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
12 changes: 9 additions & 3 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ func getCCMChartValues(
return nil, fmt.Errorf("secret %q not found", cloudControllerManagerServerName)
}

podLabels := map[string]any{
v1beta1constants.LabelPodMaintenanceRestart: "true",
}
localAPI, ok := cluster.Seed.Annotations[metal.LocalMetalAPIAnnotation]
if ok && localAPI == "true" {
podLabels[metal.AllowEgressToIstioIngressLabel] = "allowed"
}

values := map[string]any{
"enabled": true,
"replicas": extensionscontroller.GetControlPlaneReplicas(cluster, scaledDown, 1),
Expand All @@ -284,9 +292,7 @@ func getCCMChartValues(
"podAnnotations": map[string]any{
"checksum/secret-" + internal.CloudProviderConfigMapName: checksums[internal.CloudProviderConfigMapName],
},
"podLabels": map[string]any{
v1beta1constants.LabelPodMaintenanceRestart: "true",
},
"podLabels": podLabels,
"tlsCipherSuites": kutil.TLSCipherSuites,
"secrets": map[string]any{
"server": serverSecret.Name,
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/controlplane/valuesprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ var _ = Describe("Valueprovider Reconcile", func() {
},
},
},
Seed: &gardencorev1beta1.Seed{},
}

checksums := map[string]string{
Expand Down
12 changes: 9 additions & 3 deletions pkg/controller/worker/machine_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ func (w *workerDelegate) GetMachineControllerManagerChartValues(ctx context.Cont
return nil, err
}

podLabels := map[string]any{
v1beta1constants.LabelPodMaintenanceRestart: "true",
}
localAPI, ok := w.cluster.Seed.Annotations[metal.LocalMetalAPIAnnotation]
if ok && localAPI == "true" {
podLabels[metal.AllowEgressToIstioIngressLabel] = "allowed"
}

return map[string]any{
"providerName": metal.ProviderName,
"namespace": map[string]any{
"uid": namespace.UID,
},
"podLabels": map[string]any{
v1beta1constants.LabelPodMaintenanceRestart: "true",
},
"podLabels": podLabels,
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/metal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const (
IgnitionOverrideFieldName = "ignitionOverride"
// ClusterNameLabel is the name is the label key of the cluster name
ClusterNameLabel = "extension.metal.dev/cluster-name"
// LocalMetalAPIAnnotation is the name of the annotation to mark a seed, which contains a local metal API shoot
LocalMetalAPIAnnotation = "metal.ironcore.dev/local-metal-api"
// AllowEgressToIstioIngressLabel is the label key to allow egress to the istio ingress gateway
AllowEgressToIstioIngressLabel = "networking.resources.gardener.cloud/to-all-istio-ingresses-istio-ingressgateway-tcp-9443"

// CloudProviderConfigName is the name of the secret containing the cloud provider config.
CloudProviderConfigName = "cloud-provider-config"
Expand Down

0 comments on commit 862aeda

Please sign in to comment.