Merge branch 'master' of https://github.com/kubernetes/minikube into var-warning
commit
704a2a7a83
|
@ -349,6 +349,7 @@ jobs:
|
||||||
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
||||||
choco install -y kubernetes-cli
|
choco install -y kubernetes-cli
|
||||||
choco install -y jq
|
choco install -y jq
|
||||||
|
choco install -y caffeine
|
||||||
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
||||||
- name: Run Integration Test in powershell
|
- name: Run Integration Test in powershell
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
@ -485,6 +486,7 @@ jobs:
|
||||||
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
||||||
choco install -y kubernetes-cli
|
choco install -y kubernetes-cli
|
||||||
choco install -y jq
|
choco install -y jq
|
||||||
|
choco install -y caffeine
|
||||||
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
||||||
- name: Run Integration Test in powershell
|
- name: Run Integration Test in powershell
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
|
@ -347,6 +347,7 @@ jobs:
|
||||||
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
||||||
choco install -y kubernetes-cli
|
choco install -y kubernetes-cli
|
||||||
choco install -y jq
|
choco install -y jq
|
||||||
|
choco install -y caffeine
|
||||||
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
||||||
- name: Run Integration Test in powershell
|
- name: Run Integration Test in powershell
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
@ -483,6 +484,7 @@ jobs:
|
||||||
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
(New-Object Net.WebClient).DownloadFile("https://github.com/medyagh/gopogh/releases/download/v0.2.4/gopogh.exe", "C:\ProgramData\chocolatey\bin\gopogh.exe")
|
||||||
choco install -y kubernetes-cli
|
choco install -y kubernetes-cli
|
||||||
choco install -y jq
|
choco install -y jq
|
||||||
|
choco install -y caffeine
|
||||||
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
if (Test-Path 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe') { Remove-Item 'C:\Program Files\Docker\Docker\resources\bin\kubectl.exe' };
|
||||||
- name: Run Integration Test in powershell
|
- name: Run Integration Test in powershell
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -72,7 +72,6 @@ require (
|
||||||
github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097
|
github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097
|
||||||
golang.org/x/build v0.0.0-20190927031335-2835ba2e683f
|
golang.org/x/build v0.0.0-20190927031335-2835ba2e683f
|
||||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
|
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
|
||||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect
|
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
||||||
golang.org/x/sys v0.0.0-20200523222454-059865788121
|
golang.org/x/sys v0.0.0-20200523222454-059865788121
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version is the current version of kic
|
// Version is the current version of kic
|
||||||
Version = "v0.0.11"
|
Version = "v0.0.12-snapshot"
|
||||||
// SHA of the kic base image
|
// SHA of the kic base image
|
||||||
baseImageSHA = "6fee59db7d67ed8ae6835e4bcb02f32056dc95f11cb369c51e352b62dd198aa0"
|
baseImageSHA = "7be40a42fdfec56fbf7bc9de07ea2ed4a931cbb70dccb8612b2ba13763bf4568"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -123,8 +123,8 @@ func UpdateEndpoint(contextName string, hostname string, port int, confpath stri
|
||||||
|
|
||||||
address := "https://" + hostname + ":" + strconv.Itoa(port)
|
address := "https://" + hostname + ":" + strconv.Itoa(port)
|
||||||
|
|
||||||
// if the kubeconfig is missed, create new one
|
// if the cluster setting is missed in the kubeconfig, create new one
|
||||||
if len(cfg.Clusters) == 0 {
|
if _, ok := cfg.Clusters[contextName]; !ok {
|
||||||
lp := localpath.Profile(contextName)
|
lp := localpath.Profile(contextName)
|
||||||
gp := localpath.MiniPath()
|
gp := localpath.MiniPath()
|
||||||
kcs := &Settings{
|
kcs := &Settings{
|
||||||
|
@ -139,8 +139,10 @@ func UpdateEndpoint(contextName string, hostname string, port int, confpath stri
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "populating kubeconfig")
|
return false, errors.Wrap(err, "populating kubeconfig")
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
cfg.Clusters[contextName].Server = address
|
cfg.Clusters[contextName].Server = address
|
||||||
|
}
|
||||||
|
|
||||||
err = writeToFile(cfg, confpath)
|
err = writeToFile(cfg, confpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "write")
|
return false, errors.Wrap(err, "write")
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
|
|
||||||
"k8s.io/client-go/tools/clientcmd/api"
|
"k8s.io/client-go/tools/clientcmd/api"
|
||||||
"k8s.io/minikube/pkg/minikube/constants"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
|
"k8s.io/minikube/pkg/minikube/localpath"
|
||||||
|
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
)
|
)
|
||||||
|
@ -51,6 +52,40 @@ users:
|
||||||
client-key: /home/la-croix/apiserver.key
|
client-key: /home/la-croix/apiserver.key
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
var kubeConfigWithoutHTTPSUpdated = []byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
certificate-authority: /home/la-croix/apiserver.crt
|
||||||
|
server: 192.168.1.1:8080
|
||||||
|
name: la-croix
|
||||||
|
- cluster:
|
||||||
|
certificate-authority: /home/la-croix/.minikube/ca.crt
|
||||||
|
server: https://192.168.10.100:8080
|
||||||
|
name: minikube
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: la-croix
|
||||||
|
user: la-croix
|
||||||
|
name: la-croix
|
||||||
|
- context:
|
||||||
|
cluster: minikube
|
||||||
|
user: minikube
|
||||||
|
name: minikube
|
||||||
|
current-context: minikube
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: la-croix
|
||||||
|
user:
|
||||||
|
client-certificate: /home/la-croix/apiserver.crt
|
||||||
|
client-key: /home/la-croix/apiserver.key
|
||||||
|
- name: minikube
|
||||||
|
user:
|
||||||
|
client-certificate: /home/la-croix/.minikube/profiles/minikube/client.crt
|
||||||
|
client-key: /home/la-croix/.minikube/profiles/minikube/client.key
|
||||||
|
`)
|
||||||
|
|
||||||
var kubeConfig192 = []byte(`
|
var kubeConfig192 = []byte(`
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
clusters:
|
clusters:
|
||||||
|
@ -117,6 +152,37 @@ users:
|
||||||
client-key: /home/la-croix/apiserver.key
|
client-key: /home/la-croix/apiserver.key
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
var kubeConfigNoClusters = []byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
contexts:
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
`)
|
||||||
|
|
||||||
|
var kubeConfigNoClustersUpdated = []byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
certificate-authority: /home/la-croix/.minikube/ca.crt
|
||||||
|
server: https://192.168.10.100:8080
|
||||||
|
name: minikube
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: minikube
|
||||||
|
user: minikube
|
||||||
|
name: minikube
|
||||||
|
current-context: minikube
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: minikube
|
||||||
|
user:
|
||||||
|
client-certificate: /home/la-croix/.minikube/profiles/minikube/client.crt
|
||||||
|
client-key: /home/la-croix/.minikube/profiles/minikube/client.key
|
||||||
|
`)
|
||||||
|
|
||||||
func TestUpdate(t *testing.T) {
|
func TestUpdate(t *testing.T) {
|
||||||
setupCfg := &Settings{
|
setupCfg := &Settings{
|
||||||
ClusterName: "test",
|
ClusterName: "test",
|
||||||
|
@ -300,8 +366,8 @@ func TestUpdateIP(t *testing.T) {
|
||||||
hostname: "192.168.10.100",
|
hostname: "192.168.10.100",
|
||||||
port: 8080,
|
port: 8080,
|
||||||
existing: kubeConfigWithoutHTTPS,
|
existing: kubeConfigWithoutHTTPS,
|
||||||
err: true,
|
status: true,
|
||||||
expCfg: kubeConfigWithoutHTTPS,
|
expCfg: kubeConfigWithoutHTTPSUpdated,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "same IP",
|
description: "same IP",
|
||||||
|
@ -326,8 +392,20 @@ func TestUpdateIP(t *testing.T) {
|
||||||
status: true,
|
status: true,
|
||||||
expCfg: kubeConfigLocalhost12345,
|
expCfg: kubeConfigLocalhost12345,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "no clusters",
|
||||||
|
hostname: "192.168.10.100",
|
||||||
|
port: 8080,
|
||||||
|
existing: kubeConfigNoClusters,
|
||||||
|
status: true,
|
||||||
|
expCfg: kubeConfigNoClustersUpdated,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.Setenv(localpath.MinikubeHome, "/home/la-croix")
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
test := test
|
||||||
t.Run(test.description, func(t *testing.T) {
|
t.Run(test.description, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
configFilename := tempFile(t, test.existing)
|
configFilename := tempFile(t, test.existing)
|
||||||
|
@ -342,6 +420,18 @@ func TestUpdateIP(t *testing.T) {
|
||||||
if test.status != statusActual {
|
if test.status != statusActual {
|
||||||
t.Errorf("Expected status %t, but got %t", test.status, statusActual)
|
t.Errorf("Expected status %t, but got %t", test.status, statusActual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actual, err := readOrNew(configFilename)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
expected, err := decode(test.expCfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !configEquals(actual, expected) {
|
||||||
|
t.Fatal("configs did not match")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ minikube start [flags]
|
||||||
--apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine
|
--apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine
|
||||||
--apiserver-port int The apiserver listening port (default 8443)
|
--apiserver-port int The apiserver listening port (default 8443)
|
||||||
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
|
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
|
||||||
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase:v0.0.11@sha256:6fee59db7d67ed8ae6835e4bcb02f32056dc95f11cb369c51e352b62dd198aa0")
|
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase:v0.0.12-snapshot@sha256:7be40a42fdfec56fbf7bc9de07ea2ed4a931cbb70dccb8612b2ba13763bf4568")
|
||||||
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
|
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
|
||||||
--cni string CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)
|
--cni string CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)
|
||||||
--container-runtime string The container runtime to be used (docker, cri-o, containerd). (default "docker")
|
--container-runtime string The container runtime to be used (docker, cri-o, containerd). (default "docker")
|
||||||
|
|
|
@ -1007,14 +1007,86 @@ func validateCertSync(ctx context.Context, t *testing.T, profile string) {
|
||||||
func validateUpdateContextCmd(ctx context.Context, t *testing.T, profile string) {
|
func validateUpdateContextCmd(ctx context.Context, t *testing.T, profile string) {
|
||||||
defer PostMortemLogs(t, profile)
|
defer PostMortemLogs(t, profile)
|
||||||
|
|
||||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "update-context", "--alsologtostderr", "-v=2"))
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
kubeconfig []byte
|
||||||
|
want []byte
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "no changes",
|
||||||
|
kubeconfig: nil,
|
||||||
|
want: []byte("No changes"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no minikube cluster",
|
||||||
|
kubeconfig: []byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
certificate-authority: /home/la-croix/apiserver.crt
|
||||||
|
server: 192.168.1.1:8080
|
||||||
|
name: la-croix
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: la-croix
|
||||||
|
user: la-croix
|
||||||
|
name: la-croix
|
||||||
|
current-context: la-croix
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: la-croix
|
||||||
|
user:
|
||||||
|
client-certificate: /home/la-croix/apiserver.crt
|
||||||
|
client-key: /home/la-croix/apiserver.key
|
||||||
|
`),
|
||||||
|
want: []byte("context has been updated"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no clusters",
|
||||||
|
kubeconfig: []byte(`
|
||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
contexts:
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
`),
|
||||||
|
want: []byte("context has been updated"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
tc := tc
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
c := exec.CommandContext(ctx, Target(), "-p", profile, "update-context", "--alsologtostderr", "-v=2")
|
||||||
|
if tc.kubeconfig != nil {
|
||||||
|
tf, err := ioutil.TempFile("", "kubeconfig")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile(tf.Name(), tc.kubeconfig, 0644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
os.Remove(tf.Name())
|
||||||
|
})
|
||||||
|
|
||||||
|
c.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", tf.Name()))
|
||||||
|
}
|
||||||
|
|
||||||
|
rr, err := Run(t, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to run minikube update-context: args %q: %v", rr.Command(), err)
|
t.Errorf("failed to run minikube update-context: args %q: %v", rr.Command(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := []byte("No changes")
|
if !bytes.Contains(rr.Stdout.Bytes(), tc.want) {
|
||||||
if !bytes.Contains(rr.Stdout.Bytes(), want) {
|
t.Errorf("update-context: got=%q, want=*%q*", rr.Stdout.Bytes(), tc.want)
|
||||||
t.Errorf("update-context: got=%q, want=*%q*", rr.Stdout.Bytes(), want)
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue