Skip to content
Merged
18 changes: 9 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ jobs:
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6

- uses: google-github-actions/auth@v1
- uses: google-github-actions/auth@v3
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
uses: google-github-actions/setup-gcloud@v3

- name: Set up Go 1.25
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
go-version-file: 'go.mod'
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v9
with:
args: --build-tags integration --timeout=3m

Expand Down Expand Up @@ -105,12 +105,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6

- name: Set up Go 1.25
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
go-version-file: 'go.mod'
cache: false

- name: Run tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- cidr
type: object
Expand Down Expand Up @@ -192,6 +193,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- cidr
type: object
Expand Down
8 changes: 4 additions & 4 deletions controllers/clusterwidenetworkpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ func (r *ClusterwideNetworkPolicyReconciler) SetupWithManager(mgr ctrl.Manager)
r.Interval = reconciliationInterval
}

scheduleChan := make(chan event.GenericEvent)
scheduleChan := make(chan event.TypedGenericEvent[*firewallv1.ClusterwideNetworkPolicy])
if err := mgr.Add(r.getReconciliationTicker(scheduleChan)); err != nil {
return fmt.Errorf("failed to add runnable to manager: %w", err)
}

return ctrl.NewControllerManagedBy(mgr).
For(&firewallv1.ClusterwideNetworkPolicy{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Watches(&corev1.Service{}, &handler.EnqueueRequestForObject{}).
WatchesRawSource(&source.Channel{Source: scheduleChan}, &handler.EnqueueRequestForObject{}).
WatchesRawSource(source.Channel(scheduleChan, &handler.TypedEnqueueRequestForObject[*firewallv1.ClusterwideNetworkPolicy]{})).
Complete(r)
}

Expand Down Expand Up @@ -184,9 +184,9 @@ func (r *ClusterwideNetworkPolicyReconciler) manageDNSProxy(
// 1. When it's rebooted, metal-networker will generate basic nftables config and apply it.
// In basic config there's now DNAT rules required for DNS Proxy.
// 2. DNS Proxy is started by CWNP controller, and it will not be started until some CWNP resource is created/updated/deleted.
func (r *ClusterwideNetworkPolicyReconciler) getReconciliationTicker(scheduleChan chan<- event.GenericEvent) manager.RunnableFunc {
func (r *ClusterwideNetworkPolicyReconciler) getReconciliationTicker(scheduleChan chan<- event.TypedGenericEvent[*firewallv1.ClusterwideNetworkPolicy]) manager.RunnableFunc {
return func(ctx context.Context) error {
e := event.GenericEvent{Object: &firewallv1.ClusterwideNetworkPolicy{}}
e := event.TypedGenericEvent[*firewallv1.ClusterwideNetworkPolicy]{Object: &firewallv1.ClusterwideNetworkPolicy{}}
ticker := time.NewTicker(r.Interval)
defer ticker.Stop()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (r *ClusterwideNetworkPolicyValidationReconciler) Reconcile(ctx context.Con
// SetupWithManager configures this controller to watch for ClusterwideNetworkPolicy CRD
func (r *ClusterwideNetworkPolicyValidationReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named("clusterwidenetworkpolicy-validation").
For(&firewallv1.ClusterwideNetworkPolicy{}).
Complete(r)
}
11 changes: 7 additions & 4 deletions controllers/firewall_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func (r *FirewallReconciler) reconcileFirewallService(ctx context.Context, s fir
Protocol: corev1.ProtocolTCP,
Port: s.port,
TargetPort: intstr.FromString(s.namedPort),
Name: s.namedPort,
},
},
},
Expand Down Expand Up @@ -256,8 +257,12 @@ func (r *FirewallReconciler) reconcileFirewallService(ctx context.Context, s fir
return fmt.Errorf("private firewall network contains no ip")
}

// keep endpoints, even if the endpoint API is deprecated, since default prometheus-operator setups still use endpoints
// for service discovery instead of endpoint slices
//nolint:staticcheck // SA1019
endpoints := corev1.Endpoints{
ObjectMeta: meta,
//nolint:staticcheck // SA1019
Subsets: []corev1.EndpointSubset{
{
Addresses: []corev1.EndpointAddress{
Expand All @@ -276,6 +281,7 @@ func (r *FirewallReconciler) reconcileFirewallService(ctx context.Context, s fir
},
}

//nolint:staticcheck // SA1019
var currentEndpoints corev1.Endpoints
err = r.ShootClient.Get(ctx, nn, &currentEndpoints)
if err != nil && !apierrors.IsNotFound(err) {
Expand All @@ -284,10 +290,7 @@ func (r *FirewallReconciler) reconcileFirewallService(ctx context.Context, s fir

if apierrors.IsNotFound(err) {
err = r.ShootClient.Create(ctx, &endpoints)
if err != nil {
return err
}
return nil
return err
}

if !reflect.DeepEqual(currentEndpoints.Subsets, endpoints.Subsets) {
Expand Down
133 changes: 71 additions & 62 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,92 +11,101 @@ require (
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.5.1
github.com/metal-stack/metal-go v0.42.0
github.com/metal-stack/metal-lib v0.23.3
github.com/metal-stack/metal-go v0.42.5
github.com/metal-stack/metal-lib v0.23.5
github.com/metal-stack/metal-networker v0.46.2
github.com/metal-stack/v v1.0.3
github.com/miekg/dns v1.1.68
github.com/txn2/txeh v1.5.5
github.com/miekg/dns v1.1.72
github.com/txn2/txeh v1.7.0
github.com/vishvananda/netlink v1.3.1
go.uber.org/mock v0.6.0
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
k8s.io/api v0.29.3
k8s.io/apiextensions-apiserver v0.29.3
k8s.io/apimachinery v0.32.3
k8s.io/client-go v0.29.3
sigs.k8s.io/controller-runtime v0.17.5
k8s.io/api v0.34.0
k8s.io/apiextensions-apiserver v0.34.0
k8s.io/apimachinery v0.34.0
k8s.io/client-go v0.34.0
sigs.k8s.io/controller-runtime v0.22.0
sigs.k8s.io/yaml v1.6.0
)

replace k8s.io/apimachinery => k8s.io/apimachinery v0.29.3
replace github.com/imdario/mergo => dario.cat/mergo v1.0.0

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // 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.12.2 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.1 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 // indirect
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-openapi/analysis v0.24.2 // indirect
github.com/go-openapi/errors v0.22.6 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/jsonreference v0.21.4 // indirect
github.com/go-openapi/loads v0.23.2 // indirect
github.com/go-openapi/spec v0.22.3 // indirect
github.com/go-openapi/strfmt v0.25.0 // indirect
github.com/go-openapi/swag v0.25.4 // indirect
github.com/go-openapi/swag/cmdutils v0.25.4 // indirect
github.com/go-openapi/swag/conv v0.25.4 // indirect
github.com/go-openapi/swag/fileutils v0.25.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
github.com/go-openapi/swag/loading v0.25.4 // indirect
github.com/go-openapi/swag/mangling v0.25.4 // indirect
github.com/go-openapi/swag/netutils v0.25.4 // indirect
github.com/go-openapi/swag/stringutils v0.25.4 // indirect
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
github.com/go-openapi/validate v0.25.1 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/godbus/dbus/v5 v5.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/klauspost/compress v1.18.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mdlayher/netlink v1.7.3-0.20250113171957-fbb4dce95f42 // indirect
github.com/mdlayher/netlink v1.8.0 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/metal-stack/metal-hammer v0.13.11 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/metal-stack/metal-hammer v0.13.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // 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 v1.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/pflag v1.0.7 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/vishvananda/netns v0.0.5 // indirect
go.mongodb.org/mongo-driver v1.17.3 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/mod v0.27.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/term v0.34.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.36.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.mongodb.org/mongo-driver v1.17.7 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.32.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.41.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e // indirect
k8s.io/utils v0.0.0-20260108192941-914a6e750570 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
)
Loading