Skip to content

Commit

Permalink
add driver to cluster configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
eaudetcobello committed Jun 3, 2024
1 parent ea45314 commit 2d807fe
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/k8s/api/v1/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (c IngressConfig) GetDefaultTLSSecret() string { return getField(c.Default
func (c IngressConfig) GetEnableProxyProtocol() bool { return getField(c.EnableProxyProtocol) }

type LoadBalancerConfig struct {
Driver *string `json:"driver,omitempty" yaml:"driver,omitempty"`
Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
CIDRs *[]string `json:"cidrs,omitempty" yaml:"cidrs,omitempty"`
L2Mode *bool `json:"l2-mode,omitempty" yaml:"l2-mode,omitempty"`
Expand All @@ -90,6 +91,7 @@ type LoadBalancerConfig struct {
BGPPeerPort *int `json:"bgp-peer-port,omitempty" yaml:"bgp-peer-port,omitempty"`
}

func (c LoadBalancerConfig) GetDriver() string { return getField(c.Driver) }
func (c LoadBalancerConfig) GetEnabled() bool { return getField(c.Enabled) }
func (c LoadBalancerConfig) GetCIDRs() []string { return getField(c.CIDRs) }
func (c LoadBalancerConfig) GetL2Mode() bool { return getField(c.L2Mode) }
Expand Down
21 changes: 21 additions & 0 deletions src/k8s/pkg/k8sd/features/metallb/chart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package metallb

import (
"path"

"github.com/canonical/k8s/pkg/client/helm"
)

var (
chartMetalLB = helm.InstallableChart{
Name: "metallb",
Namespace: "metallb-system",
ManifestPath: path.Join("charts", "metallb-0.14.5.tgz"),
}

chartMetalLBLoadBalancer = helm.InstallableChart{
Name: "metallb-loadbalancer",
Namespace: "metallb-system",
ManifestPath: path.Join("charts", "metallb-loadbalancer"),
}
)
3 changes: 3 additions & 0 deletions src/k8s/pkg/k8sd/types/cluster_config_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (c *ClusterConfig) SetDefaults() {
c.LocalStorage.Default = utils.Pointer(true)
}
// load balancer
if c.LoadBalancer.Driver == nil {
c.LoadBalancer.Driver = utils.Pointer("cilium")
}
if c.LoadBalancer.Enabled == nil {
c.LoadBalancer.Enabled = utils.Pointer(false)
}
Expand Down
4 changes: 3 additions & 1 deletion src/k8s/pkg/k8sd/types/cluster_config_defaults_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package types_test

import (
"github.com/canonical/k8s/pkg/utils"
"testing"

"github.com/canonical/k8s/pkg/utils"

"github.com/canonical/k8s/pkg/k8sd/types"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -41,6 +42,7 @@ func TestSetDefaults(t *testing.T) {
Default: utils.Pointer(true),
},
LoadBalancer: types.LoadBalancer{
Driver: utils.Pointer("cilium"),
Enabled: utils.Pointer(false),
CIDRs: utils.Pointer([]string{}),
L2Mode: utils.Pointer(false),
Expand Down
1 change: 1 addition & 0 deletions src/k8s/pkg/k8sd/types/cluster_config_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Ingress struct {
}

type LoadBalancer struct {
Driver *string `json:"driver,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
CIDRs *[]string `json:"cidrs,omitempty"`
IPRanges *[]LoadBalancer_IPRange `json:"ranges,omitempty"`
Expand Down

0 comments on commit 2d807fe

Please sign in to comment.