Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion config/base/catalogd/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resources:
- manager.yaml
- catalogd_service.yaml
- service.yaml
- network_policy.yaml
- webhook/manifests.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Expand Down
22 changes: 22 additions & 0 deletions config/base/catalogd/manager/network_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: controller-manager
namespace: system
spec:
podSelector:
matchLabels:
control-plane: catalogd-controller-manager
policyTypes:
- Ingress
- Egress
Copy link
Contributor

@camilamacedo86 camilamacedo86 Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just need Ingress, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First I did like you there, and I received this feedback from community: kubernetes-sigs/kubebuilder#3853 (comment)

So, we might need to reconsider.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We explicitly want to allow all egress traffic both catalogd and operator-controller because they need to be able to communicate with unknown-in-advance image registries. If we are not explicitly granting that access, then another NetworkPolicy that matches our pod that is more restrictive could break us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to be more restrictive to make sense.
But I get your point.
We can also enhance it on follow ups. So, 👍

ingress:
- ports:
- protocol: TCP
port: 7443 # metrics
- protocol: TCP
port: 8443 # catalogd http server
- protocol: TCP
port: 9443 # webhook
egress:
- {} # Allows all egress traffic (needed to pull catalog images from arbitrary image registries)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: Kustomization
resources:
- manager.yaml
- service.yaml
- network_policy.yaml

images:
- name: controller
Expand Down
18 changes: 18 additions & 0 deletions config/base/operator-controller/manager/network_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: controller-manager
namespace: system
spec:
podSelector:
matchLabels:
control-plane: operator-controller-controller-manager
policyTypes:
- Ingress
- Egress
ingress:
- ports:
- protocol: TCP
port: 8443 # metrics
egress:
- {} # Allows all egress traffic (needed to pull bundle images from arbitrary image registries)
Copy link
Contributor

@camilamacedo86 camilamacedo86 Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a bit of context — back when we added this to Kubebuilder, there was a request from the community for us to use labels.

The idea was to allow scenarios where, for example, a Pod wants to scrape metrics. In those cases, having specific labels becomes necessary to permit that traffic through the NetworkPolicy.

You might want to take a look at this example for reference:
https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/config/network-policy/allow-metrics-traffic.yaml#L19-L24

So, we might want to consider the same approach. Sharing to allow you to think about the pros and cons.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are fully open now, I think keeping it simple and slightly more open is better for this first pass. If we find later that we can ratchet down access to metrics and the catalogd webhook port in a general way, we can do that later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we can do a follow-up after checking that this config works on the downstream as well.
It is fine.

Loading