Skip to content

Commit

Permalink
protokube - query host by label when setting master tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Menezes committed Dec 11, 2020
1 parent 916ff32 commit 01842c3
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 01842c3

Please sign in to comment.