Files
jpictl/pkg/rings/three.go
T
amery 57251ce0af rings: RingThreePrefix()
Ring 3 corresponds to the pods of the kubernetes cluster of a region

Signed-off-by: Alejandro Mery <amery@jpi.io>
2024-05-25 21:31:21 +00:00

19 lines
448 B
Go

package rings
import "net/netip"
// RingThreePrefix returns the subnet corresponding to
// the pods of a cluster.
//
// Ring 3 is a `10.(region_id << 4).0.0/12` network
func RingThreePrefix(region RegionID) (subnet netip.Prefix, err error) {
switch {
case !region.Valid():
err = ErrOutOfRange(region, "region")
default:
addr := AddrFrom4(10, uint(region)<<4, 0, 0)
subnet = netip.PrefixFrom(addr, RingThreeBits)
}
return subnet, err
}