Skip to content

Conversation

gardener-ci-robot
Copy link
Contributor

@gardener-ci-robot gardener-ci-robot commented May 13, 2025

This is an automated cherry-pick of #12061

/assign rfranzke

It is now ensured that extension admission webhooks have validated `WorkloadIdentity`s/`Secret`s referenced in `Shoot`s.

rfranzke and others added 8 commits May 13, 2025 17:50
for local testing

Co-Authored-By: Tim Usner <tim.usner@sap.com>
For `WorkoadIdentity`s, there is already
https://github.com/gardener/gardener/blob/b9622262d10177c185e26b4a6551414cc236ac51/plugin/pkg/global/extensionlabels/admission.go#L157-L165
which takes care of syncing the provider label based on the type in the
`spec`.
This way, we ensure that all `*Binding` resources can be considered
"safe to be used" UNDER THE CONDITION that the provider type of the
`*Binding` matches with the provider type of the target resource (e.g.,
a `Shoot` with provider type `foo` must ensure that it only references
a `*Binding` with provider type `foo`).

This is already ensured by https://github.com/gardener/gardener/blob/2a9c566f89a6a16e654193945250f60755c560b9/plugin/pkg/shoot/validator/admission.go#L1073-L1091.
As of today, the `Shoot` API is the only one using `*Binding` resources.

Note that we don't need to do this dry-run-create for
`WorkloadIdentity`s because we already ensure that the provider types of
it and the `CredentialsBinding` match (see previous commit). This way,
we ensure that a `WorkloadIdentity` must have already successfully
passed the provider extension check when referenced in
a `CredentialsBinding` with the same type.

