Merge branch 'master' into ilyaz/arm64-fixes

pull/9985/head
Ilya Zuyev 2021-01-14 22:06:10 -08:00
commit 227a6af18e
21 changed files with 155 additions and 283 deletions

View File

@ -35,8 +35,8 @@ import (
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/pkg/errors"
"github.com/shirou/gopsutil/cpu"
gopshost "github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/v3/cpu"
gopshost "github.com/shirou/gopsutil/v3/host"
"github.com/spf13/cobra"
"github.com/spf13/viper"

View File

@ -35,8 +35,9 @@ var updateContextCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cname := ClusterFlagValue()
co := mustload.Running(cname)
// cluster extension metada for kubeconfig
updated, err := kubeconfig.UpdateEndpoint(cname, co.CP.Hostname, co.CP.Port, kubeconfig.PathFromEnv())
updated, err := kubeconfig.UpdateEndpoint(cname, co.CP.Hostname, co.CP.Port, kubeconfig.PathFromEnv(), kubeconfig.NewExtension())
if err != nil {
exit.Error(reason.HostKubeconfigUpdate, "update config", err)
}

View File

@ -283,5 +283,7 @@ fix_product_uuid
select_iptables
enable_network_magic
echo "entrypoint completed: $(uname -a)"
# we want the command (expected to be systemd) to be PID1, so exec to it
exec "$@"

11
go.mod
View File

@ -8,8 +8,8 @@ require (
github.com/Azure/azure-sdk-for-go v42.3.0+incompatible
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v0.13.0
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/Parallels/docker-machine-parallels/v2 v2.0.1
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VividCortex/godaemon v0.0.0-20201030160542-15e3f4925a21
github.com/blang/semver v3.5.0+incompatible
github.com/briandowns/spinner v1.11.1
@ -20,7 +20,7 @@ require (
github.com/cloudevents/sdk-go/v2 v2.1.0
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 // indirect
github.com/containerd/containerd v1.3.1-0.20191213020239-082f7e3aed57 // indirect
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7 // indirect
github.com/docker/cli v0.0.0-20200303162255-7d407207c304 // indirect
github.com/docker/docker v17.12.0-ce-rc1.0.20181225093023-5ddb1d410a8b+incompatible
github.com/docker/go-units v0.4.0
@ -29,7 +29,6 @@ require (
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/go-logr/logr v0.3.0 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/google/go-cmp v0.5.2
github.com/google/go-containerregistry v0.3.0
@ -46,6 +45,7 @@ require (
github.com/johanneswuerbach/nfsexports v0.0.0-20200318065542-c48c3734757f
github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c
github.com/juju/errors v0.0.0-20190806202954-0232dcc7464d // indirect
github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
github.com/juju/mutex v0.0.0-20180619145857-d21b13acf4bf
github.com/juju/retry v0.0.0-20180821225755-9058e192b216 // indirect
@ -69,7 +69,7 @@ require (
github.com/pmezard/go-difflib v1.0.0
github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 // indirect
github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859 // indirect
github.com/shirou/gopsutil v2.18.12+incompatible
github.com/shirou/gopsutil/v3 v3.20.12
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0
@ -86,7 +86,7 @@ require (
golang.org/x/mod v0.3.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
golang.org/x/sys v0.0.0-20200523222454-059865788121
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3
golang.org/x/text v0.3.3
google.golang.org/api v0.29.0
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
@ -106,7 +106,6 @@ require (
replace (
git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
github.com/briandowns/spinner => github.com/alonyb/spinner v1.12.1
github.com/docker/docker => github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7
github.com/docker/machine => github.com/machine-drivers/machine v0.7.1-0.20200810185219-7d42fed1b770
github.com/google/go-containerregistry => github.com/afbjorklund/go-containerregistry v0.1.2-0.20210101161202-de47504a564f
github.com/hashicorp/go-getter => github.com/afbjorklund/go-getter v1.4.3-0.20201119203610-3f740b1eaf7d

218
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -99,6 +99,8 @@ func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig, n config.Node)
ClientCertificate: path.Join(vmpath.GuestKubernetesCertsDir, "apiserver.crt"),
ClientKey: path.Join(vmpath.GuestKubernetesCertsDir, "apiserver.key"),
CertificateAuthority: path.Join(vmpath.GuestKubernetesCertsDir, "ca.crt"),
ExtensionContext: kubeconfig.NewExtension(),
ExtensionCluster: kubeconfig.NewExtension(),
KeepContext: false,
}

View File

@ -20,7 +20,6 @@ package images
import (
"fmt"
"path"
"runtime"
"github.com/blang/semver"
@ -35,7 +34,7 @@ func Pause(v semver.Version, mirror string) string {
if semver.MustParseRange("<1.18.0-alpha.0")(v) {
pv = "3.1"
}
return path.Join(kubernetesRepo(mirror), "pause"+archTag(false)+pv)
return path.Join(kubernetesRepo(mirror), "pause:"+pv)
}
// essentials returns images needed too bootstrap a Kubernetes
@ -54,13 +53,7 @@ func essentials(mirror string, v semver.Version) []string {
// componentImage returns a Kubernetes component image to pull
func componentImage(name string, v semver.Version, mirror string) string {
needsArchSuffix := false
ancient := semver.MustParseRange("<1.12.0")
if ancient(v) {
needsArchSuffix = true
}
return fmt.Sprintf("%sv%s", path.Join(kubernetesRepo(mirror), name+archTag(needsArchSuffix)), v)
return fmt.Sprintf("%s:v%s", path.Join(kubernetesRepo(mirror), name), v)
}
// coreDNS returns the images used for CoreDNS
@ -84,17 +77,11 @@ func coreDNS(v semver.Version, mirror string) string {
case 11:
cv = "1.1.3"
}
return path.Join(kubernetesRepo(mirror), "coredns"+":"+cv)
return path.Join(kubernetesRepo(mirror), "coredns:"+cv)
}
// etcd returns the image used for etcd
func etcd(v semver.Version, mirror string) string {
needsArchSuffix := false
ancient := semver.MustParseRange("<1.12.0")
if ancient(v) {
needsArchSuffix = true
}
// Should match `DefaultEtcdVersion` in:
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go
ev := "3.4.13-0"
@ -117,18 +104,7 @@ func etcd(v semver.Version, mirror string) string {
ev = "3.4.9-1"
}
return path.Join(kubernetesRepo(mirror), "etcd"+archTag(needsArchSuffix)+ev)
}
// archTag returns a CPU architecture suffix for images
func archTag(needsArchSuffix bool) string {
return archTagInt(runtime.GOARCH, needsArchSuffix)
}
func archTagInt(arch string, needsArchSuffix bool) string {
if arch == "amd64" || !needsArchSuffix {
return ":"
}
return "-" + runtime.GOARCH + ":"
return path.Join(kubernetesRepo(mirror), "etcd:"+ev)
}
// auxiliary returns images that are helpful for running minikube
@ -143,7 +119,7 @@ func auxiliary(mirror string) []string {
// storageProvisioner returns the minikube storage provisioner image
func storageProvisioner(mirror string) string {
return path.Join(minikubeRepo(mirror), "storage-provisioner"+archTag(false)+version.GetStorageProvisionerVersion())
return path.Join(minikubeRepo(mirror), "storage-provisioner:"+version.GetStorageProvisionerVersion())
}
// dashboardFrontend returns the image used for the dashboard frontend

View File

@ -17,8 +17,6 @@ limitations under the License.
package images
import (
"fmt"
"runtime"
"testing"
"github.com/google/go-cmp/cmp"
@ -47,30 +45,3 @@ func TestAuxiliaryMirror(t *testing.T) {
t.Errorf("images mismatch (-want +got):\n%s", diff)
}
}
func TestArchTag(t *testing.T) {
tests := []struct {
arch string
suffix bool
expected string
}{
{
"amd64", true, ":",
},
{
"amd64", false, ":",
},
{
"arm64", false, ":",
},
{
"arm64", true, fmt.Sprintf("-%s:", runtime.GOARCH),
},
}
for _, test := range tests {
if tag := archTagInt(test.arch, test.suffix); tag != test.expected {
t.Errorf("For arch: %v and suffix flag: '%v' expected %v got %v",
test.arch, test.suffix, test.expected, tag)
}
}
}

View File

@ -576,14 +576,14 @@ func (k *Bootstrapper) restartControlPlane(cfg config.ClusterConfig) error {
klog.Infof("restartCluster took %s", time.Since(start))
}()
version, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
k8sVersion, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
if err != nil {
return errors.Wrap(err, "parsing Kubernetes version")
}
phase := "alpha"
controlPlane := "controlplane"
if version.GTE(semver.MustParse("1.13.0")) {
if k8sVersion.GTE(semver.MustParse("1.13.0")) {
phase = "init"
controlPlane = "control-plane"
}
@ -603,7 +603,7 @@ func (k *Bootstrapper) restartControlPlane(cfg config.ClusterConfig) error {
}
// Save the costly tax of reinstalling Kubernetes if the only issue is a missing kube context
_, err = kubeconfig.UpdateEndpoint(cfg.Name, hostname, port, kubeconfig.PathFromEnv())
_, err = kubeconfig.UpdateEndpoint(cfg.Name, hostname, port, kubeconfig.PathFromEnv(), kubeconfig.NewExtension())
if err != nil {
klog.Warningf("unable to update kubeconfig (cluster will likely require a reset): %v", err)
}

View File

@ -0,0 +1,66 @@
/*
Copyright 2021 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kubeconfig
import (
"time"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/minikube/pkg/version"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// implementing the runtime.Object internally so we can write extensions to kubeconfig
type Extension struct {
runtime.TypeMeta `json:",inline"`
Version string `json:"version"`
Provider string `json:"provider"`
LastUpdate string `json:"last-update"`
}
// NewExtension returns a minikube formated kubeconfig's extension block to idenity clusters and contexts
func NewExtension() *Extension {
return &Extension{
Provider: "minikube.sigs.k8s.io",
Version: version.GetVersion(),
// time format matching other RFC in notify.go
LastUpdate: time.Now().Format(time.RFC1123)}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension.
func (in *Extension) DeepCopy() *Extension {
if in == nil {
return nil
}
out := new(Extension)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Extension) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Extension) DeepCopyInto(out *Extension) {
*out = *in
out.TypeMeta = in.TypeMeta
}

View File

@ -105,7 +105,7 @@ func Endpoint(contextName string, configPath ...string) (string, int, error) {
}
// UpdateEndpoint overwrites the IP stored in kubeconfig with the provided IP.
func UpdateEndpoint(contextName string, hostname string, port int, confpath string) (bool, error) {
func UpdateEndpoint(contextName string, hostname string, port int, confpath string, ext *Extension) (bool, error) {
if hostname == "" {
return false, fmt.Errorf("empty ip")
}
@ -136,6 +136,9 @@ func UpdateEndpoint(contextName string, hostname string, port int, confpath stri
CertificateAuthority: path.Join(gp, "ca.crt"),
KeepContext: false,
}
if ext != nil {
kcs.ExtensionCluster = ext
}
err = PopulateFromSettings(kcs, cfg)
if err != nil {
return false, errors.Wrap(err, "populating kubeconfig")

View File

@ -410,7 +410,7 @@ func TestUpdateIP(t *testing.T) {
t.Parallel()
configFilename := tempFile(t, test.existing)
defer os.Remove(configFilename)
statusActual, err := UpdateEndpoint("minikube", test.hostname, test.port, configFilename)
statusActual, err := UpdateEndpoint("minikube", test.hostname, test.port, configFilename, nil)
if err != nil && !test.err {
t.Errorf("Got unexpected error: %v", err)
}
@ -430,7 +430,7 @@ func TestUpdateIP(t *testing.T) {
t.Fatal(err)
}
if !configEquals(actual, expected) {
t.Fatal("configs did not match")
t.Fatalf("configs did not match: Actual:\n%+v\n Expected:\n%+v", actual, expected)
}
})

View File

@ -23,6 +23,7 @@ import (
"github.com/juju/mutex"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/util/lock"
@ -54,6 +55,12 @@ type Settings struct {
// Should the certificate files be embedded instead of referenced by path
EmbedCerts bool
// Extension meta data for the cluster
ExtensionCluster *Extension
// Extension meta data for the cluster
ExtensionContext *Extension
// kubeConfigFile is the path where the kube config is stored
// Only access this with atomic ops
kubeConfigFile atomic.Value
@ -83,6 +90,10 @@ func PopulateFromSettings(cfg *Settings, apiCfg *api.Config) error {
} else {
cluster.CertificateAuthority = cfg.CertificateAuthority
}
if cfg.ExtensionCluster != nil {
cluster.Extensions = map[string]runtime.Object{"cluster_info": cfg.ExtensionCluster.DeepCopy()}
}
apiCfg.Clusters[clusterName] = cluster
// user
@ -109,6 +120,10 @@ func PopulateFromSettings(cfg *Settings, apiCfg *api.Config) error {
context.Cluster = cfg.ClusterName
context.Namespace = cfg.Namespace
context.AuthInfo = userName
if cfg.ExtensionContext != nil {
context.Extensions = map[string]runtime.Object{"context_info": cfg.ExtensionContext.DeepCopy()}
}
apiCfg.Contexts[contextName] = context
// Only set current context to minikube if the user has not used the keepContext flag
@ -138,6 +153,9 @@ func Update(kcs *Settings) error {
return err
}
ext := NewExtension()
kcs.ExtensionCluster = ext
kcs.ExtensionContext = ext
err = PopulateFromSettings(kcs, kcfg)
if err != nil {
return err

View File

@ -40,6 +40,7 @@ import (
"github.com/docker/machine/libmachine/state"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/libmachine/version"
"github.com/juju/fslock"
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/command"
@ -71,6 +72,7 @@ func NewAPIClient(miniHome ...string) (libmachine.API, error) {
storePath: storePath,
Filestore: persist.NewFilestore(storePath, certsDir, certsDir),
legacyClient: NewRPCClient(storePath, certsDir),
flock: fslock.New(localpath.MakeMiniPath("machine_client.lock")),
}, nil
}
@ -81,6 +83,7 @@ type LocalClient struct {
storePath string
*persist.Filestore
legacyClient libmachine.API
flock *fslock.Lock
}
// NewHost creates a new Host
@ -183,7 +186,22 @@ func (api *LocalClient) Create(h *host.Host) error {
}{
{
"bootstrapping certificates",
func() error { return cert.BootstrapCertificates(h.AuthOptions()) },
func() error {
// Lock is needed to avoid race conditiion in parallel Docker-Env test because issue #10107.
// CA cert and client cert should be generated atomically, otherwise might cause bad certificate error.
lockErr := api.flock.LockWithTimeout(time.Second * 5)
if lockErr != nil {
return fmt.Errorf("failed to acquire bootstrap client lock: %v " + lockErr.Error())
}
defer func() {
lockErr = api.flock.Unlock()
if lockErr != nil {
klog.Errorf("falied to release bootstrap cert client lock: %v", lockErr.Error())
}
}()
certErr := cert.BootstrapCertificates(h.AuthOptions())
return certErr
},
},
{
"precreate",

View File

@ -21,9 +21,9 @@ import (
"os/exec"
"github.com/docker/machine/libmachine/provision"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/mem"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/mem"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/out"

View File

@ -84,10 +84,6 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
}
func status() registry.State {
if runtime.GOARCH != "amd64" && runtime.GOARCH != "arm64" {
return registry.State{Error: fmt.Errorf("docker driver is not supported on %q systems yet", runtime.GOARCH), Installed: false, Healthy: false, Fix: "Try other drivers", Doc: docURL}
}
_, err := exec.LookPath(oci.Docker)
if err != nil {
return registry.State{Error: err, Installed: false, Healthy: false, Fix: "Install Docker", Doc: docURL}

0
site/content/en/docs/_index.md Executable file → Normal file
View File

0
site/content/en/docs/handbook/controls.md Executable file → Normal file
View File

0
site/content/en/docs/tutorials/_index.md Executable file → Normal file
View File

View File

@ -161,7 +161,7 @@ func validateNodeLabels(ctx context.Context, t *testing.T, profile string) {
// check functionality of minikube after evaling docker-env
func validateDockerEnv(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
mctx, cancel := context.WithTimeout(ctx, Seconds(30))
mctx, cancel := context.WithTimeout(ctx, Seconds(120))
defer cancel()
var rr *RunResult
var err error
@ -183,7 +183,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) {
t.Fatalf("expected status output to include 'Running' after eval docker-env but got: *%s*", rr.Output())
}
mctx, cancel = context.WithTimeout(ctx, Seconds(30))
mctx, cancel = context.WithTimeout(ctx, Seconds(60))
defer cancel()
// do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube
if runtime.GOOS == "windows" { // testing docker-env eval in powershell

View File

@ -35,7 +35,7 @@ import (
"time"
"github.com/docker/machine/libmachine/state"
"github.com/shirou/gopsutil/process"
"github.com/shirou/gopsutil/v3/process"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"