e2e: fetch volume metrics from Kubelet

Test if metrics are available at all. The actual values are a little
difficult to validate.

BlockMode volumes support metrics since Kubernetes 1.22.

See-also: kubernetes/kubernetes#97972
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2021-01-14 08:47:57 +01:00
committed by mergify[bot]
parent 25d0a1cfc0
commit 2b9f6c3598
4 changed files with 81 additions and 4 deletions

View File

@ -2,7 +2,9 @@ package e2e
import (
"context"
"errors"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
@ -42,3 +44,20 @@ func checkNodeHasLabel(c kubernetes.Interface, labelKey, labelValue string) erro
}
return nil
}
// List all nodes in the cluster (we have one), and return the IP-address.
// Possibly need to add a selector, pick the node where a Pod is running?
func getKubeletIP(c kubernetes.Interface) (string, error) {
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
if err != nil {
return "", err
}
for _, address := range nodes.Items[0].Status.Addresses {
if address.Type == core.NodeInternalIP {
return address.Address, nil
}
}
return "", errors.New("could not find internal IP for node")
}