Skip to content

refactor: network policies hardening - #4638

Open
sgaist wants to merge 69 commits into
release-2.22.0from
feat/network-policies-hardening
Open

sgaist wants to merge 69 commits into
release-2.22.0from
feat/network-policies-hardening

Conversation

@sgaist

@sgaist sgaist commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes

This PR's goal is to tighten the network policies to make Renku safer to run.

The TLDR: deny all by default

Until now, only the ingress part was denied. This PR also closes the egress.

This work triggered some side effects that have brought the following changes:

  • The network policies file has been split in multiple files to make things easier to get around
  • Deployments have been relabeled to use Kubernetes recommended labels
  • New renku spcecific labels have been added. This allows:
    • To make things more explicit at the pod level
    • Write network policies that can apply to multiple pods in a simpler fashion (e.g. one label rather than a list of labels)

Cluster admins deploying renku will need to provide the ingress rules for the ingress controller.

Note: the deployment relabeling means that updating an existing renku deployment will fail as the spec.selector field is immutable.
One option is, once the refactor has been approved, to add back the labels used for the original selector.

/deploy

@sgaist
sgaist requested review from a team as code owners September 25, 2026 14:30
@sgaist
sgaist requested a review from olevski September 25, 2026 14:32
@sgaist
sgaist changed the base branch from master to release-2.22.0 September 25, 2026 14:32
This simplifies the network policy and also makes it explicit
which pod shall have ingress access to the database.
In this particular case the init job.

This will allow to reduce the access surface later.
That service does not exist anymore.

Do not mix it up with `renku-k8s-watcher`.
Label:
 - renku-data-service
 - renku-data-tasks

with renku.io/solr-access: "true"
Label:
 - renku-data-service
 - renku-data-tasks
 - uiserver
 - gateway

with renku.io/redis-access: "true"
This is independent from the redis.clientLabel which may or
may not be required based on how the redis deployment was
done.
Label:
 - renku-data-service
 - renku-data-tasks

with renku.io/authz-access: "true"
There are no notebooks anymore.
Added to:
 - gateway
 - swagger
 - keycloak
 - ui (client and server)
This replaces several of the "from anywhere" policies.
Add exactly which pods they are allowed to access
There's no need to go through the ingress for the job
as it will only be created if keycloakx is deployed as
part of Renku.
This ensures the correct value is used if an external keycloak
instance is used.
This ensure that the correct url is usd if using an external
keycloak instance.
The work is twofold:

- Use dedicated files for related policies
- Use the specialized labels to establish connection

The latter means that if new pods are added, they can
simply adopt the proper label such as "renku.io/database-access"
and they will directly have the proper access to the
resource they need without having to add a new policy.
This will be removed once custom labels can be added
to the controller manager pod.
Modernized from the original.

@leafty leafty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: the deployment relabeling means that updating an existing renku deployment will fail as the spec.selector field is immutable.

This is a potential blocker: any operator applying the helm update or relying on gitops (e.g. flux) would see the upgrade fail as the changes to the deployments and stateful sets would be rejected.

There needs to be admin notes detailing the upgrade procedure (deleting workloads just before the update?).

@sgaist

sgaist commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

Note: the deployment relabeling means that updating an existing renku deployment will fail as the spec.selector field is immutable.

This is a potential blocker: any operator applying the helm update or relying on gitops (e.g. flux) would see the upgrade fail as the changes to the deployments and stateful sets would be rejected.

There needs to be admin notes detailing the upgrade procedure (deleting workloads just before the update?).

Only deployment would be impacted in this case. While there are StatefulSets deployed as part of the helm chart, these are all externals and not impacted by the changes done in this patch.

An update to the documentation in that direction is planned.

Comment thread helm-chart/renku/values.yaml Outdated
registry: harbor.renkulab.io
repository: bitnami-mirror/redis
solr:
commonLabels:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Some of them can be a bit invasive and require deletion before upgrading due to changes to the generated manifests (until now only Renku's own deployments were affected).

This can be alleviated by using more fine-grained configuration options that target only the pod's labels so only a recreation would be done AFAICT.

What do you guys prefer ?

This will avoid pre-update deletion requirements
This allows admins to disable/enabled hardened mode.

The main difference is that it changes the default deny
policy from ingress only (mode until now) to ingress and
egress (new default mode).
They need to be able to access outside in order to
work properly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants