Skip to content

Commit 11fbff0

Browse files
committed
Let k0s-cloud provider assign a node's provider ID
Since Kubernetes commit 53d38a31611, it is required for cloud providers to assign a provider ID to each node. Let k0s comply with that requirement. Signed-off-by: Tom Wieczorek <[email protected]>
1 parent 2db9128 commit 11fbff0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

inttest/k0scloudprovider/k0scloudprovider_test.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ func (s *K0sCloudProviderSuite) TestK0sGetsUp() {
4848
s.Require().NoError(err)
4949
s.Require().NoError(s.WaitJoinAPI(s.ControllerNode(0)))
5050

51-
err = s.WaitForNodeReady(s.WorkerNode(0), kc)
51+
nodeName := s.WorkerNode(0)
52+
err = s.WaitForNodeReady(nodeName, kc)
5253
s.Require().NoError(err)
5354

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

5964
// testAddAddress adds the provided address to a node and ensures that the

pkg/k0scloudprovider/instances.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (i *instancesV2) InstanceShutdown(ctx context.Context, node *v1.Node) (bool
5656
// properties of the node like its name, labels and annotations.
5757
func (i *instancesV2) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) {
5858
return &cloudprovider.InstanceMetadata{
59-
ProviderID: node.Spec.ProviderID,
59+
ProviderID: Name + "://" + node.Name,
6060
InstanceType: Name,
6161
NodeAddresses: i.addressCollector(node),
6262
}, nil

0 commit comments

Comments
 (0)