ea23312d4a
Ring 2 is the service network shared by all kubernetes clusters. Signed-off-by: Alejandro Mery <amery@jpi.io>
20 lines
490 B
Go
20 lines
490 B
Go
package rings
|
|
|
|
import "net/netip"
|
|
|
|
// RingTwoPrefix represents the services of a cluster
|
|
//
|
|
// Ring 2 subnets are of the form `10.(region_id).0.0/20`,
|
|
// using the address space that would belong to the ring 3
|
|
// region_id 0.
|
|
func RingTwoPrefix(region RegionID) (cidr netip.Prefix, err error) {
|
|
switch {
|
|
case !region.Valid():
|
|
err = ErrOutOfRange(region, "region")
|
|
default:
|
|
addr := AddrFrom4(10, uint(region), 0, 0)
|
|
cidr = netip.PrefixFrom(addr, RingTwoBits)
|
|
}
|
|
return cidr, err
|
|
}
|