|
| 1 | +--- |
| 2 | +title: Disabling Unused Managed Resources |
| 3 | +weight: 85 |
| 4 | +state: alpha |
| 5 | +alphaVersion: 2.0 |
| 6 | +description: Reduce CRD overhead by disabling unused managed resources |
| 7 | +--- |
| 8 | + |
| 9 | +{{<hint "important">}} |
| 10 | +This guide uses |
| 11 | +[managed resource definitions]({{<ref "../managed-resources/managed-resource-definitions">}}) |
| 12 | +and |
| 13 | +[managed resource activation policies]({{<ref "../managed-resources/managed-resource-activation-policies">}}), |
| 14 | +which Crossplane v2.0+ enables by default. To disable this behavior, set |
| 15 | +`--enable-custom-to-managed-resource-conversion=false` when installing |
| 16 | +Crossplane. |
| 17 | +{{</hint>}} |
| 18 | + |
| 19 | +Large Crossplane providers can install 100+ managed resource CRDs, consuming |
| 20 | +significant cluster resources even when you only need one or two resource |
| 21 | +types. This guide shows how to use |
| 22 | +[ManagedResourceDefinitions]({{<ref "../managed-resources/managed-resource-definitions">}}) |
| 23 | +and |
| 24 | +[ManagedResourceActivationPolicies]({{<ref "../managed-resources/managed-resource-activation-policies">}}) |
| 25 | +to install only the provider resources you actually need. |
| 26 | + |
| 27 | +## Before you begin |
| 28 | + |
| 29 | +This guide requires: |
| 30 | + |
| 31 | +- Crossplane v2.0+ installed in your cluster |
| 32 | +- A provider with `safe-start` capability (this guide uses |
| 33 | + `provider-aws-ec2:v2.0.0`) |
| 34 | +- Basic familiarity with Kubernetes and Crossplane concepts |
| 35 | + |
| 36 | +{{<hint "important">}} |
| 37 | +ManagedResourceDefinitions and ManagedResourceActivationPolicies are alpha |
| 38 | +features in Crossplane v2.0+. |
| 39 | +{{</hint>}} |
| 40 | + |
| 41 | +## The problem: Resource overhead |
| 42 | + |
| 43 | +Installing a large cloud provider in Crossplane creates hundreds of CRDs: |
| 44 | + |
| 45 | +```shell |
| 46 | +# Before selective activation - provider-aws-ec2 installs ~200 CRDs |
| 47 | +kubectl get crds | grep aws.crossplane.io | wc -l |
| 48 | +# Output: 200 |
| 49 | + |
| 50 | +# Each CRD consumes ~3 MiB of API server memory |
| 51 | +# 200 CRDs × 3 MiB = 600 MiB of memory usage |
| 52 | +``` |
| 53 | + |
| 54 | +Most users only need a small subset of these resources. Selective activation |
| 55 | +lets you install just what you need. |
| 56 | + |
| 57 | +## Step 1: Disable automatic activation |
| 58 | + |
| 59 | +By default, the Crossplane Helm chart creates an activation policy that |
| 60 | +enables all provider resources. To use selective activation, disable this |
| 61 | +default behavior. |
| 62 | + |
| 63 | +<!-- vale Google.Headings = NO --> |
| 64 | +### Option A: Helm installation |
| 65 | +<!-- vale Google.Headings = YES --> |
| 66 | + |
| 67 | +```shell |
| 68 | +helm install crossplane crossplane-stable/crossplane \ |
| 69 | + --namespace crossplane-system \ |
| 70 | + --create-namespace \ |
| 71 | + --set provider.defaultActivations={} |
| 72 | +``` |
| 73 | + |
| 74 | +<!-- vale Google.Headings = NO --> |
| 75 | +### Option B: Existing installation |
| 76 | +<!-- vale Google.Headings = YES --> |
| 77 | + |
| 78 | +Delete the default activation policy: |
| 79 | + |
| 80 | +```shell |
| 81 | +kubectl delete managedresourceactivationpolicy default |
| 82 | +``` |
| 83 | + |
| 84 | +## Step 2: Install your provider |
| 85 | + |
| 86 | +Install your provider as normal. Crossplane automatically converts the |
| 87 | +provider's CRDs to ManagedResourceDefinitions: |
| 88 | + |
| 89 | +```yaml |
| 90 | +apiVersion: pkg.crossplane.io/v1 |
| 91 | +kind: Provider |
| 92 | +metadata: |
| 93 | + name: provider-aws-ec2 |
| 94 | +spec: |
| 95 | + package: xpkg.crossplane.io/provider-aws-ec2:v2.0.0 |
| 96 | +``` |
| 97 | +
|
| 98 | +Save this as `provider.yaml` and apply it: |
| 99 | + |
| 100 | +```shell |
| 101 | +kubectl apply -f provider.yaml |
| 102 | +
|
| 103 | +# Wait for provider to be ready |
| 104 | +kubectl wait --for condition=Healthy provider/provider-aws-ec2 --timeout=5m |
| 105 | +``` |
| 106 | + |
| 107 | +## Step 3: Verify Crossplane created MRDs |
| 108 | + |
| 109 | +<!-- vale Google.WordList = NO --> |
| 110 | +After the provider installs, check ManagedResourceDefinitions that Crossplane |
| 111 | +created in inactive state: |
| 112 | +<!-- vale Google.WordList = YES --> |
| 113 | + |
| 114 | +```shell |
| 115 | +# List ManagedResourceDefinitions |
| 116 | +kubectl get managedresourcedefinitions |
| 117 | +
|
| 118 | +# Check their states (should be "Inactive") |
| 119 | +kubectl get mrds -o jsonpath='{.items[*].spec.state}' \ |
| 120 | + | tr ' ' '\n' | sort | uniq -c |
| 121 | +# 200 Inactive |
| 122 | +``` |
| 123 | + |
| 124 | +Notice that Crossplane didn't create any CRDs yet: |
| 125 | + |
| 126 | +```shell |
| 127 | +kubectl get crds | grep ec2.aws.crossplane.io |
| 128 | +# No output - CRDs don't exist until MRDs are activated |
| 129 | +``` |
| 130 | + |
| 131 | +## Step 4: Create an activation policy |
| 132 | + |
| 133 | +Create a ManagedResourceActivationPolicy to selectively activate only the |
| 134 | +resources you need: |
| 135 | + |
| 136 | +```yaml |
| 137 | +apiVersion: apiextensions.crossplane.io/v1alpha1 |
| 138 | +kind: ManagedResourceActivationPolicy |
| 139 | +metadata: |
| 140 | + name: my-app-resources |
| 141 | +spec: |
| 142 | + activate: |
| 143 | + - instances.ec2.aws.crossplane.io # EC2 instances for compute |
| 144 | + - securitygroups.ec2.aws.crossplane.io # Security groups for networking |
| 145 | + - vpcs.ec2.aws.crossplane.io # VPCs for isolation |
| 146 | +``` |
| 147 | + |
| 148 | +Save this as `activation-policy.yaml` and apply it: |
| 149 | + |
| 150 | +```shell |
| 151 | +kubectl apply -f activation-policy.yaml |
| 152 | +``` |
| 153 | + |
| 154 | +## Step 5: Verify selective activation |
| 155 | + |
| 156 | +<!-- vale Google.WordList = NO --> |
| 157 | +Check that Crossplane activated only the specified resources: |
| 158 | +<!-- vale Google.WordList = YES --> |
| 159 | + |
| 160 | +```shell |
| 161 | +# Check MRD states - only some should be Active now |
| 162 | +kubectl get mrds \ |
| 163 | + -o jsonpath='{range .items[*]}{.metadata.name}: {.spec.state}{"\n"}{end}' \ |
| 164 | + | grep Active |
| 165 | +# instances.ec2.aws.crossplane.io: Active |
| 166 | +# securitygroups.ec2.aws.crossplane.io: Active |
| 167 | +# vpcs.ec2.aws.crossplane.io: Active |
| 168 | +
|
| 169 | +# Verify Crossplane created corresponding CRDs |
| 170 | +kubectl get crds | grep ec2.aws.crossplane.io |
| 171 | +# instances.ec2.aws.crossplane.io |
| 172 | +# securitygroups.ec2.aws.crossplane.io |
| 173 | +# vpcs.ec2.aws.crossplane.io |
| 174 | +
|
| 175 | +# Count CRDs from EC2 provider - should match activated MRDs |
| 176 | +kubectl get crds | grep ec2.aws.crossplane.io | wc -l |
| 177 | +# 3 (only the activated resources) |
| 178 | +``` |
| 179 | + |
| 180 | +## Step 6: Measure the impact |
| 181 | + |
| 182 | +Check the significant reduction in resource overhead: |
| 183 | + |
| 184 | +```shell |
| 185 | +# Count CRDs from EC2 provider - should be much lower than 200 |
| 186 | +kubectl get crds | grep aws.crossplane.io | wc -l |
| 187 | +# 3 CRDs (99% reduction from 200) |
| 188 | +
|
| 189 | +# Calculate memory savings |
| 190 | +echo "197 CRDs saved × 3 MiB = 591 MiB saved (99% reduction)" |
| 191 | +
|
| 192 | +# Verify inactive MRDs still exist but consume minimal resources |
| 193 | +kubectl get mrds \ |
| 194 | + -o jsonpath='{.items[?(@.spec.state=="Inactive")]..metadata.name}' | wc -w |
| 195 | +# 197 inactive MRDs (~20 MiB total overhead vs 600 MiB for active CRDs) |
| 196 | +
|
| 197 | +# Check total MRDs (active + inactive) |
| 198 | +kubectl get mrds | wc -l |
| 199 | +# 200 total MRDs (3 active, 197 inactive) |
| 200 | +``` |
| 201 | + |
| 202 | +The selective activation provides massive resource savings while maintaining |
| 203 | +full capability for the resources you actually use. |
| 204 | + |
| 205 | +## Next steps |
| 206 | + |
| 207 | +- Learn more about |
| 208 | + [ManagedResourceDefinitions]({{<ref "../managed-resources/managed-resource-definitions">}}) |
| 209 | + for detailed concepts and troubleshooting |
| 210 | +- Explore |
| 211 | + [ManagedResourceActivationPolicies]({{<ref "../managed-resources/managed-resource-activation-policies">}}) |
| 212 | + for advanced activation strategies and best practices |
| 213 | +- Check the [API reference]({{<ref "../api">}}) for complete schema |
| 214 | + documentation |
0 commit comments