Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
88370459
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,发现更多精彩内容 >>
提交
88370459
编写于
7月 07, 2017
作者:
D
dlorenc
提交者:
dlorenc
7月 26, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stop using insecure serving.
上级
e9795ca1
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
212 addition
and
79 deletion
+212
-79
deploy/addons/addon-manager.yaml
deploy/addons/addon-manager.yaml
+9
-0
hack/jenkins/common.sh
hack/jenkins/common.sh
+3
-0
hack/jenkins/linux_integration_tests_none.sh
hack/jenkins/linux_integration_tests_none.sh
+2
-1
hack/jenkins/print-debug-info.sh
hack/jenkins/print-debug-info.sh
+4
-1
pkg/localkube/apiserver.go
pkg/localkube/apiserver.go
+5
-5
pkg/localkube/controller-manager.go
pkg/localkube/controller-manager.go
+2
-1
pkg/localkube/kubelet.go
pkg/localkube/kubelet.go
+4
-1
pkg/localkube/proxy.go
pkg/localkube/proxy.go
+6
-4
pkg/localkube/ready.go
pkg/localkube/ready.go
+27
-2
pkg/localkube/ready_test.go
pkg/localkube/ready_test.go
+36
-4
pkg/localkube/scheduler.go
pkg/localkube/scheduler.go
+2
-1
pkg/localkube/storage_provisioner.go
pkg/localkube/storage_provisioner.go
+7
-8
pkg/minikube/assets/addons.go
pkg/minikube/assets/addons.go
+28
-28
pkg/minikube/assets/vm_assets.go
pkg/minikube/assets/vm_assets.go
+31
-4
pkg/minikube/cluster/cluster.go
pkg/minikube/cluster/cluster.go
+22
-1
pkg/minikube/machine/drivers/none/none.go
pkg/minikube/machine/drivers/none/none.go
+1
-1
pkg/util/constants.go
pkg/util/constants.go
+2
-1
pkg/util/kubeconfig/config.go
pkg/util/kubeconfig/config.go
+21
-16
未找到文件。
deploy/addons/addon-manager.yaml
浏览文件 @
88370459
...
...
@@ -26,6 +26,9 @@ spec:
containers
:
-
name
:
kube-addon-manager
image
:
gcr.io/google-containers/kube-addon-manager:v6.4-beta.2
env
:
-
name
:
KUBECONFIG
value
:
/var/lib/localkube/kubeconfig
imagePullPolicy
:
IfNotPresent
resources
:
requests
:
...
...
@@ -35,7 +38,13 @@ spec:
-
mountPath
:
/etc/kubernetes/
name
:
addons
readOnly
:
true
-
mountPath
:
/var/lib/localkube
name
:
kubeconfig
readOnly
:
true
volumes
:
-
hostPath
:
path
:
/etc/kubernetes/
name
:
addons
-
hostPath
:
path
:
/var/lib/localkube
name
:
kubeconfig
hack/jenkins/common.sh
浏览文件 @
88370459
...
...
@@ -75,6 +75,9 @@ ${SUDO_PREFIX}out/e2e-${OS_ARCH} -minikube-args="--vm-driver=${VM_DRIVER} --v=10
result
=
$?
set
-e
# See the KUBECONFIG file for debugging
sudo cat
$KUBECONFIG
MINIKUBE_WANTREPORTERRORPROMPT
=
False
sudo
./out/minikube-
${
OS_ARCH
}
delete
\
||
MINIKUBE_WANTREPORTERRORPROMPT
=
False ./out/minikube-
${
OS_ARCH
}
delete
\
||
true
...
...
hack/jenkins/linux_integration_tests_none.sh
浏览文件 @
88370459
...
...
@@ -30,7 +30,8 @@ OS_ARCH="linux-amd64"
VM_DRIVER
=
"none"
JOB_NAME
=
"Linux-None"
EXTRA_BUILD_ARGS
=
"
$EXTRA_BUILD_ARGS
--use-vendored-driver"
SUDO_PREFIX
=
"sudo "
SUDO_PREFIX
=
"sudo -E "
export
KUBECONFIG
=
"/root/.kube/config"
# Download files and set permissions
source
common.sh
hack/jenkins/print-debug-info.sh
浏览文件 @
88370459
...
...
@@ -20,11 +20,14 @@
# the cluster state.
set
+e
env
${
SUDO_PREFIX
}
cat
$KUBECONFIG
kubectl get pods
--all-namespaces
kubectl cluster-info dump
# For the none driver
journalctl
-u
localkube
journalctl
-u
localkube
-n
500
${
SUDO_PREFIX
}
cat
$KUBECONFIG
cat
$HOME
/.kube/config
...
...
pkg/localkube/apiserver.go
浏览文件 @
88370459
...
...
@@ -41,8 +41,8 @@ func StartAPIServer(lk LocalkubeServer) func() error {
config
.
SecureServing
.
BindAddress
=
lk
.
APIServerAddress
config
.
SecureServing
.
BindPort
=
lk
.
APIServerPort
config
.
InsecureServing
.
BindAddress
=
lk
.
APIServerInsecureAddress
config
.
InsecureServing
.
BindPort
=
lk
.
APIServerInsecurePort
// 0 turns off insecure serving.
config
.
InsecureServing
.
BindPort
=
0
config
.
Authentication
.
ClientCert
.
ClientCA
=
lk
.
GetCAPublicKeyCertPath
()
...
...
@@ -86,7 +86,7 @@ func StartAPIServer(lk LocalkubeServer) func() error {
}
func
readyFunc
(
lk
LocalkubeServer
)
HealthCheck
{
hostport
:=
net
.
JoinHostPort
(
lk
.
APIServerInsecureAddress
.
String
(),
strconv
.
Itoa
(
lk
.
APIServerInsecure
Port
))
addr
:=
"http://"
+
path
.
Join
(
hostport
,
"healthz"
)
return
healthCheck
(
addr
)
hostport
:=
net
.
JoinHostPort
(
"localhost"
,
strconv
.
Itoa
(
lk
.
APIServer
Port
))
addr
:=
"http
s
://"
+
path
.
Join
(
hostport
,
"healthz"
)
return
healthCheck
(
addr
,
lk
)
}
pkg/localkube/controller-manager.go
浏览文件 @
88370459
...
...
@@ -19,6 +19,7 @@ package localkube
import
(
controllerManager
"k8s.io/kubernetes/cmd/kube-controller-manager/app"
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
"k8s.io/minikube/pkg/util"
)
func
(
lk
LocalkubeServer
)
NewControllerManagerServer
()
Server
{
...
...
@@ -28,7 +29,7 @@ func (lk LocalkubeServer) NewControllerManagerServer() Server {
func
StartControllerManagerServer
(
lk
LocalkubeServer
)
func
()
error
{
config
:=
options
.
NewCMServer
()
config
.
Master
=
lk
.
GetAPIServerInsecureURL
()
config
.
Kubeconfig
=
util
.
DefaultKubeConfigPath
// defaults from command
config
.
DeletingPodsQps
=
0.1
...
...
pkg/localkube/kubelet.go
浏览文件 @
88370459
...
...
@@ -17,8 +17,10 @@ limitations under the License.
package
localkube
import
(
"k8s.io/apiserver/pkg/util/flag"
kubelet
"k8s.io/kubernetes/cmd/kubelet/app"
"k8s.io/kubernetes/cmd/kubelet/app/options"
"k8s.io/minikube/pkg/util"
)
func
(
lk
LocalkubeServer
)
NewKubeletServer
()
Server
{
...
...
@@ -29,7 +31,8 @@ func StartKubeletServer(lk LocalkubeServer) func() error {
config
:=
options
.
NewKubeletServer
()
// Master details
config
.
APIServerList
=
[]
string
{
lk
.
GetAPIServerInsecureURL
()}
config
.
KubeConfig
=
flag
.
NewStringFlag
(
util
.
DefaultKubeConfigPath
)
config
.
RequireKubeConfig
=
true
// Set containerized based on the flag
config
.
Containerized
=
lk
.
Containerized
...
...
pkg/localkube/proxy.go
浏览文件 @
88370459
...
...
@@ -18,6 +18,7 @@ package localkube
import
(
kubeproxy
"k8s.io/kubernetes/cmd/kube-proxy/app"
"k8s.io/minikube/pkg/util"
"time"
...
...
@@ -40,8 +41,9 @@ func StartProxyServer(lk LocalkubeServer) func() error {
config
:=
&
componentconfig
.
KubeProxyConfiguration
{
OOMScoreAdj
:
&
OOMScoreAdj
,
ClientConnection
:
componentconfig
.
ClientConnectionConfiguration
{
Burst
:
10
,
QPS
:
5
,
Burst
:
10
,
QPS
:
5
,
KubeConfigFile
:
util
.
DefaultKubeConfigPath
,
},
ConfigSyncPeriod
:
v1
.
Duration
{
Duration
:
15
*
time
.
Minute
},
IPTables
:
componentconfig
.
KubeProxyIPTablesConfiguration
{
...
...
@@ -49,7 +51,7 @@ func StartProxyServer(lk LocalkubeServer) func() error {
SyncPeriod
:
v1
.
Duration
{
Duration
:
30
*
time
.
Second
},
MinSyncPeriod
:
v1
.
Duration
{
Duration
:
5
*
time
.
Second
},
},
BindAddress
:
lk
.
APIServer
Insecure
Address
.
String
(),
BindAddress
:
lk
.
APIServerAddress
.
String
(),
Mode
:
componentconfig
.
ProxyModeIPTables
,
FeatureGates
:
lk
.
FeatureGates
,
// Disable the healthz check
...
...
@@ -60,7 +62,7 @@ func StartProxyServer(lk LocalkubeServer) func() error {
return
func
()
error
{
// Creating this config requires the API Server to be up, so do it in the start function itself.
server
,
err
:=
kubeproxy
.
NewProxyServer
(
config
,
false
,
runtime
.
NewScheme
(),
lk
.
GetAPIServerInsecureURL
()
)
server
,
err
:=
kubeproxy
.
NewProxyServer
(
config
,
false
,
runtime
.
NewScheme
(),
""
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
pkg/localkube/ready.go
浏览文件 @
88370459
...
...
@@ -17,6 +17,8 @@ limitations under the License.
package
localkube
import
(
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
...
...
@@ -25,10 +27,33 @@ import (
type
HealthCheck
func
()
bool
func
healthCheck
(
addr
string
)
HealthCheck
{
func
healthCheck
(
addr
string
,
lk
LocalkubeServer
)
HealthCheck
{
return
func
()
bool
{
glog
.
Infof
(
"Performing healthcheck on %s
\n
"
,
addr
)
resp
,
err
:=
http
.
Get
(
addr
)
cert
,
err
:=
tls
.
LoadX509KeyPair
(
lk
.
GetPublicKeyCertPath
(),
lk
.
GetPrivateKeyCertPath
())
if
err
!=
nil
{
glog
.
Error
(
err
)
return
false
}
// Load CA cert
caCert
,
err
:=
ioutil
.
ReadFile
(
lk
.
GetCAPublicKeyCertPath
())
if
err
!=
nil
{
glog
.
Warning
(
err
)
return
false
}
caCertPool
:=
x509
.
NewCertPool
()
caCertPool
.
AppendCertsFromPEM
(
caCert
)
tlsConfig
:=
&
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
cert
},
RootCAs
:
caCertPool
,
}
tlsConfig
.
BuildNameToCertificate
()
transport
:=
&
http
.
Transport
{
TLSClientConfig
:
tlsConfig
}
client
:=
&
http
.
Client
{
Transport
:
transport
}
resp
,
err
:=
client
.
Get
(
addr
)
if
err
!=
nil
{
glog
.
Errorf
(
"Error performing healthcheck: %s"
,
err
)
return
false
...
...
pkg/localkube/ready_test.go
浏览文件 @
88370459
...
...
@@ -17,15 +17,21 @@ limitations under the License.
package
localkube
import
(
"crypto/tls"
"crypto/x509"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
"k8s.io/minikube/pkg/minikube/tests"
)
func
TestBasicHealthCheck
(
t
*
testing
.
T
)
{
t
est
s
:=
[]
struct
{
t
c
s
:=
[]
struct
{
body
string
statusCode
int
shouldSucceed
bool
...
...
@@ -34,17 +40,43 @@ func TestBasicHealthCheck(t *testing.T) {
{
"notok"
,
200
,
false
},
}
for
_
,
tc
:=
range
tests
{
tempDir
:=
tests
.
MakeTempDir
()
defer
os
.
RemoveAll
(
tempDir
)
lk
:=
LocalkubeServer
{
LocalkubeDirectory
:
tempDir
}
lk
.
GenerateCerts
()
cert
,
err
:=
tls
.
LoadX509KeyPair
(
lk
.
GetPublicKeyCertPath
(),
lk
.
GetPrivateKeyCertPath
())
if
err
!=
nil
{
t
.
Fatalf
(
"Unable to load server certs."
)
}
caCert
,
err
:=
ioutil
.
ReadFile
(
lk
.
GetCAPublicKeyCertPath
())
if
err
!=
nil
{
t
.
Fatalf
(
"Unable to load CA certs."
)
}
caCertPool
:=
x509
.
NewCertPool
()
caCertPool
.
AppendCertsFromPEM
(
caCert
)
tls
:=
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
cert
},
ClientCAs
:
caCertPool
,
}
tls
.
BuildNameToCertificate
()
for
_
,
tc
:=
range
tcs
{
// Do this in a func so we can use defer.
doTest
:=
func
()
{
handler
:=
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
tc
.
statusCode
)
io
.
WriteString
(
w
,
tc
.
body
)
}
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
handler
))
server
:=
httptest
.
New
Unstarted
Server
(
http
.
HandlerFunc
(
handler
))
defer
server
.
Close
()
server
.
TLS
=
&
tls
server
.
StartTLS
()
hcFunc
:=
healthCheck
(
server
.
URL
)
hcFunc
:=
healthCheck
(
server
.
URL
,
lk
)
result
:=
hcFunc
()
if
result
!=
tc
.
shouldSucceed
{
t
.
Errorf
(
"Expected healthcheck to return %v. Got %v"
,
result
,
tc
.
shouldSucceed
)
...
...
pkg/localkube/scheduler.go
浏览文件 @
88370459
...
...
@@ -19,6 +19,7 @@ package localkube
import
(
scheduler
"k8s.io/kubernetes/plugin/cmd/kube-scheduler/app"
"k8s.io/kubernetes/plugin/cmd/kube-scheduler/app/options"
"k8s.io/minikube/pkg/util"
)
func
(
lk
LocalkubeServer
)
NewSchedulerServer
()
Server
{
...
...
@@ -29,7 +30,7 @@ func StartSchedulerServer(lk LocalkubeServer) func() error {
config
:=
options
.
NewSchedulerServer
()
// master details
config
.
Master
=
lk
.
GetAPIServerInsecureURL
()
config
.
Kubeconfig
=
util
.
DefaultKubeConfigPath
// defaults from command
config
.
EnableProfiling
=
true
...
...
pkg/localkube/storage_provisioner.go
浏览文件 @
88370459
...
...
@@ -19,10 +19,8 @@ package localkube
import
(
"errors"
"fmt"
"net"
"os"
"path"
"strconv"
"time"
"github.com/golang/glog"
...
...
@@ -34,7 +32,8 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/minikube/pkg/util"
)
const
(
...
...
@@ -123,12 +122,12 @@ func (lk LocalkubeServer) NewStorageProvisionerServer() Server {
func
StartStorageProvisioner
(
lk
LocalkubeServer
)
func
()
error
{
// Create an InClusterConfig and use it to create a client for the controller
// to use to communicate with Kubernetes
config
:=
rest
.
Config
{
Host
:
net
.
JoinHostPort
(
"localhost"
,
strconv
.
Itoa
(
lk
.
APIServerInsecurePort
))}
return
func
()
error
{
clientset
,
err
:=
kubernetes
.
NewForConfig
(
&
config
)
config
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
""
,
util
.
DefaultKubeConfigPath
)
if
err
!=
nil
{
return
err
}
clientset
,
err
:=
kubernetes
.
NewForConfig
(
config
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to create client: %v"
,
err
)
}
...
...
pkg/minikube/assets/addons.go
浏览文件 @
88370459
...
...
@@ -28,12 +28,12 @@ import (
)
type
Addon
struct
{
Assets
[]
*
Memory
Asset
Assets
[]
*
BinData
Asset
enabled
bool
addonName
string
}
func
NewAddon
(
assets
[]
*
Memory
Asset
,
enabled
bool
,
addonName
string
)
*
Addon
{
func
NewAddon
(
assets
[]
*
BinData
Asset
,
enabled
bool
,
addonName
string
)
*
Addon
{
a
:=
&
Addon
{
Assets
:
assets
,
enabled
:
enabled
,
...
...
@@ -55,107 +55,107 @@ func (a *Addon) IsEnabled() (bool, error) {
}
var
Addons
=
map
[
string
]
*
Addon
{
"addon-manager"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"addon-manager"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/addon-manager.yaml"
,
"/etc/kubernetes/manifests/"
,
"addon-manager.yaml"
,
"0640"
),
},
true
,
"addon-manager"
),
"dashboard"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"dashboard"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/dashboard/dashboard-rc.yaml"
,
constants
.
AddonsPath
,
"dashboard-rc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/dashboard/dashboard-svc.yaml"
,
constants
.
AddonsPath
,
"dashboard-svc.yaml"
,
"0640"
),
},
true
,
"dashboard"
),
"default-storageclass"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"default-storageclass"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/storageclass/storageclass.yaml"
,
constants
.
AddonsPath
,
"storageclass.yaml"
,
"0640"
),
},
true
,
"default-storageclass"
),
"kube-dns"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"kube-dns"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/kube-dns/kube-dns-controller.yaml"
,
constants
.
AddonsPath
,
"kube-dns-controller.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/kube-dns/kube-dns-cm.yaml"
,
constants
.
AddonsPath
,
"kube-dns-cm.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/kube-dns/kube-dns-svc.yaml"
,
constants
.
AddonsPath
,
"kube-dns-svc.yaml"
,
"0640"
),
},
true
,
"kube-dns"
),
"heapster"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"heapster"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/heapster/influxGrafana-rc.yaml"
,
constants
.
AddonsPath
,
"influxGrafana-rc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/heapster/grafana-svc.yaml"
,
constants
.
AddonsPath
,
"grafana-svc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/heapster/influxdb-svc.yaml"
,
constants
.
AddonsPath
,
"influxdb-svc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/heapster/heapster-rc.yaml"
,
constants
.
AddonsPath
,
"heapster-rc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/heapster/heapster-svc.yaml"
,
constants
.
AddonsPath
,
"heapster-svc.yaml"
,
"0640"
),
},
false
,
"heapster"
),
"ingress"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"ingress"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/ingress/ingress-configmap.yaml"
,
constants
.
AddonsPath
,
"ingress-configmap.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/ingress/ingress-rc.yaml"
,
constants
.
AddonsPath
,
"ingress-rc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/ingress/ingress-svc.yaml"
,
constants
.
AddonsPath
,
"ingress-svc.yaml"
,
"0640"
),
},
false
,
"ingress"
),
"registry"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"registry"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/registry/registry-rc.yaml"
,
constants
.
AddonsPath
,
"registry-rc.yaml"
,
"0640"
),
New
Memory
Asset
(
New
BinData
Asset
(
"deploy/addons/registry/registry-svc.yaml"
,
constants
.
AddonsPath
,
"registry-svc.yaml"
,
"0640"
),
},
false
,
"registry"
),
"registry-creds"
:
NewAddon
([]
*
Memory
Asset
{
New
Memory
Asset
(
"registry-creds"
:
NewAddon
([]
*
BinData
Asset
{
New
BinData
Asset
(
"deploy/addons/registry-creds/registry-creds-rc.yaml"
,
constants
.
AddonsPath
,
"registry-creds-rc.yaml"
,
...
...
pkg/minikube/assets/vm_assets.go
浏览文件 @
88370459
...
...
@@ -106,8 +106,35 @@ type MemoryAsset struct {
BaseAsset
}
func
NewMemoryAsset
(
assetName
,
targetDir
,
targetName
,
permissions
string
)
*
MemoryAsset
{
func
(
m
*
MemoryAsset
)
GetLength
()
int
{
return
m
.
Length
}
func
(
m
*
MemoryAsset
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
return
m
.
reader
.
Read
(
p
)
}
func
NewMemoryAsset
(
d
[]
byte
,
targetDir
,
targetName
,
permissions
string
)
*
MemoryAsset
{
m
:=
&
MemoryAsset
{
BaseAsset
{
TargetDir
:
targetDir
,
TargetName
:
targetName
,
Permissions
:
permissions
,
},
}
m
.
data
=
d
m
.
Length
=
len
(
m
.
data
)
m
.
reader
=
bytes
.
NewReader
(
m
.
data
)
return
m
}
type
BinDataAsset
struct
{
BaseAsset
}
func
NewBinDataAsset
(
assetName
,
targetDir
,
targetName
,
permissions
string
)
*
BinDataAsset
{
m
:=
&
BinDataAsset
{
BaseAsset
{
AssetName
:
assetName
,
TargetDir
:
targetDir
,
...
...
@@ -119,7 +146,7 @@ func NewMemoryAsset(assetName, targetDir, targetName, permissions string) *Memor
return
m
}
func
(
m
*
Memory
Asset
)
loadData
()
error
{
func
(
m
*
BinData
Asset
)
loadData
()
error
{
contents
,
err
:=
Asset
(
m
.
AssetName
)
if
err
!=
nil
{
return
err
...
...
@@ -130,11 +157,11 @@ func (m *MemoryAsset) loadData() error {
return
nil
}
func
(
m
*
Memory
Asset
)
GetLength
()
int
{
func
(
m
*
BinData
Asset
)
GetLength
()
int
{
return
m
.
Length
}
func
(
m
*
Memory
Asset
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
func
(
m
*
BinData
Asset
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
return
m
.
reader
.
Read
(
p
)
}
...
...
pkg/minikube/cluster/cluster.go
浏览文件 @
88370459
...
...
@@ -38,12 +38,16 @@ import (
"github.com/docker/machine/libmachine/state"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/tools/clientcmd/api/latest"
"k8s.io/minikube/pkg/minikube/assets"
cfg
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/sshutil"
"k8s.io/minikube/pkg/util"
"k8s.io/minikube/pkg/util/kubeconfig"
)
var
(
...
...
@@ -221,7 +225,7 @@ func UpdateCluster(d drivers.Driver, config KubernetesConfig) error {
return
errors
.
Wrap
(
err
,
"Error updating localkube from uri"
)
}
}
else
{
localkubeFile
=
assets
.
New
Memory
Asset
(
"out/localkube"
,
"/usr/local/bin"
,
"localkube"
,
"0777"
)
localkubeFile
=
assets
.
New
BinData
Asset
(
"out/localkube"
,
"/usr/local/bin"
,
"localkube"
,
"0777"
)
}
copyableFiles
=
append
(
copyableFiles
,
localkubeFile
)
...
...
@@ -301,6 +305,23 @@ func SetupCerts(d drivers.Driver, apiServerName string, clusterDnsDomain string)
copyableFiles
=
append
(
copyableFiles
,
certFile
)
}
kubeCfgSetup
:=
&
kubeconfig
.
KubeConfigSetup
{
ClusterName
:
cfg
.
GetMachineName
(),
ClusterServerAddress
:
"https://localhost:8443"
,
ClientCertificate
:
filepath
.
Join
(
util
.
DefaultCertPath
,
"apiserver.crt"
),
ClientKey
:
filepath
.
Join
(
util
.
DefaultCertPath
,
"apiserver.key"
),
CertificateAuthority
:
filepath
.
Join
(
util
.
DefaultCertPath
,
"ca.crt"
),
KeepContext
:
false
,
}
kubeCfg
:=
api
.
NewConfig
()
kubeconfig
.
PopulateKubeConfig
(
kubeCfgSetup
,
kubeCfg
)
data
,
err
:=
runtime
.
Encode
(
latest
.
Codec
,
kubeCfg
)
kubeCfgFile
:=
assets
.
NewMemoryAsset
(
data
,
util
.
DefaultLocalkubeDirectory
,
"kubeconfig"
,
"0644"
)
copyableFiles
=
append
(
copyableFiles
,
kubeCfgFile
)
if
d
.
DriverName
()
==
"none"
{
// transfer files to correct place on filesystem
for
_
,
f
:=
range
copyableFiles
{
...
...
pkg/minikube/machine/drivers/none/none.go
浏览文件 @
88370459
...
...
@@ -93,7 +93,7 @@ func (d *Driver) GetSSHUsername() string {
}
func
(
d
*
Driver
)
GetURL
()
(
string
,
error
)
{
return
"
127.0.0.1:8080
"
,
nil
return
"
tcp://127.0.0.1:2376
"
,
nil
}
func
(
d
*
Driver
)
GetState
()
(
state
.
State
,
error
)
{
...
...
pkg/util/constants.go
浏览文件 @
88370459
...
...
@@ -21,6 +21,7 @@ const (
APIServerPort
=
8443
DefaultLocalkubeDirectory
=
"/var/lib/localkube"
DefaultCertPath
=
DefaultLocalkubeDirectory
+
"/certs/"
DefaultKubeConfigPath
=
DefaultLocalkubeDirectory
+
"/kubeconfig"
DefaultServiceClusterIP
=
"10.0.0.1"
DefaultDNSDomain
=
"cluster.local"
DefaultDNSIP
=
"10.0.0.10"
...
...
@@ -28,5 +29,5 @@ const (
)
func
GetAlternateDNS
(
domain
string
)
[]
string
{
return
[]
string
{
"kubernetes.default.svc."
+
domain
,
"kubernetes.default.svc"
,
"kubernetes.default"
,
"kubernetes"
}
return
[]
string
{
"kubernetes.default.svc."
+
domain
,
"kubernetes.default.svc"
,
"kubernetes.default"
,
"kubernetes"
,
"localhost"
}
}
pkg/util/kubeconfig/config.go
浏览文件 @
88370459
...
...
@@ -66,43 +66,48 @@ func (k *KubeConfigSetup) GetKubeConfigFile() string {
return
k
.
kubeConfigFile
.
Load
()
.
(
string
)
}
// SetupKubeconfig 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
SetupKubeConfig
(
cfg
*
KubeConfigSetup
)
error
{
glog
.
Infoln
(
"Using kubeconfig: "
,
cfg
.
GetKubeConfigFile
())
// read existing config or create new if does not exist
config
,
err
:=
ReadConfigOrNew
(
cfg
.
GetKubeConfigFile
())
if
err
!=
nil
{
return
err
}
// PopulateKubeConfig populates an api.Config object.
func
PopulateKubeConfig
(
cfg
*
KubeConfigSetup
,
kubecfg
*
api
.
Config
)
{
clusterName
:=
cfg
.
ClusterName
cluster
:=
api
.
NewCluster
()
cluster
.
Server
=
cfg
.
ClusterServerAddress
cluster
.
CertificateAuthority
=
cfg
.
CertificateAuthority
confi
g
.
Clusters
[
clusterName
]
=
cluster
kubecf
g
.
Clusters
[
clusterName
]
=
cluster
// user
userName
:=
cfg
.
ClusterName
user
:=
api
.
NewAuthInfo
()
user
.
ClientCertificate
=
cfg
.
ClientCertificate
user
.
ClientKey
=
cfg
.
ClientKey
confi
g
.
AuthInfos
[
userName
]
=
user
kubecf
g
.
AuthInfos
[
userName
]
=
user
// context
contextName
:=
cfg
.
ClusterName
context
:=
api
.
NewContext
()
context
.
Cluster
=
cfg
.
ClusterName
context
.
AuthInfo
=
userName
confi
g
.
Contexts
[
contextName
]
=
context
kubecf
g
.
Contexts
[
contextName
]
=
context
// Only set current context to minikube if the user has not used the keepContext flag
if
!
cfg
.
KeepContext
{
config
.
CurrentContext
=
contextName
kubecfg
.
CurrentContext
=
cfg
.
ClusterName
}
}
// SetupKubeConfig 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
SetupKubeConfig
(
cfg
*
KubeConfigSetup
)
error
{
glog
.
Infoln
(
"Using kubeconfig: "
,
cfg
.
GetKubeConfigFile
())
// read existing config or create new if does not exist
config
,
err
:=
ReadConfigOrNew
(
cfg
.
GetKubeConfigFile
())
if
err
!=
nil
{
return
err
}
PopulateKubeConfig
(
cfg
,
config
)
// write back to disk
if
err
:=
WriteConfig
(
config
,
cfg
.
GetKubeConfigFile
());
err
!=
nil
{
return
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录