Skip to content

Commit

Permalink
add advertise address to api-server flags, doesn't seem to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Mia-Cross committed Apr 2, 2024
1 parent 0daaf3e commit 2ad6a20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions nodeup/pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/blang/semver/v4"
hcloudmetadata "github.com/hetznercloud/hcloud-go/hcloud/metadata"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
"k8s.io/klog/v2"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/model"
"k8s.io/kops/pkg/apis/kops/util"
"k8s.io/kops/pkg/apis/nodeup"
"k8s.io/kops/pkg/systemd"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/scaleway"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
"k8s.io/kops/upup/pkg/fi/utils"
"k8s.io/kops/util/pkg/architectures"
Expand Down Expand Up @@ -600,6 +603,24 @@ func (c *NodeupModelContext) GetMetadataLocalIP() (string, error) {
}
}

case kops.CloudProviderScaleway:
metadataAPI := instance.NewMetadataAPI()
metadata, err := metadataAPI.GetMetadata()
if err != nil {
return "", fmt.Errorf("failed to retrieve server metadata: %w", err)
}

zone, err := scw.ParseZone(metadata.Location.ZoneID)
if err != nil {
return "", fmt.Errorf("unable to parse Scaleway zone: %w", err)
}

ip, err := scaleway.GetIPAMPublicIP(nil, metadata.ID, zone)
if err != nil {
return "", fmt.Errorf("failed to retrieve server IP: %w", err)
}
internalIP = ip

default:
return "", fmt.Errorf("getting local IP from metadata is not supported for cloud provider: %q", c.BootConfig.CloudProvider)
}
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/model/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (b *KubeAPIServerBuilder) Build(c *fi.NodeupModelBuilderContext) error {
kubeAPIServer = *b.NodeupConfig.APIServerConfig.KubeAPIServer
}

if b.CloudProvider() == kops.CloudProviderHetzner {
if b.CloudProvider() == kops.CloudProviderHetzner || b.CloudProvider() == kops.CloudProviderScaleway {
localIP, err := b.GetMetadataLocalIP()
if err != nil {
return err
Expand Down

0 comments on commit 2ad6a20

Please sign in to comment.