Merge branch 'master' into podman-sudo
commit
f78e00e99b
|
@ -99,6 +99,7 @@ const (
|
||||||
nodes = "nodes"
|
nodes = "nodes"
|
||||||
preload = "preload"
|
preload = "preload"
|
||||||
deleteOnFailure = "delete-on-failure"
|
deleteOnFailure = "delete-on-failure"
|
||||||
|
forceSystemd = "force-systemd"
|
||||||
kicBaseImage = "base-image"
|
kicBaseImage = "base-image"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -138,6 +139,7 @@ func initMinikubeFlags() {
|
||||||
startCmd.Flags().IntP(nodes, "n", 1, "The number of nodes to spin up. Defaults to 1.")
|
startCmd.Flags().IntP(nodes, "n", 1, "The number of nodes to spin up. Defaults to 1.")
|
||||||
startCmd.Flags().Bool(preload, true, "If set, download tarball of preloaded images if available to improve start time. Defaults to true.")
|
startCmd.Flags().Bool(preload, true, "If set, download tarball of preloaded images if available to improve start time. Defaults to true.")
|
||||||
startCmd.Flags().Bool(deleteOnFailure, false, "If set, delete the current cluster if start fails and try again. Defaults to false.")
|
startCmd.Flags().Bool(deleteOnFailure, false, "If set, delete the current cluster if start fails and try again. Defaults to false.")
|
||||||
|
startCmd.Flags().Bool(forceSystemd, false, "If set, force the container runtime to use sytemd as cgroup manager. Currently available for docker and crio. Defaults to false.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// initKubernetesFlags inits the commandline flags for kubernetes related options
|
// initKubernetesFlags inits the commandline flags for kubernetes related options
|
||||||
|
|
|
@ -88,7 +88,7 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed create new runtime")
|
return errors.Wrap(err, "failed create new runtime")
|
||||||
}
|
}
|
||||||
if err := cr.Enable(true); err != nil {
|
if err := cr.Enable(true, false); err != nil {
|
||||||
return errors.Wrap(err, "enable container runtime")
|
return errors.Wrap(err, "enable container runtime")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable idempotently enables containerd on a host
|
// Enable idempotently enables containerd on a host
|
||||||
func (r *Containerd) Enable(disOthers bool) error {
|
func (r *Containerd) Enable(disOthers, _ bool) error {
|
||||||
if disOthers {
|
if disOthers {
|
||||||
if err := disableOthers(r, r.Runner); err != nil {
|
if err := disableOthers(r, r.Runner); err != nil {
|
||||||
glog.Warningf("disableOthers: %v", err)
|
glog.Warningf("disableOthers: %v", err)
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (r *CRIO) Active() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable idempotently enables CRIO on a host
|
// Enable idempotently enables CRIO on a host
|
||||||
func (r *CRIO) Enable(disOthers bool) error {
|
func (r *CRIO) Enable(disOthers, _ bool) error {
|
||||||
if disOthers {
|
if disOthers {
|
||||||
if err := disableOthers(r, r.Runner); err != nil {
|
if err := disableOthers(r, r.Runner); err != nil {
|
||||||
glog.Warningf("disableOthers: %v", err)
|
glog.Warningf("disableOthers: %v", err)
|
||||||
|
|
|
@ -63,7 +63,7 @@ type Manager interface {
|
||||||
// Version retrieves the current version of this runtime
|
// Version retrieves the current version of this runtime
|
||||||
Version() (string, error)
|
Version() (string, error)
|
||||||
// Enable idempotently enables this runtime on a host
|
// Enable idempotently enables this runtime on a host
|
||||||
Enable(bool) error
|
Enable(bool, bool) error
|
||||||
// Disable idempotently disables this runtime on a host
|
// Disable idempotently disables this runtime on a host
|
||||||
Disable() error
|
Disable() error
|
||||||
// Active returns whether or not a runtime is active on a host
|
// Active returns whether or not a runtime is active on a host
|
||||||
|
|
|
@ -581,7 +581,7 @@ func TestEnable(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("New(%s): %v", tc.runtime, err)
|
t.Fatalf("New(%s): %v", tc.runtime, err)
|
||||||
}
|
}
|
||||||
err = cr.Enable(true)
|
err = cr.Enable(true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%s disable unexpected error: %v", tc.runtime, err)
|
t.Errorf("%s disable unexpected error: %v", tc.runtime, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,13 +103,20 @@ func (r *Docker) Active() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable idempotently enables Docker on a host
|
// Enable idempotently enables Docker on a host
|
||||||
func (r *Docker) Enable(disOthers bool) error {
|
func (r *Docker) Enable(disOthers, forceSystemd bool) error {
|
||||||
if disOthers {
|
if disOthers {
|
||||||
if err := disableOthers(r, r.Runner); err != nil {
|
if err := disableOthers(r, r.Runner); err != nil {
|
||||||
glog.Warningf("disableOthers: %v", err)
|
glog.Warningf("disableOthers: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if forceSystemd {
|
||||||
|
if err := r.forceSystemd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return r.Init.Restart("docker")
|
||||||
|
}
|
||||||
|
|
||||||
return r.Init.Start("docker")
|
return r.Init.Start("docker")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +281,22 @@ func (r *Docker) SystemLogCmd(len int) string {
|
||||||
return fmt.Sprintf("sudo journalctl -u docker -n %d", len)
|
return fmt.Sprintf("sudo journalctl -u docker -n %d", len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ForceSystemd forces the docker daemon to use systemd as cgroup manager
|
||||||
|
func (r *Docker) forceSystemd() error {
|
||||||
|
glog.Infof("Forcing docker to use systemd as cgroup manager...")
|
||||||
|
daemonConfig := `{
|
||||||
|
"exec-opts": ["native.cgroupdriver=systemd"],
|
||||||
|
"log-driver": "json-file",
|
||||||
|
"log-opts": {
|
||||||
|
"max-size": "100m"
|
||||||
|
},
|
||||||
|
"storage-driver": "overlay2"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
ma := assets.NewMemoryAsset([]byte(daemonConfig), "/etc/docker", "daemon.json", "0644")
|
||||||
|
return r.Runner.Copy(ma)
|
||||||
|
}
|
||||||
|
|
||||||
// Preload preloads docker with k8s images:
|
// Preload preloads docker with k8s images:
|
||||||
// 1. Copy over the preloaded tarball into the VM
|
// 1. Copy over the preloaded tarball into the VM
|
||||||
// 2. Extract the preloaded tarball to the correct directory
|
// 2. Extract the preloaded tarball to the correct directory
|
||||||
|
|
|
@ -255,7 +255,7 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cr.Enable(disableOthers)
|
err = cr.Enable(disableOthers, viper.GetBool("force-systemd"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debug.PrintStack()
|
debug.PrintStack()
|
||||||
exit.WithError("Failed to enable container runtime", err)
|
exit.WithError("Failed to enable container runtime", err)
|
||||||
|
|
|
@ -50,6 +50,7 @@ minikube start [flags]
|
||||||
Valid kubeadm parameters: ignore-preflight-errors, dry-run, kubeconfig, kubeconfig-dir, node-name, cri-socket, experimental-upload-certs, certificate-key, rootfs, skip-phases, pod-network-cidr
|
Valid kubeadm parameters: ignore-preflight-errors, dry-run, kubeconfig, kubeconfig-dir, node-name, cri-socket, experimental-upload-certs, certificate-key, rootfs, skip-phases, pod-network-cidr
|
||||||
--feature-gates string A set of key=value pairs that describe feature gates for alpha/experimental features.
|
--feature-gates string A set of key=value pairs that describe feature gates for alpha/experimental features.
|
||||||
--force Force minikube to perform possibly dangerous operations
|
--force Force minikube to perform possibly dangerous operations
|
||||||
|
--force-systemd If set, force the container runtime to use sytemd as cgroup manager. Currently available for docker and crio. Defaults to false.
|
||||||
-h, --help help for start
|
-h, --help help for start
|
||||||
--host-dns-resolver Enable host resolver for NAT DNS requests (virtualbox driver only) (default true)
|
--host-dns-resolver Enable host resolver for NAT DNS requests (virtualbox driver only) (default true)
|
||||||
--host-only-cidr string The CIDR to be used for the minikube VM (virtualbox driver only) (default "192.168.99.1/24")
|
--host-only-cidr string The CIDR to be used for the minikube VM (virtualbox driver only) (default "192.168.99.1/24")
|
||||||
|
|
|
@ -63,3 +63,30 @@ func TestDockerFlags(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestForceSystemd(t *testing.T) {
|
||||||
|
if NoneDriver() {
|
||||||
|
t.Skip("skipping: none driver does not support ssh or bundle docker")
|
||||||
|
}
|
||||||
|
MaybeParallel(t)
|
||||||
|
|
||||||
|
profile := UniqueProfileName("force-systemd")
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
|
||||||
|
defer CleanupWithLogs(t, profile, cancel)
|
||||||
|
|
||||||
|
// Use the most verbose logging for the simplest test. If it fails, something is very wrong.
|
||||||
|
args := append([]string{"start", "-p", profile, "--force-systemd", "--alsologtostderr", "-v=5"}, StartArgs()...)
|
||||||
|
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(rr.Output(), "systemd") {
|
||||||
|
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue