add --no-kubernetes flag to start minikube without kubernetes
parent
83acfbb0d4
commit
79f1b8c55c
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
@ -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
|
||||
- "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)
|
||||
|
@ -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})
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
@ -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.")
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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"))
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue