Skip to content

Commit 981d960

Browse files
Add overwrite config for Infrastructure API in instance controller (#515)
Co-authored-by: Maximilian Geberl <maximilian.geberl@stackit.cloud>
1 parent 5797e98 commit 981d960

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/ccm/instances.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ type Instances struct {
5252
region string
5353
}
5454

55+
type InstancesOpts struct {
56+
API string `yaml:"api"`
57+
}
58+
5559
func NewInstance(client stackit.NodeClient, projectID, region string) (*Instances, error) {
5660
return &Instances{
5761
iaasClient: client,

pkg/ccm/stackit.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Config struct {
4646
Global stackit.GlobalOpts `yaml:"global"`
4747
Metadata metadata.Opts `yaml:"metadata"`
4848
LoadBalancer LoadBalancerOpts `yaml:"loadBalancer"`
49+
Instances InstancesOpts `yaml:"instances"`
4950
}
5051

5152
func init() {
@@ -150,7 +151,15 @@ func NewCloudControllerManager(cfg *Config, obs *MetricsRemoteWrite) (*CloudCont
150151
return nil, err
151152
}
152153

153-
iaasInnerClient, err := iaas.NewAPIClient()
154+
iaasOpts := []sdkconfig.ConfigurationOption{
155+
sdkconfig.WithHTTPClient(metrics.NewInstrumentedHTTPClient()),
156+
}
157+
158+
if cfg.Instances.API != "" {
159+
iaasOpts = append(iaasOpts, sdkconfig.WithEndpoint(cfg.Instances.API))
160+
}
161+
162+
iaasInnerClient, err := iaas.NewAPIClient(iaasOpts...)
154163
if err != nil {
155164
return nil, fmt.Errorf("failed to create IaaS client: %v", err)
156165
}

0 commit comments

Comments
 (0)