From 521d8d05e5b9e6276e8289c5480aa14d3f5ace09 Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Tue, 11 Jul 2023 23:09:12 +0000 Subject: [PATCH] provisioner-azure: Use API to label nodes Fixes #1183 Signed-off-by: Suraj Deshmukh --- test/provisioner/provision_azure.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/test/provisioner/provision_azure.go b/test/provisioner/provision_azure.go index b10842eaa..8a3d0790c 100644 --- a/test/provisioner/provision_azure.go +++ b/test/provisioner/provision_azure.go @@ -13,7 +13,6 @@ import ( "fmt" "net/http" "os" - "os/exec" "path" "time" @@ -235,6 +234,7 @@ func (p *AzureCloudProvisioner) CreateCluster(ctx context.Context, cfg *envconf. OSType: to.Ptr(armcontainerservice.OSType(AzureProps.OsType)), EnableNodePublicIP: to.Ptr(false), VnetSubnetID: &AzureProps.SubnetID, + NodeLabels: map[string]*string{"node.kubernetes.io/worker": to.Ptr("")}, }, }, ServicePrincipalProfile: &armcontainerservice.ManagedClusterServicePrincipalProfile{ @@ -305,16 +305,6 @@ func (p *AzureCloudProvisioner) CreateCluster(ctx context.Context, cfg *envconf. cfg.WithKubeconfigFile(kubeconfigPath) - // Update this to use label while provisioning cluster - cmd := exec.Command("kubectl", "label", "nodes", "--all", fmt.Sprintf("%s=%s", "node.kubernetes.io/worker", "")) - cmd.Env = append(cmd.Env, fmt.Sprintf("KUBECONFIG="+kubeconfigPath)) - - _, err = cmd.CombinedOutput() - if err != nil { - return fmt.Errorf("labeling nodes: %w", err) - } - log.Info("Nodes labeled successfully.") - return nil }