From 812b2cea11c957381031facec2c5586e6a2cc8bc Mon Sep 17 00:00:00 2001 From: kiootic Date: Tue, 4 Jul 2023 11:59:46 +0800 Subject: [PATCH] Provide runner labels from kube node annotations --- pkg/kube/controller.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/kube/controller.go b/pkg/kube/controller.go index ae1b7fc..c3b3226 100644 --- a/pkg/kube/controller.go +++ b/pkg/kube/controller.go @@ -131,6 +131,18 @@ func (p *ControllerProvider) RegisterAgent( group := annotations[annotationRunnerGroup] labels := strings.Split(annotations[annotationRunnerLabels], ",") + if pod.Spec.NodeName != "" { + node, err := p.kube.CoreV1().Nodes().Get(r.Context(), pod.Spec.NodeName, metav1.GetOptions{}) + if err != nil { + p.logger.Error("failed to get node", + zap.String("nodeName", pod.Spec.NodeName), + zap.Error(err)) + } else { + nodeRunnerLabels := strings.Split(node.Annotations[annotationRunnerLabels], ",") + labels = append(labels, nodeRunnerLabels...) + } + } + agent, err := p.state.makeAgent(pod, hostName) if err != nil { return nil, err