Skip to content

Conversation

rfranzke
Copy link
Member

How to categorize this PR?

/area security
/kind enhancement

What this PR does / why we need it:
See #11034 for details.

Which issue(s) this PR fixes:
Fixes #11034

Special notes for your reviewer:
/hold
The last commit should be dropped - I have to revert it once the tests pass. Otherwise, PR is ready for review.

Release note:

All `Seed`s are now automatically labeled with `seed.gardener.cloud/<name>=true` where `<name>` is their own name, and (if applicable) the name of their parent seed in case they are managed seeds. This label can be used as selector for requests.

@gardener-prow gardener-prow bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. area/security Security related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. labels Dec 18, 2024
@gardener-prow gardener-prow bot requested review from acumino and timuthy December 18, 2024 08:15
@gardener-prow gardener-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 18, 2024
@rfranzke rfranzke force-pushed the improve-seed-authz branch 2 times, most recently from a73e0f1 to d85f217 Compare December 19, 2024 08:39
@rfranzke
Copy link
Member Author

/unhold

e2e tests look good, PR is ready to go.

@gardener-prow gardener-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 19, 2024
@gardener-ci-robot
Copy link
Contributor

The Gardener project currently lacks enough active contributors to adequately respond to all PRs.
This bot triages PRs according to the following rules:

  • After 15d of inactivity, lifecycle/stale is applied
  • After 15d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 7d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Mark this PR as rotten with /lifecycle rotten
  • Close this PR with /close

/lifecycle stale

@gardener-prow gardener-prow bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 4, 2025
@shafeeqes
Copy link
Contributor

/remove-lifecycle stale

@gardener-prow gardener-prow bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 9, 2025
@timuthy
Copy link
Member

timuthy commented Jan 15, 2025

/assign

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 21, 2025
@timuthy timuthy force-pushed the improve-seed-authz branch from 568196f to fd5ec2f Compare January 22, 2025 09:35
@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 22, 2025
@timuthy
Copy link
Member

timuthy commented Jan 22, 2025

