From 882596855922b2c272016683d8647a1a4b65b6d0 Mon Sep 17 00:00:00 2001 From: SkalaNetworks Date: Mon, 23 Sep 2024 12:03:00 -0400 Subject: [PATCH] feat(natgw): make the prefix for nat gws configurable Signed-off-by: SkalaNetworks --- pkg/controller/vpc_nat.go | 7 +++++++ pkg/util/vpc_nat_gateway.go | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/controller/vpc_nat.go b/pkg/controller/vpc_nat.go index 8c367adc077..5e17d0d6880 100644 --- a/pkg/controller/vpc_nat.go +++ b/pkg/controller/vpc_nat.go @@ -22,6 +22,13 @@ func (c *Controller) resyncVpcNatConfig() { return } + // Prefix used to generate the name of the StatefulSet/Pods for a NAT gateway + // By default it is equal to the value contained in 'util.VpcNatGwNamePrefix' + vpcNatGwNamePrefix := cm.Data["natGwNamePrefix"] + if vpcNatGwNamePrefix != "" { + util.VpcNatGwNamePrefix = vpcNatGwNamePrefix + } + // Image we're using to provision the NAT gateways image, exist := cm.Data["image"] if !exist { diff --git a/pkg/util/vpc_nat_gateway.go b/pkg/util/vpc_nat_gateway.go index 7a397031c83..cdc3dbda103 100644 --- a/pkg/util/vpc_nat_gateway.go +++ b/pkg/util/vpc_nat_gateway.go @@ -2,10 +2,17 @@ package util import "fmt" +var ( + // VpcNatGwNamePrefix is appended to the name of the StatefulSet and Pods for NAT gateways + VpcNatGwNamePrefix = "vpc-nat-gw" +) + +// GenNatGwStsName returns the full name of a NAT gateway StatefulSet func GenNatGwStsName(name string) string { - return fmt.Sprintf("vpc-nat-gw-%s", name) + return fmt.Sprintf("%s-%s", VpcNatGwNamePrefix, name) } +// GenNatGwPodName returns the full name of the NAT gateway pod within a StatefulSet func GenNatGwPodName(name string) string { - return fmt.Sprintf("vpc-nat-gw-%s-0", name) + return fmt.Sprintf("%s-%s-0", VpcNatGwNamePrefix, name) }