mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Get nodes from GKE node pool by checking labels
This commit is contained in:
parent
1bdcfa59e8
commit
158ffdb1ec
@ -230,11 +230,9 @@ var _ = SIGDescribe("Cluster size autoscaling [Slow]", func() {
|
|||||||
glog.Infof("Not enabling cluster autoscaler for the node pool (on purpose).")
|
glog.Infof("Not enabling cluster autoscaler for the node pool (on purpose).")
|
||||||
|
|
||||||
By("Get memory available on new node, so we can account for it when creating RC")
|
By("Get memory available on new node, so we can account for it when creating RC")
|
||||||
nodes, err := framework.GetGroupNodes(extraPoolName)
|
nodes := getPoolNodes(f, extraPoolName)
|
||||||
framework.ExpectNoError(err)
|
|
||||||
Expect(len(nodes)).Should(Equal(1))
|
Expect(len(nodes)).Should(Equal(1))
|
||||||
node, err := f.ClientSet.Core().Nodes().Get(nodes[0], metav1.GetOptions{})
|
extraMem := nodes[0].Status.Capacity[v1.ResourceMemory]
|
||||||
extraMem := node.Status.Capacity[v1.ResourceMemory]
|
|
||||||
extraMemMb := int((&extraMem).Value() / 1024 / 1024)
|
extraMemMb := int((&extraMem).Value() / 1024 / 1024)
|
||||||
|
|
||||||
ReserveMemory(f, "memory-reservation", 100, nodeCount*memCapacityMb+extraMemMb, false, defaultTimeout)
|
ReserveMemory(f, "memory-reservation", 100, nodeCount*memCapacityMb+extraMemMb, false, defaultTimeout)
|
||||||
@ -890,6 +888,17 @@ func deleteNodePool(name string) {
|
|||||||
glog.Infof("Node-pool deletion output: %s", output)
|
glog.Infof("Node-pool deletion output: %s", output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPoolNodes(f *framework.Framework, poolName string) []*v1.Node {
|
||||||
|
nodes := make([]*v1.Node, 0, 1)
|
||||||
|
nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
|
||||||
|
for _, node := range nodeList.Items {
|
||||||
|
if poolLabel := node.Labels["cloud.google.com/gke-nodepool"]; poolLabel == poolName {
|
||||||
|
nodes = append(nodes, &node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
func doPut(url, content string) (string, error) {
|
func doPut(url, content string) (string, error) {
|
||||||
req, err := http.NewRequest("PUT", url, bytes.NewBuffer([]byte(content)))
|
req, err := http.NewRequest("PUT", url, bytes.NewBuffer([]byte(content)))
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
Loading…
Reference in New Issue
Block a user