mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Update serve_hostnames node check with namespace creation
This commit is contained in:
parent
d7f7d84a5e
commit
55580b2490
@ -25,10 +25,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
@ -67,7 +65,7 @@ func main() {
|
|||||||
if *gke != "" {
|
if *gke != "" {
|
||||||
spec = filepath.Join(os.Getenv("HOME"), ".config", "gcloud", "kubernetes", "kubeconfig")
|
spec = filepath.Join(os.Getenv("HOME"), ".config", "gcloud", "kubernetes", "kubeconfig")
|
||||||
} else {
|
} else {
|
||||||
spec = filepath.Join(os.Getenv("HOME"), ".kube", ".kubeconfig")
|
spec = filepath.Join(os.Getenv("HOME"), ".kube", "config")
|
||||||
}
|
}
|
||||||
settings, err := clientcmd.LoadFromFile(spec)
|
settings, err := clientcmd.LoadFromFile(spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -109,10 +107,18 @@ func main() {
|
|||||||
|
|
||||||
queries := *queriesAverage * len(nodes.Items) * *podsPerNode
|
queries := *queriesAverage * len(nodes.Items) * *podsPerNode
|
||||||
|
|
||||||
// Make a unique namespace for this test.
|
// Create the namespace
|
||||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
got, err := c.Namespaces().Create(&api.Namespace{ObjectMeta: api.ObjectMeta{GenerateName: "serve-hostnames-"}})
|
||||||
ns := "serve-hostnames-" + strconv.Itoa(r.Int()%10000)
|
if err != nil {
|
||||||
glog.Infof("Using namespace %s for this test.", ns)
|
glog.Fatalf("Failed to create namespace: %v", err)
|
||||||
|
}
|
||||||
|
ns := got.Name
|
||||||
|
defer func(ns string) {
|
||||||
|
if err := c.Namespaces().Delete(ns); err != nil {
|
||||||
|
glog.Warningf("Failed to delete namespace ns: %e", ns, err)
|
||||||
|
}
|
||||||
|
}(ns)
|
||||||
|
glog.Infof("Created namespace %s", ns)
|
||||||
|
|
||||||
// Create a service for these pods.
|
// Create a service for these pods.
|
||||||
glog.Infof("Creating service %s/serve-hostnames", ns)
|
glog.Infof("Creating service %s/serve-hostnames", ns)
|
||||||
|
Loading…
Reference in New Issue
Block a user