Skip to content

Add --no-kubernetes flag to start minikube without kubernetes #12848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/minikube/cmd/config/profile_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ func profilesToTableData(profiles []*config.Profile) [][]string {
exit.Error(reason.GuestCpConfig, "error getting primary control plane", err)
}

data = append(data, []string{p.Name, p.Config.Driver, p.Config.KubernetesConfig.ContainerRuntime, cp.IP, strconv.Itoa(cp.Port), p.Config.KubernetesConfig.KubernetesVersion, p.Status, strconv.Itoa(len(p.Config.Nodes))})
k8sVersion := p.Config.KubernetesConfig.KubernetesVersion
if k8sVersion == "v0.0.0" { // for --no-kubernetes flag
k8sVersion = "N/A"
}
data = append(data, []string{p.Name, p.Config.Driver, p.Config.KubernetesConfig.ContainerRuntime, cp.IP, strconv.Itoa(cp.Port), k8sVersion, p.Status, strconv.Itoa(len(p.Config.Nodes))})
}
return data
}
Expand Down
28 changes: 27 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"strconv"
"strings"

"github.com/Delta456/box-cli-maker/v2"
"github.com/blang/semver/v4"
"github.com/docker/machine/libmachine/ssh"
"github.com/google/go-containerregistry/pkg/authn"
Expand Down Expand Up @@ -432,6 +433,17 @@ func displayEnviron(env []string) {
}

