Skip to content

Commit

Permalink
Merge pull request #10413 from rdrgmnzs/fix-bootstrapMasterNodeLabels
Browse files Browse the repository at this point in the history
protokube - query host by label when setting tags
  • Loading branch information
k8s-ci-robot authored Dec 18, 2020
2 parents 25eb1c9 + 01842c3 commit cbb418c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion protokube/pkg/protokube/labeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ func bootstrapMasterNodeLabels(ctx context.Context, kubeContext *KubernetesConte
}

klog.V(2).Infof("Querying k8s for node %q", nodeName)
node, err := client.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
labelSelector := fmt.Sprintf("kubernetes.io/hostname=%s", nodeName)
listOptions := metav1.ListOptions{
LabelSelector: labelSelector,
}
nodes, err := client.CoreV1().Nodes().List(ctx, listOptions)
if err != nil {
return fmt.Errorf("error querying node %q: %v", nodeName, err)
} else if len(nodes.Items) != 1 {
return fmt.Errorf("error querying node %q: expected 1 node with label %v, found %d", nodeName, labelSelector, len(nodes.Items))
}
node := nodes.Items[0]

labels := map[string]string{
"node-role.kubernetes.io/master": "",
Expand Down

0 comments on commit cbb418c

Please sign in to comment.