Skip to content

Commit

Permalink
Merge pull request #7339 from justinmir/kwok-provider-metrics-annotation
Browse files Browse the repository at this point in the history
Add metrics-server annotation for kwok-provider managed nodes
  • Loading branch information
k8s-ci-robot authored Jan 17, 2025
2 parents 31f5616 + e26ef60 commit 027795a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cluster-autoscaler/cloudprovider/kwok/kwok_nodegroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (nodeGroup *NodeGroup) IncreaseSize(delta int) error {
for i := 0; i < delta; i++ {
node := schedNode.Node()
node.Name = fmt.Sprintf("%s-%s", nodeGroup.name, rand.String(5))
if node.Annotations == nil {
node.Annotations = map[string]string{}
}
node.Annotations["metrics.k8s.io/resource-metrics-path"] = fmt.Sprintf("/metrics/nodes/%s/metrics/resource", node.Name)
node.Spec.ProviderID = getProviderID(node.Name)
_, err := nodeGroup.kubeClient.CoreV1().Nodes().Create(context.Background(), node, v1.CreateOptions{})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestIncreaseSize(t *testing.T) {
for _, n := range nodes {
assert.Contains(t, n.Spec.ProviderID, "kwok")
assert.Contains(t, n.GetName(), ng.name)
assert.Contains(t, n.Annotations["metrics.k8s.io/resource-metrics-path"], fmt.Sprintf("/metrics/nodes/%s/metrics/resource", n.GetName()))
}

// delta is negative
Expand Down

0 comments on commit 027795a

Please sign in to comment.