Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
9db86d91
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9db86d91
编写于
10月 18, 2019
作者:
T
Thomas Strömberg
提交者:
GitHub
10月 18, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5592 from tstromberg/sshcheck
Add networking validation to validateNetwork
上级
3161c4e8
8ca74ef1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
10 deletion
+59
-10
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+52
-8
pkg/minikube/bootstrapper/images/images.go
pkg/minikube/bootstrapper/images/images.go
+7
-2
未找到文件。
cmd/minikube/cmd/start.go
浏览文件 @
9db86d91
...
...
@@ -459,8 +459,12 @@ func startMachine(config *cfg.Config) (runner command.Runner, preExists bool, ma
exit
.
WithError
(
"Failed to get machine client"
,
err
)
}
host
,
preExists
=
startHost
(
m
,
config
.
MachineConfig
)
runner
,
err
=
machine
.
CommandRunner
(
host
)
if
err
!=
nil
{
exit
.
WithError
(
"Failed to get command runner"
,
err
)
}
ip
:=
validateNetwork
(
host
)
ip
:=
validateNetwork
(
host
,
runner
)
// Bypass proxy for minikube's vm host ip
err
=
proxy
.
ExcludeIP
(
ip
)
if
err
!=
nil
{
...
...
@@ -471,10 +475,6 @@ func startMachine(config *cfg.Config) (runner command.Runner, preExists bool, ma
if
err
:=
saveConfig
(
config
);
err
!=
nil
{
exit
.
WithError
(
"Failed to save config"
,
err
)
}
runner
,
err
=
machine
.
CommandRunner
(
host
)
if
err
!=
nil
{
exit
.
WithError
(
"Failed to get command runner"
,
err
)
}
return
runner
,
preExists
,
m
,
host
}
...
...
@@ -811,7 +811,7 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, driver string)
repository
=
autoSelectedRepository
}
if
repository
!=
""
{
if
cmd
.
Flags
()
.
Changed
(
imageRepository
)
{
out
.
T
(
out
.
SuccessType
,
"Using image repository {{.name}}"
,
out
.
V
{
"name"
:
repository
})
}
...
...
@@ -952,7 +952,7 @@ func startHost(api libmachine.API, mc cfg.MachineConfig) (*host.Host, bool) {
}
// validateNetwork tries to catch network problems as soon as possible
func
validateNetwork
(
h
*
host
.
Host
)
string
{
func
validateNetwork
(
h
*
host
.
Host
,
r
command
.
Runner
)
string
{
ip
,
err
:=
h
.
Driver
.
GetIP
()
if
err
!=
nil
{
exit
.
WithError
(
"Unable to get VM IP address"
,
err
)
...
...
@@ -976,7 +976,51 @@ func validateNetwork(h *host.Host) string {
}
}
// Here is where we should be checking connectivity to/from the VM
// none driver does not need ssh access
if
h
.
Driver
.
DriverName
()
!=
constants
.
DriverNone
{
sshAddr
:=
fmt
.
Sprintf
(
"%s:22"
,
ip
)
conn
,
err
:=
net
.
Dial
(
"tcp"
,
sshAddr
)
if
err
!=
nil
{
exit
.
WithCodeT
(
exit
.
IO
,
`minikube is unable to connect to the VM: {{.error}}
This is likely due to one of two reasons:
- VPN or firewall interference
- {{.hypervisor}} network configuration issue
Suggested workarounds:
- Disable your local VPN or firewall software
- Configure your local VPN or firewall to allow access to {{.ip}}
- Restart or reinstall {{.hypervisor}}
- Use an alternative --vm-driver`
,
out
.
V
{
"error"
:
err
,
"hypervisor"
:
h
.
Driver
.
DriverName
(),
"ip"
:
ip
})
}
defer
conn
.
Close
()
}
if
err
:=
r
.
Run
(
"nslookup kubernetes.io"
);
err
!=
nil
{
out
.
WarningT
(
"VM is unable to resolve DNS hosts: {[.error}}"
,
out
.
V
{
"error"
:
err
})
}
// Try both UDP and ICMP to assert basic external connectivity
if
err
:=
r
.
Run
(
"nslookup k8s.io 8.8.8.8 || nslookup k8s.io 1.1.1.1 || ping -c1 8.8.8.8"
);
err
!=
nil
{
out
.
WarningT
(
"VM is unable to directly connect to the internet: {{.error}}"
,
out
.
V
{
"error"
:
err
})
}
// Try an HTTPS connection to the
proxy
:=
os
.
Getenv
(
"HTTPS_PROXY"
)
opts
:=
"-sS"
if
proxy
!=
""
&&
!
strings
.
HasPrefix
(
proxy
,
"localhost"
)
&&
!
strings
.
HasPrefix
(
proxy
,
"127.0"
)
{
opts
=
fmt
.
Sprintf
(
"-x %s %s"
,
proxy
,
opts
)
}
repo
:=
viper
.
GetString
(
imageRepository
)
if
repo
==
""
{
repo
=
images
.
DefaultImageRepo
}
if
err
:=
r
.
Run
(
fmt
.
Sprintf
(
"curl %s https://%s/"
,
opts
,
repo
));
err
!=
nil
{
out
.
WarningT
(
"VM is unable to connect to the selected image repository: {{.error}}"
,
out
.
V
{
"error"
:
err
})
}
return
ip
}
...
...
pkg/minikube/bootstrapper/images/images.go
浏览文件 @
9db86d91
...
...
@@ -25,10 +25,15 @@ import (
minikubeVersion
"k8s.io/minikube/pkg/version"
)
const
(
DefaultImageRepo
=
"k8s.gcr.io"
DefaultMinikubeRepo
=
"gcr.io/k8s-minikube"
)
// getImageRepositories returns either the k8s image registry on GCR or a mirror if specified
func
getImageRepository
(
imageRepository
string
)
string
{
if
imageRepository
==
""
{
imageRepository
=
"k8s.gcr.io"
imageRepository
=
DefaultImageRepo
}
if
!
strings
.
HasSuffix
(
imageRepository
,
"/"
)
{
imageRepository
+=
"/"
...
...
@@ -41,7 +46,7 @@ func getImageRepository(imageRepository string) string {
func
getMinikubeRepository
(
imageRepository
string
)
string
{
minikubeRepository
:=
imageRepository
if
minikubeRepository
==
""
{
minikubeRepository
=
"gcr.io/k8s-minikube"
minikubeRepository
=
DefaultMinikubeRepo
}
if
!
strings
.
HasSuffix
(
minikubeRepository
,
"/"
)
{
minikubeRepository
+=
"/"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录