Skip to content

Commit 5431be5

Browse files
stackit-skexoxys
andauthored
[release-v1.34] Unify config files for ccm and csi (#483)
* Unify config files for ccm and csi * switch back to separate configs for ccm and csi * align GetConfig methods and cleanup * add migration documentation * fix lb migration --------- Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
1 parent d2ec2b5 commit 5431be5

File tree

19 files changed

+543
-181
lines changed

19 files changed

+543
-181
lines changed

cmd/cloud-controller-manager/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
func main() {
3737
ccmOptions, err := options.NewCloudControllerManagerOptions()
3838
if err != nil {
39-
klog.Fatalf("unable to initialize command options: %v", err)
39+
klog.Fatalf("Unable to initialize command options: %v", err)
4040
}
4141

4242
fmt.Println("starting Controller")
@@ -91,7 +91,7 @@ func cloudInitializer(ctx context.Context) func(config *cloudcontrollerconfig.Co
9191

9292
if !cloud.HasClusterID() {
9393
if config.ComponentConfig.KubeCloudShared.AllowUntaggedCloud {
94-
klog.Warning("detected a cluster without a ClusterID. A ClusterID will be required in the future. Please tag your cluster to avoid any future issues")
94+
klog.Warning("Detected a cluster without a ClusterID. A ClusterID will be required in the future. Please tag your cluster to avoid any future issues")
9595
} else {
9696
klog.Fatalf(
9797
"no ClusterID found. A ClusterID is required for the cloud provider to function properly. " +

deploy/csi-plugin/controllerplugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ spec:
105105
- name: CSI_ENDPOINT
106106
value: unix://csi/csi.sock
107107
- name: CLOUD_CONFIG
108-
value: /etc/config/cloud.conf
108+
value: /etc/config/cloud.yaml
109109
- name: CLUSTER_NAME
110110
value: kubernetes
111111
- name: STACKIT_SERVICE_ACCOUNT_KEY_PATH

deploy/csi-plugin/nodeplugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ spec:
6464
- name: CSI_ENDPOINT
6565
value: unix://csi/csi.sock
6666
- name: CLOUD_CONFIG
67-
value: /etc/config/cloud.conf
67+
value: /etc/config/cloud.yaml
6868
imagePullPolicy: "IfNotPresent"
6969
ports:
7070
- containerPort: 9808

docs/migration/configuration.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Migration Guide: CCM and CSI Configuration to Unified YAML Format
2+
3+
## Introduction
4+
5+
This guide provides step-by-step instructions for migrating from the legacy Cloud Controller Manager (CCM) and Container Storage Interface (CSI) configurations to the new unified YAML-based configuration format.
6+
7+
## Overview
8+
9+
The migration involves:
10+
11+
- Updating CCM and CSI configurations to use the new unified YAML format
12+
- Mapping legacy configuration keys to new schema
13+
- Ensuring compatibility with the latest version of the STACKIT Kubernetes integration
14+
15+
**Note**: While the new format uses a unified structure, CCM and CSI configurations remain in separate files but follow the same YAML schema.
16+
17+
## Removed Configuration Options
18+
19+
The following configuration options have been removed in the new format:
20+
21+
### CCM
22+
23+
- `nonStackitClassNames` - No longer supported
24+
25+
### CSI
26+
27+
- `node-volume-attach-limit` - No longer configurable
28+
29+
## Old Configuration Reference
30+
31+
### CCM Configuration
32+
33+
```yaml
34+
# cloudprovider.yaml
35+
projectId: my-stackit-project-id
36+
networkId: my-stackit-network-id
37+
region: eu01
38+
nonStackitClassNames: my-non-stackit-class
39+
extraLabels:
40+
key1: value1
41+
key2: value2
42+
metadata:
43+
searchOrder: "configDrive,metadataService"
44+
requestTimeout: "5s"
45+
loadBalancerApi:
46+
url: https://loadbalancer.example.com
47+
```
48+
49+
### CSI Configuration
50+
51+
```ini
52+
# cloudprovider.conf
53+
[Global]
54+
project-id = "my-stackit-project-id"
55+
iaas-api-url = "https://iaas.example.com"
56+
[Metadata]
57+
search-order = "configDrive,metadataService"
58+
request-timeout = "5s"
59+
[BlockStorage]
60+
node-volume-attach-limit = 20
61+
rescan-on-resize = true
62+
```
63+
64+
## New Configuration Reference
65+
66+
### CCM Configuration
67+
68+
```yaml
69+
# cloudprovider.yaml
70+
global:
71+
projectId: my-stackit-project-id
72+
region: eu01
73+
metadata:
74+
searchOrder: "configDrive,metadataService"
75+
requestTimeout: "5s"
76+
loadBalancer:
77+
api: https://loadbalancer.example.com
78+
networkId: my-stackit-network-id
79+
extraLabels:
80+
key1: value1
81+
key2: value2
82+
```
83+
84+
### CSI Configuration
85+
86+
```yaml
87+
# cloudprovider.conf
88+
global:
89+
projectId: my-stackit-project-id
90+
iaasApi: https://iaas.example.com
91+
metadata:
92+
searchOrder: "configDrive,metadataService"
93+
requestTimeout: "5s"
94+
blockStorage:
95+
rescanOnResize: true
96+
```

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ require (
1919
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0
2020
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.7.0
2121
go.uber.org/mock v0.6.0
22+
go.yaml.in/yaml/v2 v2.4.3
2223
golang.org/x/sync v0.19.0
2324
golang.org/x/sys v0.40.0
2425
google.golang.org/grpc v1.78.0
2526
google.golang.org/protobuf v1.36.11
26-
gopkg.in/gcfg.v1 v1.2.3
2727
gopkg.in/yaml.v3 v3.0.1
2828
k8s.io/api v0.34.3
2929
k8s.io/apimachinery v0.34.3
@@ -114,7 +114,6 @@ require (
114114
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
115115
go.uber.org/multierr v1.11.0 // indirect
116116
go.uber.org/zap v1.27.0 // indirect
117-
go.yaml.in/yaml/v2 v2.4.3 // indirect
118117
go.yaml.in/yaml/v3 v3.0.4 // indirect
119118
golang.org/x/crypto v0.44.0 // indirect
120119
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
@@ -130,7 +129,6 @@ require (
130129
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
131130
gopkg.in/inf.v0 v0.9.1 // indirect
132131
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
133-
gopkg.in/warnings.v0 v0.1.2 // indirect
134132
gopkg.in/yaml.v2 v2.4.0 // indirect
135133
k8s.io/apiserver v0.34.2 // indirect
136134
k8s.io/component-helpers v0.34.2 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,10 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
345345
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
346346
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
347347
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
348-
gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs=
349-
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
350348
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
351349
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
352350
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
353351
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
354-
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
355-
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
356352
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
357353
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
358354
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

pkg/ccm/instances.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func NewInstance(client stackit.NodeClient, projectID, region string) (*Instance
6565
func (i *Instances) InstanceExists(ctx context.Context, node *corev1.Node) (bool, error) {
6666
_, err := i.getInstance(ctx, node)
6767
if errors.Is(err, cloudprovider.InstanceNotFound) {
68-
klog.V(6).Infof("instance not found for node: %s", node.Name)
68+
klog.V(6).Infof("Instance not found for node: %s", node.Name)
6969
return false, nil
7070
}
7171
if err != nil {
@@ -94,7 +94,7 @@ func (i *Instances) InstanceShutdown(ctx context.Context, node *corev1.Node) (bo
9494
func (i *Instances) InstanceMetadata(ctx context.Context, node *corev1.Node) (*cloudprovider.InstanceMetadata, error) {
9595
server, err := i.getInstance(ctx, node)
9696
if errors.Is(err, cloudprovider.InstanceNotFound) {
97-
klog.V(6).Infof("instance not found for node: %s", node.Name)
97+
klog.V(6).Infof("Instance not found for node: %s", node.Name)
9898
return nil, nil
9999
}
100100
if err != nil {

pkg/ccm/loadbalancer.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,29 @@ type MetricsRemoteWrite struct {
3939

4040
// LoadBalancer is used for creating and maintaining load balancers.
4141
type LoadBalancer struct {
42-
client stackit.LoadbalancerClient
43-
recorder record.EventRecorder // set in CloudControllerManager.Initialize
44-
projectID string
45-
networkID string
46-
extraLabels map[string]string
42+
client stackit.LoadbalancerClient
43+
recorder record.EventRecorder // set in CloudControllerManager.Initialize
44+
projectID string
45+
opts LoadBalancerOpts
4746
// metricsRemoteWrite setting this enables remote writing of metrics and nil means it is disabled
4847
metricsRemoteWrite *MetricsRemoteWrite
4948
}
5049

50+
type LoadBalancerOpts struct {
51+
API string `yaml:"api"`
52+
NetworkID string `yaml:"networkId"`
53+
ExtraLabels map[string]string `yaml:"extraLabels"`
54+
}
55+
5156
var _ cloudprovider.LoadBalancer = (*LoadBalancer)(nil)
5257

53-
func NewLoadBalancer(client stackit.LoadbalancerClient, projectID, networkID string, extraLabels map[string]string, metricsRemoteWrite *MetricsRemoteWrite) (*LoadBalancer, error) { //nolint:lll // looks weird when shortened
58+
func NewLoadBalancer(client stackit.LoadbalancerClient, projectID string, opts LoadBalancerOpts, metricsRemoteWrite *MetricsRemoteWrite) (*LoadBalancer, error) { //nolint:lll // looks weird when shortened
5459
// LoadBalancer.recorder is set in CloudControllerManager.Initialize
5560
return &LoadBalancer{
5661
client: client,
5762
projectID: projectID,
58-
networkID: networkID,
63+
opts: opts,
5964
metricsRemoteWrite: metricsRemoteWrite,
60-
extraLabels: extraLabels,
6165
}, nil
6266
}
6367

@@ -126,7 +130,7 @@ func (l *LoadBalancer) EnsureLoadBalancer( //nolint:gocyclo // not really comple
126130
return nil, fmt.Errorf("reconcile metricsRemoteWrite: %w", err)
127131
}
128132

129-
spec, events, err := lbSpecFromService(service, nodes, l.networkID, l.extraLabels, observabilityOptions)
133+
spec, events, err := lbSpecFromService(service, nodes, l.opts, observabilityOptions)
130134
if err != nil {
131135
return nil, fmt.Errorf("invalid load balancer specification: %w", err)
132136
}
@@ -206,12 +210,12 @@ func (l *LoadBalancer) createLoadBalancer(ctx context.Context, clusterName strin
206210
return nil, fmt.Errorf("reconcile metricsRemoteWrite: %w", err)
207211
}
208212

209-
spec, events, err := lbSpecFromService(service, nodes, l.networkID, l.extraLabels, metricsRemoteWrite)
213+
spec, events, err := lbSpecFromService(service, nodes, l.opts, metricsRemoteWrite)
210214
if err != nil {
211215
return nil, fmt.Errorf("invalid load balancer specification: %w", err)
212216
}
213-
if l.extraLabels != nil {
214-
spec.Labels = ptr.To(l.extraLabels)
217+
if l.opts.ExtraLabels != nil {
218+
spec.Labels = ptr.To(l.opts.ExtraLabels)
215219
}
216220
for _, event := range events {
217221
l.recorder.Event(service, event.Type, event.Reason, event.Message)
@@ -238,7 +242,7 @@ func (l *LoadBalancer) createLoadBalancer(ctx context.Context, clusterName strin
238242
// It is not called on controller start-up. EnsureLoadBalancer must also ensure to update targets.
239243
func (l *LoadBalancer) UpdateLoadBalancer(ctx context.Context, clusterName string, service *corev1.Service, nodes []*corev1.Node) error {
240244
// only TargetPools are used from spec
241-
spec, events, err := lbSpecFromService(service, nodes, l.networkID, l.extraLabels, nil)
245+
spec, events, err := lbSpecFromService(service, nodes, l.opts, nil)
242246
if err != nil {
243247
return fmt.Errorf("invalid service: %w", err)
244248
}

pkg/ccm/loadbalancer_spec.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,15 @@ func getPlanID(service *corev1.Service) (planID *string, msgs []string, err erro
244244
func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
245245
service *corev1.Service,
246246
nodes []*corev1.Node,
247-
networkID string,
248-
extraLabels map[string]string,
247+
opts LoadBalancerOpts,
249248
observability *loadbalancer.LoadbalancerOptionObservability,
250249
) (*loadbalancer.CreateLoadBalancerPayload, []Event, error) {
251250
lb := &loadbalancer.CreateLoadBalancerPayload{
252251
Options: &loadbalancer.LoadBalancerOptions{},
253252
Networks: &[]loadbalancer.Network{
254253
{
255254
Role: utils.Ptr(loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS),
256-
NetworkId: &networkID,
255+
NetworkId: &opts.NetworkID,
257256
},
258257
},
259258
}
@@ -262,7 +261,7 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
262261
lb.Networks = &[]loadbalancer.Network{
263262
{
264263
Role: utils.Ptr(loadbalancer.NETWORKROLE_TARGETS),
265-
NetworkId: &networkID,
264+
NetworkId: &opts.NetworkID,
266265
}, {
267266
Role: utils.Ptr(loadbalancer.NETWORKROLE_LISTENERS),
268267
NetworkId: &listenerNetwork,
@@ -272,14 +271,14 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
272271
lb.Networks = &[]loadbalancer.Network{
273272
{
274273
Role: utils.Ptr(loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS),
275-
NetworkId: &networkID,
274+
NetworkId: &opts.NetworkID,
276275
},
277276
}
278277
}
279278

280279
// Add extraLabels if set
281-
if extraLabels != nil {
282-
lb.Labels = ptr.To(extraLabels)
280+
if opts.ExtraLabels != nil {
281+
lb.Labels = ptr.To(opts.ExtraLabels)
283282
}
284283

285284
// Add metric metricsRemoteWrite settings

0 commit comments

Comments
 (0)