func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName string) error {
if k8sVersion == "v0.0.0" {
register.Reg.SetStep(register.Done)
out.Step(style.Ready, "Done! minikube is ready without Kubernetes!")
out.BoxedWithConfig(box.Config{Py: 1, Px: 4, Type: "Round", Color: "Green"}, style.Tip, "Things to try without Kubernetes ...", `- "minikube ssh" to SSH into minikube's node.
- "minikube docker-env" to build images by pointing to the docker inside minikube
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check for the runtime being docker, so needs a parameter with the current setting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actualy aware of this I was gonna make a good first issue out of this for joey

- "minikube image" to build images without docker`)
return nil
}

// here are some ideas to do without Kubernetes:

// To be shown at the end, regardless of exit path
defer func() {
register.Reg.SetStep(register.Done)
Expand Down Expand Up @@ -1463,7 +1475,6 @@ func autoSetDriverOptions(cmd *cobra.Command, drvName string) (err error) {
// validateKubernetesVersion ensures that the requested version is reasonable
func validateKubernetesVersion(old *config.ClusterConfig) {
nvs, _ := semver.Make(strings.TrimPrefix(getKubernetesVersion(old), version.VersionPrefix))

oldestVersion, err := semver.Make(strings.TrimPrefix(constants.OldestKubernetesVersion, version.VersionPrefix))
if err != nil {
exit.Message(reason.InternalSemverParse, "Unable to parse oldest Kubernetes version from constants: {{.error}}", out.V{"error": err})
Expand All @@ -1473,6 +1484,15 @@ func validateKubernetesVersion(old *config.ClusterConfig) {
exit.Message(reason.InternalSemverParse, "Unable to parse default Kubernetes version from constants: {{.error}}", out.V{"error": err})
}

zeroVersion, err := semver.Make("0.0.0")
if err != nil {
exit.Message(reason.InternalSemverParse, "Unable to parse v0.0.0 Kubernetes : {{.error}}", out.V{"error": err})
}

if nvs.Equals(zeroVersion) {
klog.Info("No kuberentes version set for minikube, setting Kubernetes version to v0.0.0")
return
}
if nvs.LT(oldestVersion) {
out.WarningT("Specified Kubernetes version {{.specified}} is less than the oldest supported version: {{.oldest}}", out.V{"specified": nvs, "oldest": constants.OldestKubernetesVersion})
if !viper.GetBool(force) {
Expand Down Expand Up @@ -1519,6 +1539,12 @@ func isBaseImageApplicable(drv string) bool {
}

func getKubernetesVersion(old *config.ClusterConfig) string {
if viper.GetBool(noKubernetes) {
klog.Info("No Kubernetes flag is set, setting Kubernetes version to v0.0.0")
viper.Set(kubernetesVersion, "v0.0.0")

}

paramVersion := viper.GetString(kubernetesVersion)

// try to load the old version first if the user didn't specify anything
Expand Down
2 changes: 2 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
nfsSharesRoot = "nfs-shares-root"
nfsShare = "nfs-share"
kubernetesVersion = "kubernetes-version"
noKubernetes = "no-kubernetes"
hostOnlyCIDR = "host-only-cidr"
containerRuntime = "container-runtime"
criSocket = "cri-socket"
Expand Down Expand Up @@ -164,6 +165,7 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(installAddons, true, "If set, install addons. Defaults to true.")
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(noKubernetes, false, "If set, minikube VM/container will start without starting or configuring Kubernetes. (only works on new clusters)")
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 systemd as cgroup manager. Defaults to false.")
startCmd.Flags().StringP(network, "", "", "network to run minikube with. Now it is used by docker/podman and KVM drivers. If left empty, minikube will create a new network.")
Expand Down
18 changes: 13 additions & 5 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ type Starter struct {

// Start spins up a guest and starts the Kubernetes node.
func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
var kcs *kubeconfig.Settings
if starter.Node.KubernetesVersion == "v0.0.0" {
return kcs, config.Write(viper.GetString(config.ProfileName), starter.Cfg)
}
// wait for preloaded tarball to finish downloading before configuring runtimes
waitCacheRequiredImages(&cacheGroup)

Expand Down Expand Up @@ -115,7 +119,6 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
}

var bs bootstrapper.Bootstrapper
var kcs *kubeconfig.Settings
if apiServer {
// Must be written before bootstrap, otherwise health checks may flake due to stale IP
kcs = setupKubeconfig(starter.Host, starter.Cfg, starter.Node, starter.Cfg.Name)
Expand Down Expand Up @@ -286,11 +289,16 @@ func joinCluster(starter Starter, cpBs bootstrapper.Bootstrapper, bs bootstrappe
func Provision(cc *config.ClusterConfig, n *config.Node, apiServer bool, delOnFail bool) (command.Runner, bool, libmachine.API, *host.Host, error) {
register.Reg.SetStep(register.StartingNode)
name := config.MachineName(*cc, *n)
if apiServer {
out.Step(style.ThumbsUp, "Starting control plane node {{.name}} in cluster {{.cluster}}", out.V{"name": name, "cluster": cc.Name})
} else {
out.Step(style.ThumbsUp, "Starting node {{.name}} in cluster {{.cluster}}", out.V{"name": name, "cluster": cc.Name})

nodeTitle := "Starting control plane node"
if !apiServer {
nodeTitle = "Starting worker node"
}
if cc.KubernetesConfig.KubernetesVersion == "v0.0.0" {
nodeTitle = "Starting minikube without Kubernetes"
}

out.Step(style.ThumbsUp, "{{.nodeName}} {{.name}} in cluster {{.cluster}}", out.V{"nodeName": nodeTitle, "name": name, "cluster": cc.Name})

if driver.IsKIC(cc.Driver) {
beginDownloadKicBaseImage(&kicGroup, cc, viper.GetBool("download-only"))
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/out/out.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ func BoxedErr(format string, a ...V) {
}

// BoxedWithConfig writes a templated message in a box with customized style config to stdout
func BoxedWithConfig(cfg box.Config, st style.Enum, title string, format string, a ...V) {
func BoxedWithConfig(cfg box.Config, st style.Enum, title string, text string, a ...V) {
if st != style.None {
title = Sprintf(st, title)
}
// need to make sure no newlines are in the title otherwise box-cli-maker panics
title = strings.ReplaceAll(title, "\n", "")
boxedCommon(String, cfg, title, format, a...)
boxedCommon(String, cfg, title, text, a...)
}

// Sprintf is used for returning the string (doesn't write anything)
Expand Down