Skip to content

Commit eba9221

Browse files
committed
feat(loadbalancers): add selector style annotation for lb to vpc/pn assoc
Signed-off-by: Andreas Wachs <awa@corti.ai>
1 parent f745002 commit eba9221

6 files changed

Lines changed: 938 additions & 31 deletions

File tree

docs/loadbalancer-annotations.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,43 @@ The possible formats are:
245245
- `<pn-id>`: will attach a single Private Network to the LB.
246246
- `<pn-id>,<pn-id>`: will attach the two Private Networks to the LB.
247247

248+
### `service.beta.kubernetes.io/scw-loadbalancer-pn-names`
249+
250+
This is the annotation to configure the Private Networks by name instead of ID.
251+
The private network names will be resolved to IDs at runtime. This is useful when
252+
you want to specify private networks without hardcoding their IDs, which can change
253+
when clusters are recreated.
254+
255+
**Priority order:**
256+
1. `service.beta.kubernetes.io/scw-loadbalancer-pn-ids` (highest priority)
257+
2. `service.beta.kubernetes.io/scw-loadbalancer-pn-names`
258+
3. `PN_ID` environment variable (fallback)
259+
260+
If both `pn-ids` and `pn-names` are set, `pn-ids` takes precedence and `pn-names` is ignored.
261+
This annotation is ignored when `service.beta.kubernetes.io/scw-loadbalancer-externally-managed` is enabled.
262+
263+
The format must be `<vpc-name>/<pn-name>` to specify both the VPC and the private network name.
264+
Multiple entries can be comma-separated.
265+
266+
**Examples:**
267+
```yaml
268+
# Single private network
269+
service.beta.kubernetes.io/scw-loadbalancer-pn-names: "default/my-private-network"
270+
271+
# Multiple networks from different VPCs
272+
service.beta.kubernetes.io/scw-loadbalancer-pn-names: "prod-vpc/network-1,staging-vpc/network-2"
273+
274+
# Multiple networks from the same VPC
275+
service.beta.kubernetes.io/scw-loadbalancer-pn-names: "default/network-1,default/network-2"
276+
```
277+
278+
**Error handling:**
279+
- If the format is invalid (missing VPC or PN name), an error is returned.
280+
- If a private network name is not found, an error is returned.
281+
- If multiple private networks have the same name within the VPC, an error is returned.
282+
- If the specified VPC is not found, an error is returned.
283+
- If multiple VPCs have the same name, an error is returned.
284+
248285
### `service.beta.kubernetes.io/scw-loadbalancer-health-check-from-service`
249286

250287
This is the annotation to configure the load balancer backend to use the service's `healthCheckNodePort` for health checks.

scaleway/errors.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ package scaleway
1919
import "errors"
2020

2121
var (
22-
BadProviderID = errors.New("provider ID wrong format: format should be scaleway://product/region/0788e6f4-55b0-42e2-936f-d0c5ecd49a13")
23-
InstanceDuplicated = errors.New("duplicated instance results")
24-
IPAddressNotFound = errors.New("ip address not found")
25-
IPAddressInUse = errors.New("ip address already in use")
26-
LoadBalancerNotFound = errors.New("loadbalancer not found")
27-
LoadBalancerDuplicated = errors.New("loadbalancer duplicated")
28-
LoadBalancerNotReady = errors.New("loadbalancer is not ready")
22+
BadProviderID = errors.New("provider ID wrong format: format should be scaleway://product/region/0788e6f4-55b0-42e2-936f-d0c5ecd49a13")
23+
InstanceDuplicated = errors.New("duplicated instance results")
24+
IPAddressNotFound = errors.New("ip address not found")
25+
IPAddressInUse = errors.New("ip address already in use")
26+
LoadBalancerNotFound = errors.New("loadbalancer not found")
27+
LoadBalancerDuplicated = errors.New("loadbalancer duplicated")
28+
LoadBalancerNotReady = errors.New("loadbalancer is not ready")
29+
PrivateNetworkNotFound = errors.New("private network not found")
30+
PrivateNetworkDuplicated = errors.New("multiple private networks found with same name")
31+
VPCNotFound = errors.New("VPC not found")
32+
VPCDuplicated = errors.New("multiple VPCs found with same name")
2933

3034
errLoadBalancerInvalidAnnotation = errors.New("load balancer invalid annotation")
3135
errLoadBalancerInvalidLoadBalancerID = errors.New("load balancer invalid loadbalancer-id annotation")

0 commit comments

Comments
 (0)