Co-Authored-By: Tim Usner <tim.usner@sap.com>
…ing`s

Co-Authored-By: Rafael Franzke <rafael.franzke@sap.com>
When `CredentialsBinding`s or `SecretBinding`s are created with `generateName`, the `metadata.name` field is not populated, causing the admission plugin to miss validating that the providers between the binding and the shoot match.

In addition, the `ResourceReferenceManager` needs to be a validating admission plugin in order to see the changes applied by `PrepareForCreate`.
@gardener-ci-robot gardener-ci-robot added kind/enhancement Enhancement, improvement, extension area/usability Usability related labels May 13, 2025
@gardener-prow gardener-prow bot requested review from ialidzhikov and tobschli May 13, 2025 17:50
@gardener-prow gardener-prow bot added cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 13, 2025
@rfranzke
Copy link
Member

/lgtm
/approve

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

gardener-prow bot commented May 13, 2025

LGTM label has been added.

Git tree hash: e113db72afe1cc79ca460024dcf90b0c39ead980

Copy link
Contributor

gardener-prow bot commented May 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rfranzke

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 May 13, 2025
@gardener-prow gardener-prow bot merged commit b89cf2c into gardener:release-v1.118 May 13, 2025
18 checks passed
@gardener-ci-robot gardener-ci-robot deleted the cherry-pick-12061-to-release-v1.118 branch May 13, 2025 22:00
timebertt pushed a commit to stackitcloud/gardener that referenced this pull request May 14, 2025
…oadIdentity`s and `Secret`s when used (gardener#12075)

backport of gardener#12061
Can be dropped when upgrading to g/g@v1.119

* Implement dummy `Secret`/`WorkloadIdentity` validator for provider-local

for local testing

Co-Authored-By: Tim Usner <tim.usner@sap.com>

* New webhook for syncing provider secrets

For `WorkoadIdentity`s, there is already
https://github.com/gardener/gardener/blob/b9622262d10177c185e26b4a6551414cc236ac51/plugin/pkg/global/extensionlabels/admission.go#L157-L165
which takes care of syncing the provider label based on the type in the
`spec`.

* Dry-run provider secret creation to ensure it is sane

This way, we ensure that all `*Binding` resources can be considered
"safe to be used" UNDER THE CONDITION that the provider type of the
`*Binding` matches with the provider type of the target resource (e.g.,
a `Shoot` with provider type `foo` must ensure that it only references
a `*Binding` with provider type `foo`).

This is already ensured by https://github.com/gardener/gardener/blob/2a9c566f89a6a16e654193945250f60755c560b9/plugin/pkg/shoot/validator/admission.go#L1073-L1091.
As of today, the `Shoot` API is the only one using `*Binding` resources.

Note that we don't need to do this dry-run-create for
`WorkloadIdentity`s because we already ensure that the provider types of
it and the `CredentialsBinding` match (see previous commit). This way,
we ensure that a `WorkloadIdentity` must have already successfully
passed the provider extension check when referenced in
a `CredentialsBinding` with the same type.

Co-Authored-By: Tim Usner <tim.usner@sap.com>

* New admission plugin preventing undesired finalizer removal of `*Binding`s

Co-Authored-By: Rafael Franzke <rafael.franzke@sap.com>

* Ensure provider types match

* Support `generateName` field

When `CredentialsBinding`s or `SecretBinding`s are created with `generateName`, the `metadata.name` field is not populated, causing the admission plugin to miss validating that the providers between the binding and the shoot match.

In addition, the `ResourceReferenceManager` needs to be a validating admission plugin in order to see the changes applied by `PrepareForCreate`.

* Handle unset `provider` field in `SecretBinding`s

* Address PR review feedback

---------

Co-authored-by: rfranzke <rafael.franzke@sap.com>
Co-authored-by: Tim Usner <tim.usner@sap.com>
ske-prow bot pushed a commit to stackitcloud/gardener that referenced this pull request May 14, 2025
…oadIdentity`s and `Secret`s when used (gardener#12075)

backport of gardener#12061
Can be dropped when upgrading to g/g@v1.119

* Implement dummy `Secret`/`WorkloadIdentity` validator for provider-local

for local testing

Co-Authored-By: Tim Usner <tim.usner@sap.com>

* New webhook for syncing provider secrets

For `WorkoadIdentity`s, there is already
https://github.com/gardener/gardener/blob/b9622262d10177c185e26b4a6551414cc236ac51/plugin/pkg/global/extensionlabels/admission.go#L157-L165
which takes care of syncing the provider label based on the type in the
`spec`.

* Dry-run provider secret creation to ensure it is sane

This way, we ensure that all `*Binding` resources can be considered
"safe to be used" UNDER THE CONDITION that the provider type of the
`*Binding` matches with the provider type of the target resource (e.g.,
a `Shoot` with provider type `foo` must ensure that it only references
a `*Binding` with provider type `foo`).

This is already ensured by https://github.com/gardener/gardener/blob/2a9c566f89a6a16e654193945250f60755c560b9/plugin/pkg/shoot/validator/admission.go#L1073-L1091.
As of today, the `Shoot` API is the only one using `*Binding` resources.

Note that we don't need to do this dry-run-create for
`WorkloadIdentity`s because we already ensure that the provider types of
it and the `CredentialsBinding` match (see previous commit). This way,
we ensure that a `WorkloadIdentity` must have already successfully
passed the provider extension check when referenced in
a `CredentialsBinding` with the same type.

Co-Authored-By: Tim Usner <tim.usner@sap.com>

* New admission plugin preventing undesired finalizer removal of `*Binding`s

Co-Authored-By: Rafael Franzke <rafael.franzke@sap.com>

* Ensure provider types match

* Support `generateName` field

When `CredentialsBinding`s or `SecretBinding`s are created with `generateName`, the `metadata.name` field is not populated, causing the admission plugin to miss validating that the providers between the binding and the shoot match.

In addition, the `ResourceReferenceManager` needs to be a validating admission plugin in order to see the changes applied by `PrepareForCreate`.

* Handle unset `provider` field in `SecretBinding`s

* Address PR review feedback

---------

Co-authored-by: rfranzke <rafael.franzke@sap.com>
Co-authored-by: Tim Usner <tim.usner@sap.com>
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/usability Usability 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.

3 participants