Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
a15201b1
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,体验更适合开发者的 AI 搜索 >>
提交
a15201b1
编写于
8月 07, 2019
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove exit from kubeconfig update lib
上级
733ba21a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
18 deletion
+21
-18
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+6
-3
pkg/minikube/kubeconfig/kubeconfig_test.go
pkg/minikube/kubeconfig/kubeconfig_test.go
+3
-3
pkg/minikube/kubeconfig/setup.go
pkg/minikube/kubeconfig/setup.go
+5
-5
pkg/minikube/kubeconfig/update.go
pkg/minikube/kubeconfig/update.go
+7
-7
未找到文件。
cmd/minikube/cmd/start.go
浏览文件 @
a15201b1
...
...
@@ -307,7 +307,10 @@ func runStart(cmd *cobra.Command, args []string) {
bs
:=
setupKubeAdm
(
machineAPI
,
config
.
KubernetesConfig
)
// The kube config must be update must come before bootstrapping, otherwise health checks may use a stale IP
kubeconfig
:=
setupKubeconfig
(
host
,
&
config
)
kubeconfig
,
err
:=
setupKubeconfig
(
host
,
&
config
)
if
err
!=
nil
{
exit
.
WithError
(
"Failed to setup kubeconfig"
,
err
)
}
// pull images or restart cluster
bootstrapCluster
(
bs
,
cr
,
mRunner
,
config
.
KubernetesConfig
,
preExists
,
isUpgrade
)
...
...
@@ -326,12 +329,12 @@ func runStart(cmd *cobra.Command, args []string) {
}
func
setupKubeconfig
(
host
*
host
.
Host
,
config
*
cfg
.
Config
)
*
kubeconfig
.
Setup
{
func
setupKubeconfig
(
host
*
host
.
Host
,
config
*
cfg
.
Config
)
(
*
kubeconfig
.
Setup
,
error
)
{
addr
,
err
:=
host
.
Driver
.
GetURL
()
if
err
!=
nil
{
exit
.
WithError
(
"Failed to get host URL"
,
err
)
}
return
kubeconfig
.
Update
(
addr
,
config
)
return
kubeconfig
.
Setup
(
addr
,
config
)
}
func
handleDownloadOnly
(
cacheGroup
*
errgroup
.
Group
,
k8sVersion
string
)
{
...
...
pkg/minikube/kubeconfig/kubeconfig_test.go
浏览文件 @
a15201b1
...
...
@@ -97,7 +97,7 @@ users:
`
)
func
Test_update
(
t
*
testing
.
T
)
{
setupCfg
:=
&
Setup
{
setupCfg
:=
&
KCS
{
ClusterName
:
"test"
,
ClusterServerAddress
:
"192.168.1.1:8080"
,
ClientCertificate
:
"/home/apiserver.crt"
,
...
...
@@ -108,7 +108,7 @@ func Test_update(t *testing.T) {
var
tests
=
[]
struct
{
description
string
cfg
*
Setup
cfg
*
KCS
existingCfg
[]
byte
expected
api
.
Config
err
bool
...
...
@@ -128,7 +128,7 @@ func Test_update(t *testing.T) {
},
{
description
:
"keep context"
,
cfg
:
&
Setup
{
cfg
:
&
KCS
{
ClusterName
:
"test"
,
ClusterServerAddress
:
"192.168.1.1:8080"
,
ClientCertificate
:
"/home/apiserver.crt"
,
...
...
pkg/minikube/kubeconfig/setup.go
浏览文件 @
a15201b1
...
...
@@ -23,8 +23,8 @@ import (
"k8s.io/client-go/tools/clientcmd/api"
)
//
Setup
is the kubeconfig setup
type
Setup
struct
{
//
KCS
is the kubeconfig setup
type
KCS
struct
{
// The name of the cluster for this context
ClusterName
string
...
...
@@ -52,17 +52,17 @@ type Setup struct {
}
// SetKubeConfigFile sets the kubeconfig file
func
(
k
*
Setup
)
setPath
(
kubeConfigFile
string
)
{
func
(
k
*
KCS
)
setPath
(
kubeConfigFile
string
)
{
k
.
kubeConfigFile
.
Store
(
kubeConfigFile
)
}
// fileContent gets the kubeconfig file
func
(
k
*
Setup
)
fileContent
()
string
{
func
(
k
*
KCS
)
fileContent
()
string
{
return
k
.
kubeConfigFile
.
Load
()
.
(
string
)
}
// Populate populates an api.Config object with values from *Setup
func
Populate
(
cfg
*
Setup
,
apiCfg
*
api
.
Config
)
error
{
func
Populate
(
cfg
*
KCS
,
apiCfg
*
api
.
Config
)
error
{
var
err
error
clusterName
:=
cfg
.
ClusterName
cluster
:=
api
.
NewCluster
()
...
...
pkg/minikube/kubeconfig/update.go
浏览文件 @
a15201b1
...
...
@@ -34,19 +34,18 @@ import (
"k8s.io/client-go/tools/clientcmd/api/latest"
cfg
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/exit"
pkgutil
"k8s.io/minikube/pkg/util"
)
//
Update
sets up kubeconfig to be used by kubectl
func
Update
(
clusterURL
string
,
c
*
cfg
.
Config
)
*
Setup
{
//
Setup
sets up kubeconfig to be used by kubectl
func
Setup
(
clusterURL
string
,
c
*
cfg
.
Config
)
(
*
KCS
,
error
)
{
clusterURL
=
strings
.
Replace
(
clusterURL
,
"tcp://"
,
"https://"
,
-
1
)
clusterURL
=
strings
.
Replace
(
clusterURL
,
":2376"
,
":"
+
strconv
.
Itoa
(
c
.
KubernetesConfig
.
NodePort
),
-
1
)
if
c
.
KubernetesConfig
.
APIServerName
!=
constants
.
APIServerName
{
clusterURL
=
strings
.
Replace
(
clusterURL
,
c
.
KubernetesConfig
.
NodeIP
,
c
.
KubernetesConfig
.
APIServerName
,
-
1
)
}
kcs
:=
&
Setup
{
kcs
:=
&
KCS
{
ClusterName
:
cfg
.
GetMachineName
(),
ClusterServerAddress
:
clusterURL
,
ClientCertificate
:
constants
.
MakeMiniPath
(
"client.crt"
),
...
...
@@ -57,15 +56,16 @@ func Update(clusterURL string, c *cfg.Config) *Setup {
}
kcs
.
setPath
(
Path
())
if
err
:=
update
(
kcs
);
err
!=
nil
{
exit
.
WithError
(
"Failed to setup kubeconfig"
,
err
)
return
kcs
,
fmt
.
Errorf
(
"error update kubeconfig: %v"
,
err
)
}
return
kcs
return
kcs
,
nil
}
// update reads config from disk, adds the minikube settings, and writes it back.
// activeContext is true when minikube is the CurrentContext
// If no CurrentContext is set, the given name will be used.
func
update
(
cfg
*
Setup
)
error
{
func
update
(
cfg
*
KCS
)
error
{
glog
.
Infoln
(
"Using kubeconfig: "
,
cfg
.
fileContent
())
// read existing config or create new if does not exist
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录