Test API more extensivelly before declaring readiness (close #34411)
This commit is contained in:
parent
ead65fc25f
commit
53e393ad42
@ -34,6 +34,7 @@ const (
|
|||||||
KubeDNSImage = "kube-dns"
|
KubeDNSImage = "kube-dns"
|
||||||
KubeDNSmasqImage = "dnsmasq"
|
KubeDNSmasqImage = "dnsmasq"
|
||||||
KubeExechealthzImage = "exechealthz"
|
KubeExechealthzImage = "exechealthz"
|
||||||
|
Pause = "pause"
|
||||||
|
|
||||||
gcrPrefix = "gcr.io/google_containers"
|
gcrPrefix = "gcr.io/google_containers"
|
||||||
etcdVersion = "2.2.5"
|
etcdVersion = "2.2.5"
|
||||||
@ -41,6 +42,7 @@ const (
|
|||||||
kubeDNSVersion = "1.7"
|
kubeDNSVersion = "1.7"
|
||||||
dnsmasqVersion = "1.3"
|
dnsmasqVersion = "1.3"
|
||||||
exechealthzVersion = "1.1"
|
exechealthzVersion = "1.1"
|
||||||
|
pauseVersion = "3.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetCoreImage(image string, cfg *kubeadmapi.MasterConfiguration, overrideImage string) string {
|
func GetCoreImage(image string, cfg *kubeadmapi.MasterConfiguration, overrideImage string) string {
|
||||||
@ -62,5 +64,6 @@ func GetAddonImage(image string) string {
|
|||||||
KubeDNSImage: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "kubedns", runtime.GOARCH, kubeDNSVersion),
|
KubeDNSImage: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "kubedns", runtime.GOARCH, kubeDNSVersion),
|
||||||
KubeDNSmasqImage: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "kube-dnsmasq", runtime.GOARCH, dnsmasqVersion),
|
KubeDNSmasqImage: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "kube-dnsmasq", runtime.GOARCH, dnsmasqVersion),
|
||||||
KubeExechealthzImage: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "exechealthz", runtime.GOARCH, exechealthzVersion),
|
KubeExechealthzImage: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "exechealthz", runtime.GOARCH, exechealthzVersion),
|
||||||
|
Pause: fmt.Sprintf("%s/%s-%s:%s", gcrPrefix, "pause", runtime.GOARCH, pauseVersion),
|
||||||
}[image]
|
}[image]
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/cmd/kubeadm/app/images"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
||||||
unversionedapi "k8s.io/kubernetes/pkg/api/unversioned"
|
unversionedapi "k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
@ -96,6 +97,8 @@ func CreateClientAndWaitForAPI(adminConfig *clientcmdapi.Config) (*clientset.Cli
|
|||||||
return true, nil
|
return true, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createDummyDeployment(client)
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,3 +222,41 @@ func SetMasterNodeAffinity(meta *api.ObjectMeta) {
|
|||||||
}
|
}
|
||||||
meta.Annotations[api.AffinityAnnotationKey] = string(affinityAnnotation)
|
meta.Annotations[api.AffinityAnnotationKey] = string(affinityAnnotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createDummyDeployment(client *clientset.Clientset) {
|
||||||
|
fmt.Println("<master/apiclient> attempting a test deployment")
|
||||||
|
dummyDeployment := NewDeployment("dummy", 1, api.PodSpec{
|
||||||
|
SecurityContext: &api.PodSecurityContext{HostNetwork: true},
|
||||||
|
Containers: []api.Container{{
|
||||||
|
Name: "dummy",
|
||||||
|
Image: images.GetAddonImage("pause"),
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
|
||||||
|
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
|
||||||
|
// TODO: we should check the error, as some cases may be fatal
|
||||||
|
if _, err := client.Extensions().Deployments(api.NamespaceSystem).Create(dummyDeployment); err != nil {
|
||||||
|
fmt.Printf("<master/apiclient> failed to create test deployment [%v] (will retry)", err)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
wait.PollInfinite(apiCallRetryInterval, func() (bool, error) {
|
||||||
|
d, err := client.Extensions().Deployments(api.NamespaceSystem).Get("dummy")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("<master/apiclient> failed to get test deployment [%v] (will retry)", err)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
if d.Status.AvailableReplicas < 1 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
fmt.Println("<master/apiclient> test deployment succeeded")
|
||||||
|
|
||||||
|
if err := client.Extensions().Deployments(api.NamespaceSystem).Delete("dummy", &api.DeleteOptions{}); err != nil {
|
||||||
|
fmt.Printf("<master/apiclient> failed to delete test deployment [%v] (will ignore)", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user