Added fd5ec2f to address review comment (#11062 (comment)) and rebased PR.

@oliver-goetz
Copy link
Member

There is an rebase error in pkg/apis/core/v1beta1/helper/helper.go and pkg/apis/core/v1beta1/helper/helper_test.go. Those files have been reorganized in #11083.

@timuthy timuthy force-pushed the improve-seed-authz branch from fd5ec2f to 4c6e4d2 Compare January 22, 2025 11:15
@timuthy
Copy link
Member

timuthy commented Jan 22, 2025

/retest-required

@timuthy
Copy link
Member

timuthy commented Jan 22, 2025

/test pull-gardener-e2e-kind-migration

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 23, 2025
The `gardenlet` only updates its own `Seed`, so there is no need to have
these verbs as part of the "always allowed" list.
The only place where `gardenlet` deletes `Seed` resources is in its
`ManagedSeed` controller via
https://github.com/gardener/gardener/blob/48169a21cfbfd5a515a7374c729c9de9111e5bd2/pkg/controller/gardenletdeployer/actuator.go#L304-L311.

Now, the graph is consulted and asked whether the `gardenlet` is allowed
to delete it.
rfranzke and others added 7 commits January 24, 2025 15:54
- own name
- optional: name of parent seed in case the `Seed` is a managed seed

This allows to use a label selector in `gardenlet` when watching
`Seed`s.

Similar to gardener#9089
only the name of the parent seed (i.e., the name of the seed that is
used in the referenced shoot)
… label selector

This should not be activated in the same release since we have to
make sure that all `{Managed}Seed`s get the label first (which usually
only happens when the `gardenlet`s make their first request for updating
the `{Managed}Seed` status).

If we rolled this out in one release (gardenlet cache already
restricted), the `{Managed}Seed`s wouldn't have the labels yet, hence
the `gardenlet`s wouldn't see any `{Managed}Seed`s.
The controller is ought to remove the `ShootReadyForMigration`
constraint in case it missed the event during migration.
The `ReadyForMigration` taint was previously removed at the beginning of the `migration` phase.
However, if the migration reconcile flow restarts then gardenlet will end up again and stuck in the check ready-for-migration check (see https://github.com/gardener/gardener/blob/4c6e4d23d2725c93ac77cae246095e20af75d86a/pkg/gardenlet/controller/shoot/shoot/reconciler.go#L161).
With this change the constraint is removed during the `restore` phase.
@timuthy timuthy force-pushed the improve-seed-authz branch from 4c6e4d2 to 725c3d8 Compare January 24, 2025 15:04
@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 24, 2025
@timuthy
Copy link
Member

timuthy commented Jan 27, 2025

/test pull-gardener-e2e-kind-ha-multi-zone

@ScheererJ
Copy link
Member

/assign

@timuthy
Copy link
Member

timuthy commented Jan 27, 2025

/test pull-gardener-e2e-kind-operator

Copy link
Member

@ScheererJ ScheererJ left a comment

Choose a reason for hiding this comment

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

Thanks for improving security by reducing the almighty gardenlet.

/lgtm
/approve

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 27, 2025
Copy link
Contributor

gardener-prow bot commented Jan 27, 2025

LGTM label has been added.

Git tree hash: d13e0b85d4302c81b0b41740fcd89b05001d21e7

Copy link
Contributor

gardener-prow bot commented Jan 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ScheererJ

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gardener-prow gardener-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2025
@gardener-prow gardener-prow bot merged commit e6c6ecd into gardener:master Jan 27, 2025
19 checks passed
Roncossek pushed a commit to Roncossek/gardener that referenced this pull request Jan 27, 2025
* No longer unconditionally allow `update`, `patch` verbs for `Seed`s

The `gardenlet` only updates its own `Seed`, so there is no need to have
these verbs as part of the "always allowed" list.

* No longer unconditionally allow `delete` verb for `Seed`s

The only place where `gardenlet` deletes `Seed` resources is in its
`ManagedSeed` controller via
https://github.com/gardener/gardener/blob/48169a21cfbfd5a515a7374c729c9de9111e5bd2/pkg/controller/gardenletdeployer/actuator.go#L304-L311.

Now, the graph is consulted and asked whether the `gardenlet` is allowed
to delete it.

* New controller in GCM writing `ReadyForMigration` shoot constraint

* Maintain seed labels on `Seed` resource

- own name
- optional: name of parent seed in case the `Seed` is a managed seed

This allows to use a label selector in `gardenlet` when watching
`Seed`s.

Similar to gardener#9089

* Maintain seed label on `ManagedSeed` resource

only the name of the parent seed (i.e., the name of the seed that is
used in the referenced shoot)

* Add TODO for restricting `gardenlet` watches on `{Managed}Seed`s with label selector

This should not be activated in the same release since we have to
make sure that all `{Managed}Seed`s get the label first (which usually
only happens when the `gardenlet`s make their first request for updating
the `{Managed}Seed` status).

If we rolled this out in one release (gardenlet cache already
restricted), the `{Managed}Seed`s wouldn't have the labels yet, hence
the `gardenlet`s wouldn't see any `{Managed}Seed`s.

* Improve `migration` controller

The controller is ought to remove the `ShootReadyForMigration`
constraint in case it missed the event during migration.

* Remove constraint only during restoration

The `ReadyForMigration` taint was previously removed at the beginning of the `migration` phase.
However, if the migration reconcile flow restarts then gardenlet will end up again and stuck in the check ready-for-migration check (see https://github.com/gardener/gardener/blob/4c6e4d23d2725c93ac77cae246095e20af75d86a/pkg/gardenlet/controller/shoot/shoot/reconciler.go#L161).
With this change the constraint is removed during the `restore` phase.

* Change to external config

* Address review comments

---------

Co-authored-by: Tim Usner <tim.usner@sap.com>
@rfranzke rfranzke deleted the improve-seed-authz branch February 7, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/security Security related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restrict gardenlet access for Seed resources
6 participants