Skip to content

Commit

Permalink
Merge pull request #4228 from twz123/k0s-cloud-provider-id
Browse files Browse the repository at this point in the history
Let k0s cloud provider assign a node's provider ID
  • Loading branch information
twz123 authored Apr 22, 2024
2 parents b313016 + 11fbff0 commit ae27910
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions inttest/k0scloudprovider/k0scloudprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ func (s *K0sCloudProviderSuite) TestK0sGetsUp() {
s.Require().NoError(err)
s.Require().NoError(s.WaitJoinAPI(s.ControllerNode(0)))

err = s.WaitForNodeReady(s.WorkerNode(0), kc)
nodeName := s.WorkerNode(0)
err = s.WaitForNodeReady(nodeName, kc)
s.Require().NoError(err)

s.testAddAddress(ctx, kc, s.WorkerNode(0), "1.2.3.4")
s.testAddAddress(ctx, kc, s.WorkerNode(0), "2041:0000:140F::875B:131B")
s.testAddAddress(ctx, kc, s.WorkerNode(0), "GIGO")
node, err := kc.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
s.Require().NoError(err)
s.Equal("k0s-cloud-provider://"+nodeName, node.Spec.ProviderID)

s.testAddAddress(ctx, kc, nodeName, "1.2.3.4")
s.testAddAddress(ctx, kc, nodeName, "2041:0000:140F::875B:131B")
s.testAddAddress(ctx, kc, nodeName, "GIGO")
}

// testAddAddress adds the provided address to a node and ensures that the
Expand Down
2 changes: 1 addition & 1 deletion pkg/k0scloudprovider/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (i *instancesV2) InstanceShutdown(ctx context.Context, node *v1.Node) (bool
// properties of the node like its name, labels and annotations.
func (i *instancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) {
return &cloudprovider.InstanceMetadata{
ProviderID: node.Spec.ProviderID,
ProviderID: Name + "://" + node.Name,
InstanceType: Name,
NodeAddresses: i.addressCollector(node),
}, nil
Expand Down

0 comments on commit ae27910

Please sign in to comment.