Skip to content

Commit

Permalink
Add optional router id to openstack cloud config
Browse files Browse the repository at this point in the history
Needed not by MC itself but by Metakube seed-cm, which uses this
structure to generate the seed user cluster cloud config secret
  • Loading branch information
multi-io committed May 5, 2023
1 parent 6625c3e commit 74ff5bd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/cloudprovider/provider/openstack/types/cloudconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"github.com/kubermatic/machine-controller/pkg/ini"
)

// use-octavia is enabled by default in CCM since v1.17.0, and disabled by
// default with the in-tree cloud provider.
// https://v1-18.docs.kubernetes.io/docs/concepts/cluster-administration/cloud-providers/#load-balancer
// use-octavia is enabled by default in CCM since v1.17.0, and disabled by
// default with the in-tree cloud provider.
// https://v1-18.docs.kubernetes.io/docs/concepts/cluster-administration/cloud-providers/#load-balancer
const (
cloudConfigTpl = `[Global]
auth-url = {{ .Global.AuthURL | iniEscape }}
Expand Down Expand Up @@ -77,6 +77,11 @@ bs-version = {{ default "auto" .BlockStorage.BSVersion | iniEscape }}
{{- if .BlockStorage.NodeVolumeAttachLimit }}
node-volume-attach-limit = {{ .BlockStorage.NodeVolumeAttachLimit }}
{{- end }}
{{- if .Route.RouterID }}
[Route]
router-id = {{ .Route.RouterID }}
{{- end }}
`
)

Expand All @@ -103,6 +108,11 @@ type BlockStorageOpts struct {
NodeVolumeAttachLimit uint `gcfg:"node-volume-attach-limit"`
}

// RouterOpts is used for Neutron routes
type RouterOpts struct {
RouterID string `gcfg:"router-id"`
}

type GlobalOpts struct {
AuthURL string `gcfg:"auth-url"`
Username string
Expand All @@ -127,6 +137,7 @@ type CloudConfig struct {
Global GlobalOpts
LoadBalancer LoadBalancerOpts
BlockStorage BlockStorageOpts
Route RouterOpts
Version string
}

Expand Down
26 changes: 26 additions & 0 deletions pkg/cloudprovider/provider/openstack/types/cloudconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,32 @@ func TestCloudConfigToString(t *testing.T) {
Version: "1.10.0",
},
},
{
name: "config-with-router-id",
config: &CloudConfig{
Global: GlobalOpts{
AuthURL: "https://127.0.0.1:8443",
Username: "admin",
Password: "password",
DomainName: "Default",
ProjectName: "Test",
Region: "eu-central1",
},
BlockStorage: BlockStorageOpts{
BSVersion: "v2",
IgnoreVolumeAZ: true,
TrustDevicePath: true,
NodeVolumeAttachLimit: 25,
},
LoadBalancer: LoadBalancerOpts{
ManageSecurityGroups: true,
},
Route: RouterOpts{
RouterID: "12345-6666-7777",
},
Version: "1.10.0",
},
},
}

for _, test := range tests {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Global]
auth-url = "https://127.0.0.1:8443"
username = "admin"
password = "password"
tenant-name = "Test"
tenant-id = ""
domain-name = "Default"
region = "eu-central1"

[LoadBalancer]
lb-version = "v2"
subnet-id = ""
floating-network-id = ""
lb-method = "ROUND_ROBIN"
lb-provider = ""

[BlockStorage]
ignore-volume-az = true
trust-device-path = true
bs-version = "v2"
node-volume-attach-limit = 25

[Route]
router-id = 12345-6666-7777

0 comments on commit 74ff5bd

Please sign in to comment.