Skip to content

Commit

Permalink
Merge pull request #88 from epenchev/master
Browse files Browse the repository at this point in the history
Introduce additional env vars.
  • Loading branch information
cwdsuzhou committed Apr 26, 2023
2 parents 2cc1d68 + acd8048 commit ad40680
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/provider/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ func podStopped(pod *corev1.Pod) bool {
return (pod.Status.Phase == corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed) && pod.Spec.
RestartPolicy == corev1.RestartPolicyNever
}

// nodeCustomLabel adds an additional node label.
// The label can be any customised meaningful label specified from user.
func nodeCustomLabel(node *corev1.Node, label string) {
nodelabel := strings.Split(label, ":")
if len(nodelabel) == 2 {
node.ObjectMeta.Labels[strings.TrimSpace(nodelabel[0])] = strings.TrimSpace(nodelabel[1])
}
}
6 changes: 6 additions & 0 deletions pkg/provider/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ func (v *VirtualK8S) ConfigureNode(ctx context.Context, node *corev1.Node) {
node.ObjectMeta.Labels[corev1.LabelArchStable] = "amd64"
node.ObjectMeta.Labels[corev1.LabelOSStable] = "linux"
node.ObjectMeta.Labels[util.LabelOSBeta] = "linux"
if label := os.Getenv("VKUBELET_NODE_LABEL"); label != "" {
nodeCustomLabel(node, label)
}
node.Status.Addresses = []corev1.NodeAddress{{Type: corev1.NodeInternalIP, Address: os.Getenv("VKUBELET_POD_IP")}}
if externalIP := os.Getenv("VKUBELET_EXTERNAL_POD_IP"); externalIP != "" {
node.Status.Addresses = append(node.Status.Addresses, corev1.NodeAddress{Type: corev1.NodeExternalIP, Address: externalIP})
}
node.Status.Conditions = nodeConditions()
node.Status.DaemonEndpoints = v.nodeDaemonEndpoints()
v.providerNode.Node = node
Expand Down

0 comments on commit ad40680

Please sign in to comment.