Merge pull request #4058 from moduspwnens/master
Fixed status checking with non-default apiserver-port.pull/3755/head
commit
fad8355f99
|
@ -215,7 +215,9 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
// The kube config must be update must come before bootstrapping, otherwise health checks may use a stale IP
|
||||
kubeconfig := updateKubeConfig(host, &config)
|
||||
bootstrapCluster(bs, cr, runner, config.KubernetesConfig, preexisting)
|
||||
validateCluster(bs, cr, runner, ip)
|
||||
|
||||
apiserverPort := config.KubernetesConfig.NodePort
|
||||
validateCluster(bs, cr, runner, ip, apiserverPort)
|
||||
configureMounts()
|
||||
if err = LoadCachedImagesInConfigFile(); err != nil {
|
||||
console.Failure("Unable to load cached images from config file.")
|
||||
|
@ -543,7 +545,7 @@ func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner b
|
|||
}
|
||||
|
||||
// validateCluster validates that the cluster is well-configured and healthy
|
||||
func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bootstrapper.CommandRunner, ip string) {
|
||||
func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bootstrapper.CommandRunner, ip string, apiserverPort int) {
|
||||
console.OutStyle("verifying-noline", "Verifying component health ...")
|
||||
k8sStat := func() (err error) {
|
||||
st, err := bs.GetKubeletStatus()
|
||||
|
@ -558,7 +560,7 @@ func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bo
|
|||
exit.WithLogEntries("kubelet checks failed", err, logs.FindProblems(r, bs, runner))
|
||||
}
|
||||
aStat := func() (err error) {
|
||||
st, err := bs.GetAPIServerStatus(net.ParseIP(ip))
|
||||
st, err := bs.GetAPIServerStatus(net.ParseIP(ip), apiserverPort)
|
||||
console.Out(".")
|
||||
if err != nil || st != state.Running.String() {
|
||||
return &pkgutil.RetriableError{Err: fmt.Errorf("apiserver status=%s err=%v", st, err)}
|
||||
|
|
|
@ -92,7 +92,13 @@ var statusCmd = &cobra.Command{
|
|||
glog.Errorln("Error host driver ip status:", err)
|
||||
}
|
||||
|
||||
apiserverSt, err = clusterBootstrapper.GetAPIServerStatus(ip)
|
||||
apiserverPort, err := pkgutil.GetPortFromKubeConfig(util.GetKubeConfigPath(), config.GetMachineName())
|
||||
if err != nil {
|
||||
// Fallback to presuming default apiserver port
|
||||
apiserverPort = pkgutil.APIServerPort
|
||||
}
|
||||
|
||||
apiserverSt, err = clusterBootstrapper.GetAPIServerStatus(ip, apiserverPort)
|
||||
if err != nil {
|
||||
glog.Errorln("Error apiserver status:", err)
|
||||
} else if apiserverSt != state.Running.String() {
|
||||
|
|
|
@ -43,7 +43,7 @@ type Bootstrapper interface {
|
|||
LogCommands(LogOptions) map[string]string
|
||||
SetupCerts(cfg config.KubernetesConfig) error
|
||||
GetKubeletStatus() (string, error)
|
||||
GetAPIServerStatus(net.IP) (string, error)
|
||||
GetAPIServerStatus(net.IP, int) (string, error)
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
@ -122,8 +122,8 @@ func (k *Bootstrapper) GetKubeletStatus() (string, error) {
|
|||
}
|
||||
|
||||
// GetAPIServerStatus returns the api-server status
|
||||
func (k *Bootstrapper) GetAPIServerStatus(ip net.IP) (string, error) {
|
||||
url := fmt.Sprintf("https://%s:%d/healthz", ip, util.APIServerPort)
|
||||
func (k *Bootstrapper) GetAPIServerStatus(ip net.IP, apiserverPort int) (string, error) {
|
||||
url := fmt.Sprintf("https://%s:%d/healthz", ip, apiserverPort)
|
||||
// To avoid: x509: certificate signed by unknown authority
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
|
|
|
@ -251,7 +251,7 @@ func UpdateKubeconfigIP(ip net.IP, filename string, machineName string) (bool, e
|
|||
if kip.Equal(ip) {
|
||||
return false, nil
|
||||
}
|
||||
kport, err := getPortFromKubeConfig(filename, machineName)
|
||||
kport, err := GetPortFromKubeConfig(filename, machineName)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -291,8 +291,8 @@ func getIPFromKubeConfig(filename, machineName string) (net.IP, error) {
|
|||
return ip, nil
|
||||
}
|
||||
|
||||
// getPortFromKubeConfig returns the Port number stored for minikube in the kubeconfig specified
|
||||
func getPortFromKubeConfig(filename, machineName string) (int, error) {
|
||||
// GetPortFromKubeConfig returns the Port number stored for minikube in the kubeconfig specified
|
||||
func GetPortFromKubeConfig(filename, machineName string) (int, error) {
|
||||
con, err := ReadConfigOrNew(filename)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "Error getting kubeconfig status")
|
||||
|
|
|
@ -46,9 +46,10 @@ func TestStartStop(t *testing.T) {
|
|||
"--extra-config=kubelet.network-plugin=cni",
|
||||
fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion),
|
||||
}},
|
||||
{"containerd", []string{
|
||||
{"containerd_and_non_default_apiserver_port", []string{
|
||||
"--container-runtime=containerd",
|
||||
"--docker-opt containerd=/var/run/containerd/containerd.sock",
|
||||
"--apiserver-port=8444",
|
||||
}},
|
||||
{"crio_ignore_preflights", []string{
|
||||
"--container-runtime=crio",
|
||||
|
|
Loading…
Reference in New Issue