Skip to content

Commit

Permalink
Make NAT gateway generation prefix a variable (#4557)
Browse files Browse the repository at this point in the history
Signed-off-by: SkalaNetworks <[email protected]>
  • Loading branch information
SkalaNetworks authored Nov 6, 2024
1 parent 042bdff commit 5734a27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/controller/vpc_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ 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
} else {
util.VpcNatGwNamePrefix = util.VpcNatGwNameDefaultPrefix
}

// Image we're using to provision the NAT gateways
image, exist := cm.Data["image"]
if !exist {
Expand Down
12 changes: 10 additions & 2 deletions pkg/util/vpc_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ package util

import "fmt"

// VpcNatGwNameDefaultPrefix is the default prefix appended to the name of the NAT gateways
const VpcNatGwNameDefaultPrefix = "vpc-nat-gw"

// VpcNatGwNamePrefix is appended to the name of the StatefulSet and Pods for NAT gateways
var VpcNatGwNamePrefix = VpcNatGwNameDefaultPrefix

// 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 5734a27

Please sign in to comment.