Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion controllers/clusterwidenetworkpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"go4.org/netipx"

apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/firewall-controller/v2/pkg/dns"
"github.com/metal-stack/firewall-controller/v2/pkg/helper"
"github.com/metal-stack/firewall-controller/v2/pkg/nftables"
Expand Down Expand Up @@ -45,6 +46,9 @@ type ClusterwideNetworkPolicyReconciler struct {
Interval time.Duration
DnsProxy *dns.DNSProxy
SkipDNS bool

DefaultRouteIp string
MachineAllocation *apiv2.MachineAllocation
}

// SetupWithManager configures this controller to run in schedule
Expand Down Expand Up @@ -103,7 +107,7 @@ func (r *ClusterwideNetworkPolicyReconciler) Reconcile(ctx context.Context, _ ct
}
cwnps.Items = validCwnps

nftablesFirewall := nftables.NewFirewall(f, &cwnps, &services, r.DnsProxy, r.Log, r.Recorder)
nftablesFirewall := nftables.NewFirewall(f, &cwnps, &services, r.DnsProxy, r.Log, r.Recorder, r.MachineAllocation)
if err := r.manageDNSProxy(f, cwnps, nftablesFirewall); err != nil {
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -147,6 +151,7 @@ func (r *ClusterwideNetworkPolicyReconciler) manageDNSProxy(
DNSServer: f.Spec.DNSServerAddress,
Port: f.Spec.DNSPort,
ShootClient: r.ShootClient,
BindAddress: r.DefaultRouteIp,
}
if r.DnsProxy, err = dns.NewDNSProxy(r.Ctx, dnsProxyConfig); err != nil {
return fmt.Errorf("failed to init DNS proxy: %w", err)
Expand Down
21 changes: 13 additions & 8 deletions controllers/firewall_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/Masterminds/semver/v3"
"github.com/go-logr/logr"
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
mn "github.com/metal-stack/metal-lib/pkg/net"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -52,7 +53,8 @@ type FirewallReconciler struct {

SeedUpdatedFunc func()

FrrVersion *semver.Version
FrrVersion *semver.Version
MachineAllocation *apiv2.MachineAllocation
}

const (
Expand Down Expand Up @@ -93,8 +95,10 @@ func (r *FirewallReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
defaultFw := nftables.NewFirewall(
&firewallv2.Firewall{},
&firewallv1.ClusterwideNetworkPolicyList{},
&corev1.ServiceList{}, nil, logr.Discard(),
&corev1.ServiceList{},
nil, logr.Discard(),
r.Recorder,
r.MachineAllocation,
)

flushErr := defaultFw.Flush()
Expand Down Expand Up @@ -124,7 +128,8 @@ func (r *FirewallReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
r.Log.Info("reconciling network settings")

var errs []error
changed, err := network.ReconcileNetwork(r.Log, f, r.FrrVersion)

changed, err := network.ReconcileNetwork(r.Log, f, r.MachineAllocation, r.FrrVersion)
if changed && err == nil {
r.recordFirewallEvent(f, corev1.EventTypeNormal, "Network settings", "reconciliation succeeded (frr.conf)")
} else if changed && err != nil {
Expand Down Expand Up @@ -169,16 +174,16 @@ type firewallService struct {
// reconcileFirewallServices reconciles the services and endpoints exposed by the firewall
func (r *FirewallReconciler) reconcileFirewallServices(ctx context.Context, f *firewallv2.Firewall) error {
services := []firewallService{
{
name: nodeExporterService,
port: nodeExporterPort,
namedPort: nodeExporterNamedPort,
},
{
name: nftablesExporterService,
port: nftablesExporterPort,
namedPort: nftablesExporterNamedPort,
},
{
name: nodeExporterService,
port: nodeExporterPort,
namedPort: nodeExporterNamedPort,
},
}

var errs []error
Expand Down
33 changes: 18 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ require (
github.com/google/go-cmp v0.7.0
github.com/google/nftables v0.3.0
github.com/ks2211/go-suricata v0.0.0-20200823200910-986ce1470707
github.com/metal-stack/firewall-controller-manager v0.6.1
github.com/metal-stack/metal-go v0.45.0
github.com/metal-stack/api v0.8.2
github.com/metal-stack/firewall-controller-manager v0.6.2-0.20261013093056-8814016e6683
github.com/metal-stack/metal-lib v0.26.3
github.com/metal-stack/metal-networker v0.47.0
github.com/metal-stack/os-installer v0.3.2
github.com/metal-stack/v v1.0.3
github.com/miekg/dns v1.1.73
github.com/stretchr/testify v1.12.1
github.com/txn2/txeh v1.8.1
github.com/vishvananda/netlink v1.3.1
go4.org/netipx v0.0.0-20260823151212-3075585bcbeb
google.golang.org/protobuf v1.36.12
k8s.io/api v0.36.3
k8s.io/apiextensions-apiserver v0.36.3
k8s.io/apimachinery v0.36.3
Expand All @@ -31,20 +32,19 @@ require (
replace github.com/imdario/mergo => dario.cat/mergo v1.0.0

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 // indirect
dario.cat/mergo v1.0.2 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.14.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/fxamacker/cbor/v2 v2.9.6 // indirect
github.com/go-openapi/analysis v1.0.1 // indirect
github.com/go-openapi/errors v0.22.9 // indirect
github.com/go-openapi/jsonpointer v1.0.2 // indirect
github.com/go-openapi/jsonreference v1.0.3 // indirect
github.com/go-openapi/loads v0.25.3 // indirect
github.com/go-openapi/spec v1.0.1 // indirect
github.com/go-openapi/strfmt v0.27.3 // indirect
github.com/go-openapi/swag v0.29.2 // indirect
github.com/go-openapi/swag/cmdutils v0.29.2 // indirect
github.com/go-openapi/swag/conv v0.29.2 // indirect
Expand All @@ -57,45 +57,48 @@ require (
github.com/go-openapi/swag/stringutils v0.29.2 // indirect
github.com/go-openapi/swag/typeutils v0.29.2 // indirect
github.com/go-openapi/swag/yamlutils v0.29.2 // indirect
github.com/go-openapi/validate v1.0.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/go-openapi/testify/enable/yaml/v2 v2.8.0 // indirect
github.com/godbus/dbus/v5 v5.2.4 // indirect
github.com/google/gnostic-models v0.7.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.6.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.16 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/mdlayher/netlink v1.11.2 // indirect
github.com/mdlayher/socket v0.8.0 // indirect
github.com/metal-stack/metal-hammer v0.13.17 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid/v2 v2.1.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.25.0 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.72.1 // indirect
github.com/prometheus/procfs v0.22.0 // indirect
github.com/samber/lo v1.53.0 // indirect
github.com/shopspring/decimal v1.5.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/stretchr/objx v0.8.0 // indirect
github.com/vishvananda/netns v0.0.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/crypto v0.58.0 // indirect
golang.org/x/net v0.61.0 // indirect
golang.org/x/oauth2 v0.37.0 // indirect
golang.org/x/sync v0.24.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/term v0.47.0 // indirect
golang.org/x/text v0.43.0 // indirect
golang.org/x/time v0.16.0 // indirect
golang.org/x/tools v0.52.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/protobuf v1.36.12 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3 // indirect
Expand Down
Loading
Loading