|
61 | 61 |
|
62 | 62 | Reference to LinodeVPC object is added to LinodeCluster object which then uses the specified VPC to provision resources. |
63 | 63 |
|
| 64 | +## Lifecycle Management and Adopting Existing VPCs |
| 65 | +
|
| 66 | +The provider offers flexible lifecycle management, allowing you to adopt existing VPCs and control whether resources are deleted when their corresponding Kubernetes objects are removed. |
| 67 | +
|
| 68 | +### Adopting an Existing VPC |
| 69 | +You can instruct the controller to use a pre-existing VPC by specifying its ID in the `LinodeVPCSpec`. The controller will "adopt" this VPC and manage its subnets without creating a new one. |
| 70 | + |
| 71 | +```yaml |
| 72 | +--- |
| 73 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 |
| 74 | +kind: LinodeVPC |
| 75 | +metadata: |
| 76 | + name: my-adopted-vpc |
| 77 | +spec: |
| 78 | + vpcID: 12345 |
| 79 | + region: us-sea |
| 80 | + # subnets can be defined and will be created within the adopted VPC |
| 81 | + subnets: |
| 82 | + - label: my-new-subnet-in-adopted-vpc |
| 83 | + ipv4: 10.0.3.0/24 |
| 84 | +``` |
| 85 | + |
| 86 | +### Retaining Resources on Deletion |
| 87 | +By default, the controller deletes VPCs and subnets from your Linode account when you delete the `LinodeVPC` Kubernetes object. You can prevent this using the `retain` flag. |
| 88 | + |
| 89 | +- **`spec.retain`**: When set to `true` on the `LinodeVPC`, the VPC itself will not be deleted from Linode. This is the default and recommended behavior when adopting an existing VPC. |
| 90 | +- **`spec.subnets[].retain`**: When the parent VPC is retained, you can use this flag to control individual subnets. If `retain` is `false` (the default), the subnet will be deleted. |
| 91 | + |
| 92 | +```admonish warning title="Safety Check for Attached Linodes" |
| 93 | +The controller includes a critical safety feature: it will **not** delete a subnet if it has any active Linode instances attached to it. The operation will be paused and retried, preventing resource orphaning. |
| 94 | +``` |
| 95 | + |
64 | 96 | ### Additional Configuration |
65 | 97 | By default, the VPC will use the subnet with the `default` label for deploying clusters. To modify this behavior, set the `SUBNET_NAME` environment variable to match the label of the subnet to be used. Make sure the subnet is set up in the LinodeVPC manifest. |
66 | 98 |
|
@@ -111,3 +143,5 @@ CIDR returned in the output of above command should match with the pod CIDR pres |
111 | 143 |
|
112 | 144 | ### Running cilium connectivity tests |
113 | 145 | One can also run cilium connectivity tests to make sure networking works fine within VPC. Follow the steps defined in [cilium e2e tests](https://docs.cilium.io/en/stable/contributing/testing/e2e/) guide to install cilium binary, set the KUBECONFIG variable and then run `cilium connectivity tests`. |
| 146 | + |
| 147 | +``` |
0 commit comments