GCP: Only create debugd loadbalancer when debugCluster is set

This commit is contained in:
Nils Hanke 2022-09-06 10:28:00 +02:00 committed by Nils Hanke
parent d74c7a3769
commit 72d4456b3f
5 changed files with 54 additions and 22 deletions

View file

@ -35,7 +35,7 @@ type loadBalancer struct {
}
// CreateLoadBalancers creates all necessary load balancers.
func (c *Client) CreateLoadBalancers(ctx context.Context) error {
func (c *Client) CreateLoadBalancers(ctx context.Context, isDebugCluster bool) error {
if err := c.createIPAddr(ctx); err != nil {
return fmt.Errorf("creating load balancer IP address: %w", err)
}
@ -69,13 +69,16 @@ func (c *Client) CreateLoadBalancers(ctx context.Context) error {
healthCheck: computepb.HealthCheck_TCP,
})
c.loadbalancers = append(c.loadbalancers, &loadBalancer{
name: c.buildResourceName("debugd"),
ip: c.loadbalancerIPname,
frontendPort: constants.DebugdPort,
backendPortName: "debugd",
healthCheck: computepb.HealthCheck_TCP,
})
// Only create when the debug cluster flag is set in the Constellation config
if isDebugCluster {
c.loadbalancers = append(c.loadbalancers, &loadBalancer{
name: c.buildResourceName("debugd"),
ip: c.loadbalancerIPname,
frontendPort: constants.DebugdPort,
backendPortName: "debugd",
healthCheck: computepb.HealthCheck_TCP,
})
}
// Load balancer creation.