-
Notifications
You must be signed in to change notification settings - Fork 158
feat(protection): document new provider deletion protection with clusterusages #1090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -457,6 +457,99 @@ removing their finalizers. | |
| For more information on deleting abandoned resources read the [Crossplane troubleshooting guide]({{<ref "../guides/troubleshoot-crossplane#deleting-when-a-resource-hangs" >}}). | ||
| {{< /hint >}} | ||
|
|
||
| ### Provider deletion protection | ||
|
|
||
| {{<hint "important" >}} | ||
| Provider deletion protection is an alpha feature. Crossplane disables alpha | ||
| features by default. | ||
|
|
||
| Enable Provider deletion protection with the | ||
| `--enable-provider-deletion-protection` | ||
| [feature flag]({{<ref "../get-started/install#feature-flags">}}). | ||
| This feature also requires | ||
| [Usages]({{<ref "../managed-resources/usages">}}) to be enabled (on by default). | ||
|
|
||
| ```shell {label="protection-helm"} | ||
| helm upgrade --install crossplane crossplane-stable/crossplane \ | ||
| --namespace crossplane-system \ | ||
| --set args='{"--enable-provider-deletion-protection"}' | ||
| ``` | ||
| {{</hint >}} | ||
|
|
||
| When Provider deletion protection is enabled, Crossplane automatically prevents | ||
| the deletion of Providers that still have active managed resources. This | ||
| protects against accidentally removing a Provider and orphaning its managed | ||
| resources. | ||
|
|
||
| Crossplane watches for managed resources associated with each Provider. When | ||
| managed resources exist, Crossplane creates a | ||
| [ClusterUsage]({{<ref "../managed-resources/usages#clusterusages">}}) that | ||
| blocks deletion of the owning Provider. The `ClusterUsage` includes a | ||
| descriptive reason indicating which managed resource type is still active, | ||
| for example `"Provider has active managed resources of type | ||
| VPC.ec2.aws.upbound.io"`. | ||
|
|
||
| When all managed resources of a given type are deleted, Crossplane automatically | ||
| removes the corresponding `ClusterUsage`, allowing the Provider to be deleted. | ||
|
|
||
| List all provider protection `ClusterUsages` using the | ||
| `crossplane.io/provider-protection=true` label: | ||
|
|
||
| ```shell {copy-lines="1"} | ||
| kubectl get clusterusages -l crossplane.io/provider-protection=true | ||
| NAME AGE | ||
| provider-protection-a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6 5m | ||
| ``` | ||
|
|
||
| {{<hint "note" >}} | ||
| Crossplane generates `ClusterUsage` names using a hash of the | ||
| `ManagedResourceDefinition` name. Use the | ||
| `crossplane.io/provider-protection=true` label to find them. | ||
|
|
||
| Each `ClusterUsage` also has labels for the Provider name | ||
| (`pkg.crossplane.io/package`) and the MRD name | ||
| (`apiextensions.crossplane.io/mrd`). | ||
| {{< /hint >}} | ||
|
|
||
| Inspect a specific `ClusterUsage` to see which Provider it protects and why: | ||
|
|
||
| ```yaml | ||
| apiVersion: protection.crossplane.io/v1beta1 | ||
| kind: ClusterUsage | ||
| metadata: | ||
| name: provider-protection-a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6 | ||
| labels: | ||
| crossplane.io/provider-protection: "true" | ||
| pkg.crossplane.io/package: crossplane-contrib-provider-aws-s3 | ||
| apiextensions.crossplane.io/mrd: buckets.s3.aws.upbound.io | ||
| spec: | ||
| of: | ||
| apiVersion: pkg.crossplane.io/v1 | ||
| kind: Provider | ||
| resourceRef: | ||
| name: crossplane-contrib-provider-aws-s3 | ||
| reason: "Provider has active managed resources of type Bucket.s3.aws.upbound.io" | ||
| ``` | ||
|
|
||
| Attempting to delete a Provider with active managed resources returns an error | ||
| from the Usage admission webhook: | ||
|
|
||
| ```shell | ||
| $ kubectl delete provider.pkg.crossplane.io/provider-aws-ec2 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the terminal prompt char should not be included here, the docs add that automatically currently, the copy to clipboard button is displayed and clicking it copies the entire command along with error message. If we don't mean for folks to copy it, then we should disable it with |
||
| Error from server (This resource is in-use by 3 usage(s), including the | ||
| *v1beta1.ClusterUsage "provider-protection-774712aa693d57a5e7ce09a7754d53f3 | ||
| ca5cc59f417083756b2a" with reason: "Provider has active managed resources of | ||
| type SecurityGroup.ec2.aws.m.upbound.io".): admission webhook | ||
| "nousages.protection.crossplane.io" denied the request: This resource is | ||
| in-use by 3 usage(s), including the *v1beta1.ClusterUsage | ||
| "provider-protection-774712aa693d57a5e7ce09a7754d53f3ca5cc59f417083756b2a" | ||
| with reason: "Provider has active managed resources of type | ||
| SecurityGroup.ec2.aws.m.upbound.io". | ||
| ``` | ||
|
|
||
| To delete a protected Provider, first remove all its managed resources, or | ||
| manually delete the `ClusterUsage` resource protecting it. | ||
|
|
||
| ## Verify a Provider | ||
|
|
||
| Providers install their own APIs representing the managed resources they support. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when i ran this command, i got more useful printer columns like
DETAILS- do you not see the same? i think it looks better to have the more details by default in the docs