Skip to content

Commit

Permalink
feat(natgw): make the prefix for nat gws configurable
Browse files Browse the repository at this point in the history
Signed-off-by: SkalaNetworks <[email protected]>
  • Loading branch information
SkalaNetworks committed Sep 23, 2024
1 parent b406ce9 commit 8825968
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pkg/controller/vpc_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 9 additions & 2 deletions pkg/util/vpc_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 8825968

Please sign in to comment.