From 878c3ca2b62a100050fa88aeb4330d8bd4d7a511 Mon Sep 17 00:00:00 2001 From: yugo horie Date: Sun, 22 Sep 2019 13:39:49 +0900 Subject: [PATCH] WIP: Remove all single-package constants from constants package #5375 --- cmd/minikube/cmd/cache.go | 8 +- cmd/minikube/cmd/cache_list.go | 7 +- cmd/minikube/cmd/config/addons_list.go | 5 +- cmd/minikube/cmd/config/util.go | 6 +- cmd/minikube/cmd/config/view.go | 4 +- cmd/minikube/cmd/mount.go | 12 ++- cmd/minikube/cmd/root.go | 6 +- cmd/minikube/cmd/root_test.go | 5 +- cmd/minikube/cmd/start.go | 43 +++++---- cmd/minikube/cmd/start_test.go | 4 +- cmd/minikube/cmd/status.go | 7 +- pkg/gvisor/disable.go | 9 +- pkg/gvisor/enable.go | 16 ++-- pkg/minikube/assets/addons.go | 92 ++++++++++--------- pkg/minikube/assets/addons_test.go | 9 +- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 13 ++- .../bootstrapper/kubeadm/templates.go | 4 +- pkg/minikube/constants/constants.go | 77 ---------------- pkg/minikube/service/service.go | 5 +- .../content/en/docs/Contributing/addons.en.md | 6 +- 20 files changed, 149 insertions(+), 189 deletions(-) diff --git a/cmd/minikube/cmd/cache.go b/cmd/minikube/cmd/cache.go index b2795e48517d..8656cf98c17b 100644 --- a/cmd/minikube/cmd/cache.go +++ b/cmd/minikube/cmd/cache.go @@ -25,6 +25,8 @@ import ( "k8s.io/minikube/pkg/minikube/machine" ) +const cache = "cache" + // cacheCmd represents the cache command var cacheCmd = &cobra.Command{ Use: "cache", @@ -43,7 +45,7 @@ var addCacheCmd = &cobra.Command{ exit.WithError("Failed to cache and load images", err) } // Add images to config file - if err := cmdConfig.AddToConfigMap(constants.Cache, args); err != nil { + if err := cmdConfig.AddToConfigMap(cache, args); err != nil { exit.WithError("Failed to update config", err) } }, @@ -56,7 +58,7 @@ var deleteCacheCmd = &cobra.Command{ Long: "Delete an image from the local cache.", Run: func(cmd *cobra.Command, args []string) { // Delete images from config file - if err := cmdConfig.DeleteFromConfigMap(constants.Cache, args); err != nil { + if err := cmdConfig.DeleteFromConfigMap(cache, args); err != nil { exit.WithError("Failed to delete images from config", err) } // Delete images from cache/images directory @@ -71,7 +73,7 @@ func imagesInConfigFile() ([]string, error) { if err != nil { return nil, err } - if values, ok := configFile[constants.Cache]; ok { + if values, ok := configFile[cache]; ok { var images []string for key := range values.(map[string]interface{}) { images = append(images, key) diff --git a/cmd/minikube/cmd/cache_list.go b/cmd/minikube/cmd/cache_list.go index 2d7466061e58..6025430d5bd5 100644 --- a/cmd/minikube/cmd/cache_list.go +++ b/cmd/minikube/cmd/cache_list.go @@ -22,10 +22,11 @@ import ( "github.com/spf13/cobra" cmdConfig "k8s.io/minikube/cmd/minikube/cmd/config" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" ) +const defaultCacheListFormat = "{{.CacheImage}}\n" + var cacheListFormat string // CacheListTemplate represents the cache list template @@ -39,7 +40,7 @@ var listCacheCmd = &cobra.Command{ Short: "List all available images from the local cache.", Long: "List all available images from the local cache.", Run: func(cmd *cobra.Command, args []string) { - images, err := cmdConfig.ListConfigMap(constants.Cache) + images, err := cmdConfig.ListConfigMap(cache) if err != nil { exit.WithError("Failed to get image map", err) } @@ -50,7 +51,7 @@ var listCacheCmd = &cobra.Command{ } func init() { - listCacheCmd.Flags().StringVar(&cacheListFormat, "format", constants.DefaultCacheListFormat, + listCacheCmd.Flags().StringVar(&cacheListFormat, "format", defaultCacheListFormat, `Go template format string for the cache list output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ For the list of accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#CacheListTemplate`) cacheCmd.AddCommand(listCacheCmd) diff --git a/cmd/minikube/cmd/config/addons_list.go b/cmd/minikube/cmd/config/addons_list.go index bf05d976a7a7..72aadadc22ea 100644 --- a/cmd/minikube/cmd/config/addons_list.go +++ b/cmd/minikube/cmd/config/addons_list.go @@ -23,10 +23,11 @@ import ( "github.com/spf13/cobra" "k8s.io/minikube/pkg/minikube/assets" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" ) +const defaultAddonListFormat = "- {{.AddonName}}: {{.AddonStatus}}\n" + var addonListFormat string // AddonListTemplate represents the addon list template @@ -51,7 +52,7 @@ var addonsListCmd = &cobra.Command{ } func init() { - AddonsCmd.Flags().StringVar(&addonListFormat, "format", constants.DefaultAddonListFormat, + AddonsCmd.Flags().StringVar(&addonListFormat, "format", defaultAddonListFormat, `Go template format string for the addon list output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ For the list of accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd/config#AddonListTemplate`) AddonsCmd.AddCommand(addonsListCmd) diff --git a/cmd/minikube/cmd/config/util.go b/cmd/minikube/cmd/config/util.go index f04222d9015b..d103ba36ea97 100644 --- a/cmd/minikube/cmd/config/util.go +++ b/cmd/minikube/cmd/config/util.go @@ -27,13 +27,15 @@ import ( "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/command" "k8s.io/minikube/pkg/minikube/config" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/storageclass" ) +// defaultStorageClassProvisioner is the name of the default storage class provisioner +const defaultStorageClassProvisioner = "standard" + // Runs all the validation or callback functions and collects errors func run(name string, value string, fns []setFn) error { var errors []error @@ -205,7 +207,7 @@ func EnableOrDisableStorageClasses(name, val string) error { return errors.Wrap(err, "Error parsing boolean") } - class := constants.DefaultStorageClassProvisioner + class := defaultStorageClassProvisioner if name == "storage-provisioner-gluster" { class = "glusterfile" } diff --git a/cmd/minikube/cmd/config/view.go b/cmd/minikube/cmd/config/view.go index 33f79e12cd40..9f91d7b1dd47 100644 --- a/cmd/minikube/cmd/config/view.go +++ b/cmd/minikube/cmd/config/view.go @@ -26,6 +26,8 @@ import ( "k8s.io/minikube/pkg/minikube/exit" ) +const defaultConfigViewFormat = "- {{.ConfigKey}}: {{.ConfigValue}}\n" + var viewFormat string // ViewTemplate represents the view template @@ -47,7 +49,7 @@ var configViewCmd = &cobra.Command{ } func init() { - configViewCmd.Flags().StringVar(&viewFormat, "format", constants.DefaultConfigViewFormat, + configViewCmd.Flags().StringVar(&viewFormat, "format", defaultConfigViewFormat, `Go template format string for the config view output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ For the list of accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd/config#ConfigViewTemplate`) ConfigCmd.AddCommand(configViewCmd) diff --git a/cmd/minikube/cmd/mount.go b/cmd/minikube/cmd/mount.go index d2942699de0b..6a4885d18c00 100644 --- a/cmd/minikube/cmd/mount.go +++ b/cmd/minikube/cmd/mount.go @@ -38,8 +38,12 @@ import ( "k8s.io/minikube/third_party/go9p/ufs" ) -// nineP is the value of --type used for the 9p filesystem. -const nineP = "9p" +const ( + // nineP is the value of --type used for the 9p filesystem. + nineP = "9p" + defaultMountVersion = "9p2000.L" + defaultMsize = 262144 +) // placeholders for flag values var mountIP string @@ -202,13 +206,13 @@ var mountCmd = &cobra.Command{ func init() { mountCmd.Flags().StringVar(&mountIP, "ip", "", "Specify the ip that the mount should be setup on") mountCmd.Flags().StringVar(&mountType, "type", nineP, "Specify the mount filesystem type (supported types: 9p)") - mountCmd.Flags().StringVar(&mountVersion, "9p-version", constants.DefaultMountVersion, "Specify the 9p version that the mount should use") + mountCmd.Flags().StringVar(&mountVersion, "9p-version", defaultMountVersion, "Specify the 9p version that the mount should use") mountCmd.Flags().BoolVar(&isKill, "kill", false, "Kill the mount process spawned by minikube start") mountCmd.Flags().StringVar(&uid, "uid", "docker", "Default user id used for the mount") mountCmd.Flags().StringVar(&gid, "gid", "docker", "Default group id used for the mount") mountCmd.Flags().UintVar(&mode, "mode", 0755, "File permissions used for the mount") mountCmd.Flags().StringSliceVar(&options, "options", []string{}, "Additional mount options, such as cache=fscache") - mountCmd.Flags().IntVar(&mSize, "msize", constants.DefaultMsize, "The number of bytes to use for 9p packet payload") + mountCmd.Flags().IntVar(&mSize, "msize", defaultMsize, "The number of bytes to use for 9p packet payload") } // getPort asks the kernel for a free open port that is ready to use diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 894ec3639826..d09553355d70 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -40,6 +40,8 @@ import ( "k8s.io/minikube/pkg/minikube/translate" ) +const defaultClusterBootstrapper = "kubeadm" + var dirs = [...]string{ localpath.MiniPath(), localpath.MakeMiniPath("certs"), @@ -161,7 +163,7 @@ func setFlagsUsingViper() { func init() { translate.DetermineLocale() RootCmd.PersistentFlags().StringP(config.MachineProfile, "p", constants.DefaultMachineName, `The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently.`) - RootCmd.PersistentFlags().StringP(configCmd.Bootstrapper, "b", constants.DefaultClusterBootstrapper, "The name of the cluster bootstrapper that will set up the kubernetes cluster.") + RootCmd.PersistentFlags().StringP(configCmd.Bootstrapper, "b", defaultClusterBootstrapper, "The name of the cluster bootstrapper that will set up the kubernetes cluster.") groups := templates.CommandGroups{ { @@ -243,7 +245,7 @@ func initConfig() { } func setupViper() { - viper.SetEnvPrefix(constants.MinikubeEnvPrefix) + viper.SetEnvPrefix(minikubeEnvPrefix) // Replaces '-' in flags with '_' in env variables // e.g. iso-url => $ENVPREFIX_ISO_URL viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) diff --git a/cmd/minikube/cmd/root_test.go b/cmd/minikube/cmd/root_test.go index 87a4faa325f8..b0c29ca4b14b 100644 --- a/cmd/minikube/cmd/root_test.go +++ b/cmd/minikube/cmd/root_test.go @@ -26,7 +26,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/tests" ) @@ -97,7 +96,7 @@ func runCommand(f func(*cobra.Command, []string)) { func hideEnv(t *testing.T) func(t *testing.T) { envs := make(map[string]string) for _, env := range os.Environ() { - if strings.HasPrefix(env, constants.MinikubeEnvPrefix) { + if strings.HasPrefix(env, minikubeEnvPrefix) { line := strings.Split(env, "=") key, val := line[0], line[1] envs[key] = val @@ -143,7 +142,7 @@ func TestViperConfig(t *testing.T) { } func getEnvVarName(name string) string { - return constants.MinikubeEnvPrefix + "_" + strings.ToUpper(name) + return minikubeEnvPrefix + "_" + strings.ToUpper(name) } func setValues(tt configTest) error { diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 3106b441208f..ee3ce0de2188 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -85,6 +85,11 @@ const ( kvmQemuURI = "kvm-qemu-uri" kvmGPU = "kvm-gpu" kvmHidden = "kvm-hidden" + minikubeEnvPrefix = "MINIKUBE" + defaultEmbedCerts = false + defaultKeepContext = false + defaultMemorySize = "2000mb" + defaultDiskSize = "20000mb" keepContext = "keep-context" createMount = "mount" featureGates = "feature-gates" @@ -110,6 +115,12 @@ const ( interactive = "interactive" waitTimeout = "wait-timeout" nativeSSH = "native-ssh" + minimumMemorySize = "1024mb" + defaultCPUS = 2 + minimumCPUS = 2 + minimumDiskSize = "2000mb" + defaultVMDriver = constants.DriverVirtualbox + defaultMountEndpoint = "/minikube-host" ) var ( @@ -136,7 +147,7 @@ func init() { // initMinikubeFlags includes commandline flags for minikube. func initMinikubeFlags() { - viper.SetEnvPrefix(constants.MinikubeEnvPrefix) + viper.SetEnvPrefix(minikubeEnvPrefix) // Replaces '-' in flags with '_' in env variables // e.g. iso-url => $ENVPREFIX_ISO_URL viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) @@ -145,17 +156,17 @@ func initMinikubeFlags() { startCmd.Flags().Bool(force, false, "Force minikube to perform possibly dangerous operations") startCmd.Flags().Bool(interactive, true, "Allow user prompts for more information") - startCmd.Flags().Int(cpus, constants.DefaultCPUS, "Number of CPUs allocated to the minikube VM.") - startCmd.Flags().String(memory, constants.DefaultMemorySize, "Amount of RAM allocated to the minikube VM (format: [], where unit = b, k, m or g).") - startCmd.Flags().String(humanReadableDiskSize, constants.DefaultDiskSize, "Disk size allocated to the minikube VM (format: [], where unit = b, k, m or g).") + startCmd.Flags().Int(cpus, defaultCPUS, "Number of CPUs allocated to the minikube VM.") + startCmd.Flags().String(memory, defaultMemorySize, "Amount of RAM allocated to the minikube VM (format: [], where unit = b, k, m or g).") + startCmd.Flags().String(humanReadableDiskSize, defaultDiskSize, "Disk size allocated to the minikube VM (format: [], where unit = b, k, m or g).") startCmd.Flags().Bool(downloadOnly, false, "If true, only download and cache files for later use - don't install or start anything.") startCmd.Flags().Bool(cacheImages, true, "If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --vm-driver=none.") startCmd.Flags().String(isoURL, constants.DefaultISOURL, "Location of the minikube iso.") - startCmd.Flags().Bool(keepContext, constants.DefaultKeepContext, "This will keep the existing kubectl context and will create a minikube context.") - startCmd.Flags().Bool(embedCerts, constants.DefaultEmbedCerts, "if true, will embed the certs in kubeconfig.") + startCmd.Flags().Bool(keepContext, defaultKeepContext, "This will keep the existing kubectl context and will create a minikube context.") + startCmd.Flags().Bool(embedCerts, defaultEmbedCerts, "if true, will embed the certs in kubeconfig.") startCmd.Flags().String(containerRuntime, "docker", "The container runtime to be used (docker, crio, containerd).") startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube.") - startCmd.Flags().String(mountString, constants.DefaultMountDir+":"+constants.DefaultMountEndpoint, "The argument to pass the minikube mount command on start.") + startCmd.Flags().String(mountString, constants.DefaultMountDir+":"+defaultMountEndpoint, "The argument to pass the minikube mount command on start.") startCmd.Flags().String(criSocket, "", "The cri socket path to be used.") startCmd.Flags().String(networkPlugin, "", "The name of the network plugin.") startCmd.Flags().Bool(enableDefaultCNI, false, "Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with \"--network-plugin=cni\".") @@ -476,7 +487,7 @@ func selectDriver(oldConfig *cfg.Config) string { driver := viper.GetString("vm-driver") // By default, the driver is whatever we used last time if driver == "" { - driver = constants.DefaultVMDriver + driver = defaultVMDriver if oldConfig != nil { driver = oldConfig.MachineConfig.VMDriver } @@ -619,17 +630,17 @@ func validateUser(driver string) { // validateFlags validates the supplied flags against known bad combinations func validateFlags(driver string) { diskSizeMB := pkgutil.CalculateSizeInMB(viper.GetString(humanReadableDiskSize)) - if diskSizeMB < pkgutil.CalculateSizeInMB(constants.MinimumDiskSize) && !viper.GetBool(force) { - exit.WithCodeT(exit.Config, "Requested disk size {{.requested_size}} is less than minimum of {{.minimum_size}}", out.V{"requested_size": diskSizeMB, "minimum_size": pkgutil.CalculateSizeInMB(constants.MinimumDiskSize)}) + if diskSizeMB < pkgutil.CalculateSizeInMB(minimumDiskSize) && !viper.GetBool(force) { + exit.WithCodeT(exit.Config, "Requested disk size {{.requested_size}} is less than minimum of {{.minimum_size}}", out.V{"requested_size": diskSizeMB, "minimum_size": pkgutil.CalculateSizeInMB(minimumDiskSize)}) } memorySizeMB := pkgutil.CalculateSizeInMB(viper.GetString(memory)) - if memorySizeMB < pkgutil.CalculateSizeInMB(constants.MinimumMemorySize) && !viper.GetBool(force) { - exit.UsageT("Requested memory allocation {{.requested_size}} is less than the minimum allowed of {{.minimum_size}}", out.V{"requested_size": memorySizeMB, "minimum_size": pkgutil.CalculateSizeInMB(constants.MinimumMemorySize)}) + if memorySizeMB < pkgutil.CalculateSizeInMB(minimumMemorySize) && !viper.GetBool(force) { + exit.UsageT("Requested memory allocation {{.requested_size}} is less than the minimum allowed of {{.minimum_size}}", out.V{"requested_size": memorySizeMB, "minimum_size": pkgutil.CalculateSizeInMB(minimumMemorySize)}) } - if memorySizeMB < pkgutil.CalculateSizeInMB(constants.DefaultMemorySize) && !viper.GetBool(force) { + if memorySizeMB < pkgutil.CalculateSizeInMB(defaultMemorySize) && !viper.GetBool(force) { out.T(out.Notice, "Requested memory allocation ({{.memory}}MB) is less than the default memory allocation of {{.default_memorysize}}MB. Beware that minikube might not work correctly or crash unexpectedly.", - out.V{"memory": memorySizeMB, "default_memorysize": pkgutil.CalculateSizeInMB(constants.DefaultMemorySize)}) + out.V{"memory": memorySizeMB, "default_memorysize": pkgutil.CalculateSizeInMB(defaultMemorySize)}) } var cpuCount int @@ -648,8 +659,8 @@ func validateFlags(driver string) { } else { cpuCount = viper.GetInt(cpus) } - if cpuCount < constants.MinimumCPUS { - exit.UsageT("Requested CPU count {{.requested_cpus}} is less than the minimum allowed of {{.minimum_cpus}}", out.V{"requested_cpus": cpuCount, "minimum_cpus": constants.MinimumCPUS}) + if cpuCount < minimumCPUS { + exit.UsageT("Requested cpu count {{.requested_cpus}} is less than the minimum allowed of {{.minimum_cpus}}", out.V{"requested_cpus": cpuCount, "minimum_cpus": minimumCPUS}) } // check that kubeadm extra args contain only whitelisted parameters diff --git a/cmd/minikube/cmd/start_test.go b/cmd/minikube/cmd/start_test.go index b5522df4506a..0f4fe397d2d6 100644 --- a/cmd/minikube/cmd/start_test.go +++ b/cmd/minikube/cmd/start_test.go @@ -26,8 +26,8 @@ import ( ) func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) { - viper.SetDefault(memory, constants.DefaultMemorySize) - viper.SetDefault(humanReadableDiskSize, constants.DefaultDiskSize) + viper.SetDefault(memory, defaultMemorySize) + viper.SetDefault(humanReadableDiskSize, defaultDiskSize) originalEnv := os.Getenv("HTTP_PROXY") defer func() { err := os.Setenv("HTTP_PROXY", originalEnv) diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index c34abb9869c1..217166107839 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -48,6 +48,11 @@ const ( minikubeNotRunningStatusFlag = 1 << 0 clusterNotRunningStatusFlag = 1 << 1 k8sNotRunningStatusFlag = 1 << 2 + defaultStatusFormat = `host: {{.Host}} +kubelet: {{.Kubelet}} +apiserver: {{.APIServer}} +kubectl: {{.Kubeconfig}} +` ) // statusCmd represents the status command @@ -140,7 +145,7 @@ var statusCmd = &cobra.Command{ } func init() { - statusCmd.Flags().StringVar(&statusFormat, "format", constants.DefaultStatusFormat, + statusCmd.Flags().StringVar(&statusFormat, "format", defaultStatusFormat, `Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status`) } diff --git a/pkg/gvisor/disable.go b/pkg/gvisor/disable.go index 4c00bbaea0c9..b55fadbec373 100644 --- a/pkg/gvisor/disable.go +++ b/pkg/gvisor/disable.go @@ -23,17 +23,16 @@ import ( "github.com/docker/machine/libmachine/mcnutils" "github.com/pkg/errors" - "k8s.io/minikube/pkg/minikube/constants" ) // Disable reverts containerd config files and restarts containerd func Disable() error { log.Print("Disabling gvisor...") - if err := os.Remove(filepath.Join(nodeDir, constants.ContainerdConfigTomlPath)); err != nil { - return errors.Wrapf(err, "removing %s", constants.ContainerdConfigTomlPath) + if err := os.Remove(filepath.Join(nodeDir, containerdConfigTomlPath)); err != nil { + return errors.Wrapf(err, "removing %s", containerdConfigTomlPath) } - log.Printf("Restoring default config.toml at %s", constants.ContainerdConfigTomlPath) - if err := mcnutils.CopyFile(filepath.Join(nodeDir, constants.StoredContainerdConfigTomlPath), filepath.Join(nodeDir, constants.ContainerdConfigTomlPath)); err != nil { + log.Printf("Restoring default config.toml at %s", containerdConfigTomlPath) + if err := mcnutils.CopyFile(filepath.Join(nodeDir, storedContainerdConfigTomlPath), filepath.Join(nodeDir, containerdConfigTomlPath)); err != nil { return errors.Wrap(err, "reverting back to default config.toml") } // restart containerd diff --git a/pkg/gvisor/enable.go b/pkg/gvisor/enable.go index 403ab0d4d8e8..2a5f9e315a29 100644 --- a/pkg/gvisor/enable.go +++ b/pkg/gvisor/enable.go @@ -35,7 +35,11 @@ import ( ) const ( - nodeDir = "/node" + nodeDir = "/node" + containerdConfigTomlPath = "/etc/containerd/config.toml" + storedContainerdConfigTomlPath = "/tmp/config.toml" + gvisorContainerdShimURL = "https://github.com/google/gvisor-containerd-shim/releases/download/v0.0.3/containerd-shim-runsc-v1.linux-amd64" + gvisorURL = "https://storage.googleapis.com/gvisor/releases/nightly/2019-01-14/runsc" ) // Enable follows these steps for enabling gvisor in minikube: @@ -102,13 +106,13 @@ func downloadBinaries() error { // downloads the gvisor-containerd-shim func gvisorContainerdShim() error { dest := filepath.Join(nodeDir, "usr/bin/containerd-shim-runsc-v1") - return downloadFileToDest(constants.GvisorContainerdShimURL, dest) + return downloadFileToDest(gvisorContainerdShimURL, dest) } // downloads the runsc binary and returns a path to the binary func runsc() error { dest := filepath.Join(nodeDir, "usr/bin/runsc") - return downloadFileToDest(constants.GvisorURL, dest) + return downloadFileToDest(gvisorURL, dest) } // downloadFileToDest downloads the given file to the dest @@ -149,12 +153,12 @@ func downloadFileToDest(url, dest string) error { // 2. gvisor containerd config.toml // and save the default version of config.toml func copyConfigFiles() error { - log.Printf("Storing default config.toml at %s", constants.StoredContainerdConfigTomlPath) - if err := mcnutils.CopyFile(filepath.Join(nodeDir, constants.ContainerdConfigTomlPath), filepath.Join(nodeDir, constants.StoredContainerdConfigTomlPath)); err != nil { + log.Printf("Storing default config.toml at %s", storedContainerdConfigTomlPath) + if err := mcnutils.CopyFile(filepath.Join(nodeDir, containerdConfigTomlPath), filepath.Join(nodeDir, storedContainerdConfigTomlPath)); err != nil { return errors.Wrap(err, "copying default config.toml") } log.Print("Copying containerd config.toml with gvisor...") - if err := copyAssetToDest(constants.GvisorConfigTomlTargetName, filepath.Join(nodeDir, constants.ContainerdConfigTomlPath)); err != nil { + if err := copyAssetToDest(constants.GvisorConfigTomlTargetName, filepath.Join(nodeDir, containerdConfigTomlPath)); err != nil { return errors.Wrap(err, "copying gvisor version of config.toml") } return nil diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index f362cde623f6..7a51e3326bd8 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -31,6 +31,8 @@ import ( "k8s.io/minikube/pkg/util" ) +const guestAddonsDir = "/etc/kubernetes/addons" + // Addon is a named list of assets, that can be enabled type Addon struct { Assets []*BinAsset @@ -78,21 +80,21 @@ var Addons = map[string]*Addon{ true), }, true, "addon-manager"), "dashboard": NewAddon([]*BinAsset{ - MustBinAsset("deploy/addons/dashboard/dashboard-clusterrole.yaml", constants.GuestAddonsDir, "dashboard-clusterrole.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-clusterrolebinding.yaml", constants.GuestAddonsDir, "dashboard-clusterrolebinding.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-configmap.yaml", constants.GuestAddonsDir, "dashboard-configmap.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-dp.yaml", constants.GuestAddonsDir, "dashboard-dp.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-ns.yaml", constants.GuestAddonsDir, "dashboard-ns.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-role.yaml", constants.GuestAddonsDir, "dashboard-role.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-rolebinding.yaml", constants.GuestAddonsDir, "dashboard-rolebinding.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-sa.yaml", constants.GuestAddonsDir, "dashboard-sa.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-secret.yaml", constants.GuestAddonsDir, "dashboard-secret.yaml", "0640", false), - MustBinAsset("deploy/addons/dashboard/dashboard-svc.yaml", constants.GuestAddonsDir, "dashboard-svc.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-clusterrole.yaml", guestAddonsDir, "dashboard-clusterrole.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-clusterrolebinding.yaml", guestAddonsDir, "dashboard-clusterrolebinding.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-configmap.yaml", guestAddonsDir, "dashboard-configmap.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-dp.yaml", guestAddonsDir, "dashboard-dp.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-ns.yaml", guestAddonsDir, "dashboard-ns.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-role.yaml", guestAddonsDir, "dashboard-role.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-rolebinding.yaml", guestAddonsDir, "dashboard-rolebinding.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-sa.yaml", guestAddonsDir, "dashboard-sa.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-secret.yaml", guestAddonsDir, "dashboard-secret.yaml", "0640", false), + MustBinAsset("deploy/addons/dashboard/dashboard-svc.yaml", guestAddonsDir, "dashboard-svc.yaml", "0640", false), }, false, "dashboard"), "default-storageclass": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/storageclass/storageclass.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "storageclass.yaml", "0640", false), @@ -100,7 +102,7 @@ var Addons = map[string]*Addon{ "storage-provisioner": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "storage-provisioner.yaml", "0640", true), @@ -108,25 +110,25 @@ var Addons = map[string]*Addon{ "storage-provisioner-gluster": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/storage-provisioner-gluster/storage-gluster-ns.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "storage-gluster-ns.yaml", "0640", false), MustBinAsset( "deploy/addons/storage-provisioner-gluster/glusterfs-daemonset.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "glusterfs-daemonset.yaml", "0640", false), MustBinAsset( "deploy/addons/storage-provisioner-gluster/heketi-deployment.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "heketi-deployment.yaml", "0640", false), MustBinAsset( "deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "storage-privisioner-glusterfile.yaml", "0640", false), @@ -134,31 +136,31 @@ var Addons = map[string]*Addon{ "heapster": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/heapster/influx-grafana-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "influxGrafana-rc.yaml", "0640", true), MustBinAsset( "deploy/addons/heapster/grafana-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "grafana-svc.yaml", "0640", false), MustBinAsset( "deploy/addons/heapster/influxdb-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "influxdb-svc.yaml", "0640", false), MustBinAsset( "deploy/addons/heapster/heapster-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "heapster-rc.yaml", "0640", true), MustBinAsset( "deploy/addons/heapster/heapster-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "heapster-svc.yaml", "0640", false), @@ -166,37 +168,37 @@ var Addons = map[string]*Addon{ "efk": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/efk/elasticsearch-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "elasticsearch-rc.yaml", "0640", true), MustBinAsset( "deploy/addons/efk/elasticsearch-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "elasticsearch-svc.yaml", "0640", false), MustBinAsset( "deploy/addons/efk/fluentd-es-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "fluentd-es-rc.yaml", "0640", true), MustBinAsset( "deploy/addons/efk/fluentd-es-configmap.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "fluentd-es-configmap.yaml", "0640", false), MustBinAsset( "deploy/addons/efk/kibana-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "kibana-rc.yaml", "0640", false), MustBinAsset( "deploy/addons/efk/kibana-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "kibana-svc.yaml", "0640", false), @@ -204,19 +206,19 @@ var Addons = map[string]*Addon{ "ingress": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/ingress/ingress-configmap.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "ingress-configmap.yaml", "0640", false), MustBinAsset( "deploy/addons/ingress/ingress-rbac.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "ingress-rbac.yaml", "0640", false), MustBinAsset( "deploy/addons/ingress/ingress-dp.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "ingress-dp.yaml", "0640", true), @@ -224,19 +226,19 @@ var Addons = map[string]*Addon{ "metrics-server": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/metrics-server/metrics-apiservice.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "metrics-apiservice.yaml", "0640", false), MustBinAsset( "deploy/addons/metrics-server/metrics-server-deployment.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "metrics-server-deployment.yaml", "0640", true), MustBinAsset( "deploy/addons/metrics-server/metrics-server-service.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "metrics-server-service.yaml", "0640", false), @@ -244,19 +246,19 @@ var Addons = map[string]*Addon{ "registry": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/registry/registry-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "registry-rc.yaml", "0640", false), MustBinAsset( "deploy/addons/registry/registry-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "registry-svc.yaml", "0640", false), MustBinAsset( "deploy/addons/registry/registry-proxy.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "registry-proxy.yaml", "0640", false), @@ -264,7 +266,7 @@ var Addons = map[string]*Addon{ "registry-creds": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "registry-creds-rc.yaml", "0640", false), @@ -272,7 +274,7 @@ var Addons = map[string]*Addon{ "freshpod": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/freshpod/freshpod-rc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "freshpod-rc.yaml", "0640", true), @@ -280,7 +282,7 @@ var Addons = map[string]*Addon{ "nvidia-driver-installer": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "nvidia-driver-installer.yaml", "0640", true), @@ -288,7 +290,7 @@ var Addons = map[string]*Addon{ "nvidia-gpu-device-plugin": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "nvidia-gpu-device-plugin.yaml", "0640", true), @@ -296,13 +298,13 @@ var Addons = map[string]*Addon{ "logviewer": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "logviewer-dp-and-svc.yaml", "0640", false), MustBinAsset( "deploy/addons/logviewer/logviewer-rbac.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "logviewer-rbac.yaml", "0640", false), @@ -310,13 +312,13 @@ var Addons = map[string]*Addon{ "gvisor": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gvisor/gvisor-pod.yaml.tmpl", - constants.GuestAddonsDir, + guestAddonsDir, "gvisor-pod.yaml", "0640", true), MustBinAsset( "deploy/addons/gvisor/gvisor-runtimeclass.yaml", - constants.GuestAddonsDir, + guestAddonsDir, "gvisor-runtimeclass.yaml", "0640", false), @@ -352,7 +354,7 @@ var Addons = map[string]*Addon{ // AddMinikubeDirAssets adds all addons and files to the list // of files to be copied to the vm. func AddMinikubeDirAssets(assets *[]CopyableFile) error { - if err := addMinikubeDirToAssets(localpath.MakeMiniPath("addons"), constants.GuestAddonsDir, assets); err != nil { + if err := addMinikubeDirToAssets(localpath.MakeMiniPath("addons"), guestAddonsDir, assets); err != nil { return errors.Wrap(err, "adding addons folder to assets") } if err := addMinikubeDirToAssets(localpath.MakeMiniPath("files"), "", assets); err != nil { diff --git a/pkg/minikube/assets/addons_test.go b/pkg/minikube/assets/addons_test.go index 1446d81f018d..e546a5b210db 100644 --- a/pkg/minikube/assets/addons_test.go +++ b/pkg/minikube/assets/addons_test.go @@ -23,7 +23,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/localpath" ) @@ -57,18 +56,18 @@ func TestAddMinikubeDirAssets(t *testing.T) { }{ { relativePath: "/dir1/file1.txt", - expectedPath: constants.GuestAddonsDir, + expectedPath: guestAddonsDir, }, { relativePath: "/dir1/file2.txt", - expectedPath: constants.GuestAddonsDir, + expectedPath: guestAddonsDir, }, { relativePath: "/dir2/file1.txt", - expectedPath: constants.GuestAddonsDir, + expectedPath: guestAddonsDir, }, }, - vmPath: constants.GuestAddonsDir, + vmPath: guestAddonsDir, }, { description: "absolute path assets", diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index e1f8436db312..f70309382315 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -57,8 +57,11 @@ import ( // enum to differentiate kubeadm command line parameters from kubeadm config file parameters (see the // KubeadmExtraArgsWhitelist variable below for more info) const ( - KubeadmCmdParam = iota - KubeadmConfigParam = iota + KubeadmCmdParam = iota + KubeadmConfigParam = iota + defaultCNIConfigPath = "/etc/cni/net.d/k8s.conf" + kubeletServiceFile = "/lib/systemd/system/kubelet.service" + kubeletSystemdConfFile = "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf" ) // KubeadmExtraArgsWhitelist is a whitelist of supported kubeadm params that can be supplied to kubeadm through @@ -745,14 +748,14 @@ func NewKubeletService(cfg config.KubernetesConfig) ([]byte, error) { func configFiles(cfg config.KubernetesConfig, kubeadm []byte, kubelet []byte, kubeletSvc []byte) []assets.CopyableFile { fs := []assets.CopyableFile{ assets.NewMemoryAssetTarget(kubeadm, yamlConfigPath, "0640"), - assets.NewMemoryAssetTarget(kubelet, constants.KubeletSystemdConfFile, "0640"), - assets.NewMemoryAssetTarget(kubeletSvc, constants.KubeletServiceFile, "0640"), + assets.NewMemoryAssetTarget(kubelet, kubeletSystemdConfFile, "0640"), + assets.NewMemoryAssetTarget(kubeletSvc, kubeletServiceFile, "0640"), } // Copy the default CNI config (k8s.conf), so that kubelet can successfully // start a Pod in the case a user hasn't manually installed any CNI plugin // and minikube was started with "--extra-config=kubelet.network-plugin=cni". if cfg.EnableDefaultCNI { - fs = append(fs, assets.NewMemoryAssetTarget([]byte(defaultCNIConfig), constants.DefaultCNIConfigPath, "0644")) + fs = append(fs, assets.NewMemoryAssetTarget([]byte(defaultCNIConfig), defaultCNIConfigPath, "0644")) } return fs } diff --git a/pkg/minikube/bootstrapper/kubeadm/templates.go b/pkg/minikube/bootstrapper/kubeadm/templates.go index dd1bfe65906e..9c3887f0dd78 100644 --- a/pkg/minikube/bootstrapper/kubeadm/templates.go +++ b/pkg/minikube/bootstrapper/kubeadm/templates.go @@ -151,7 +151,7 @@ evictionHard: imagefs.available: "0%" `)) -// kubeletSystemdTemplate hosts the override kubelet flags, written to constants.KubeletSystemdConfFile +// kubeletSystemdTemplate hosts the override kubelet flags, written to kubeletSystemdConfFile var kubeletSystemdTemplate = template.Must(template.New("kubeletSystemdTemplate").Parse(`[Unit] {{if or (eq .ContainerRuntime "cri-o") (eq .ContainerRuntime "cri")}}Wants=crio.service{{else if eq .ContainerRuntime "containerd"}}Wants=containerd.service{{else}}Wants=docker.socket{{end}} @@ -162,7 +162,7 @@ ExecStart={{.KubeletPath}}{{if .ExtraOptions}} {{.ExtraOptions}}{{end}} [Install] `)) -// kubeletServiceTemplate is the base kubelet systemd template, written to constanst.KubeletServiceFile +// kubeletServiceTemplate is the base kubelet systemd template, written to kubeletServiceFile var kubeletServiceTemplate = template.Must(template.New("kubeletServiceTemplate").Parse(`[Unit] Description=kubelet: The Kubernetes Node Agent Documentation=http://kubernetes.io/docs/ diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index a952e4d8eca4..71737c68ee3d 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -19,7 +19,6 @@ package constants import ( "fmt" "path/filepath" - "time" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/homedir" @@ -72,70 +71,24 @@ var KubeconfigPath = clientcmd.RecommendedHomeFile // KubeconfigEnvVar is the env var to check for the Kubernetes client config var KubeconfigEnvVar = clientcmd.RecommendedConfigPathEnvVar -// MinikubeContext is the kubeconfig context name used for minikube -const MinikubeContext = "minikube" - -// MinikubeEnvPrefix is the prefix for the environmental variables -const MinikubeEnvPrefix = "MINIKUBE" - // DefaultMachineName is the default name for the VM const DefaultMachineName = "minikube" // DefaultNodeName is the default name for the kubeadm node within the VM const DefaultNodeName = "minikube" -// DefaultStorageClassProvisioner is the name of the default storage class provisioner -const DefaultStorageClassProvisioner = "standard" - -// Cache is used to modify the cache field in the config file -const Cache = "cache" - // MountProcessFileName is the filename of the mount process var MountProcessFileName = ".mount-process" const ( - // DefaultEmbedCerts is if the certs should be embedded in the kubeconfig file - DefaultEmbedCerts = false - // DefaultKeepContext is if we should keep context by default - DefaultKeepContext = false // SHASuffix is the suffix of a SHA-256 checksum file SHASuffix = ".sha256" - // DefaultMemorySize is the default memory which will be allocated to minikube, in megabytes - DefaultMemorySize = "2000mb" - // MinimumMemorySize is the minimum memory size, in megabytes - MinimumMemorySize = "1024mb" - // DefaultCPUS is the default number of cpus of a host - DefaultCPUS = 2 - // MinimumCPUS is the minimum number of cpus of a host - MinimumCPUS = 2 - // DefaultDiskSize is the default disk image size, in megabytes - DefaultDiskSize = "20000mb" - // MinimumDiskSize is the minimum disk image size, in megabytes - MinimumDiskSize = "2000mb" - // DefaultVMDriver is the default virtual machine driver name - DefaultVMDriver = DriverVirtualbox - // DefaultStatusFormat is the default format of a host - DefaultStatusFormat = `host: {{.Host}} -kubelet: {{.Kubelet}} -apiserver: {{.APIServer}} -kubectl: {{.Kubeconfig}} -` - // DefaultAddonListFormat is the default format of addon list - DefaultAddonListFormat = "- {{.AddonName}}: {{.AddonStatus}}\n" - // DefaultConfigViewFormat is the default format of config view - DefaultConfigViewFormat = "- {{.ConfigKey}}: {{.ConfigValue}}\n" - // DefaultCacheListFormat is the default format of cache list - DefaultCacheListFormat = "{{.CacheImage}}\n" // GithubMinikubeReleasesURL is the URL of the minikube github releases JSON file GithubMinikubeReleasesURL = "https://storage.googleapis.com/minikube/releases.json" // DefaultWait is the default wait time, in seconds DefaultWait = 20 // DefaultInterval is the default interval, in seconds DefaultInterval = 6 - // DefaultK8sClientTimeout is the default kubernetes client timeout - DefaultK8sClientTimeout = 60 * time.Second - // DefaultClusterBootstrapper is the default cluster bootstrapper - DefaultClusterBootstrapper = "kubeadm" ) // DefaultISOURL is the default location of the minikube.iso file @@ -157,15 +110,6 @@ var OldestKubernetesVersion = "v1.11.10" var ConfigFile = localpath.MakeMiniPath("config", "config.json") const ( - // KubeletServiceFile is the path to the kubelet systemd service - KubeletServiceFile = "/lib/systemd/system/kubelet.service" - // KubeletSystemdConfFile is the path to the kubelet systemd configuration - KubeletSystemdConfFile = "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf" - // DefaultCNIConfigPath is the path to the CNI configuration - DefaultCNIConfigPath = "/etc/cni/net.d/k8s.conf" - - // GuestAddonsDir is the default path of the addons configuration - GuestAddonsDir = "/etc/kubernetes/addons" // GuestManifestsDir is where the kubelet should look for static Pod manifests GuestManifestsDir = "/etc/kubernetes/manifests" // GuestEphemeralDir is the path where ephemeral data should be stored within the VM @@ -174,21 +118,9 @@ const ( GuestPersistentDir = "/var/lib/minikube" // GuestCertsDir are where Kubernetes certificates are kept on the guest GuestCertsDir = GuestPersistentDir + "/certs" - // DefaultUfsPort is the default port of UFS - DefaultUfsPort = "5640" - // DefaultUfsDebugLvl is the default debug level of UFS - DefaultUfsDebugLvl = 0 - // DefaultMountEndpoint is the default mount endpoint - DefaultMountEndpoint = "/minikube-host" - // DefaultMsize is the default number of bytes to use for 9p packet payload - DefaultMsize = 262144 - // DefaultMountVersion is the default 9p version to use for mount - DefaultMountVersion = "9p2000.L" // IsMinikubeChildProcess is the name of "is minikube child process" variable IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS" - // FileScheme is the file scheme - FileScheme = "file" ) // ImageRepositories contains all known image repositories @@ -206,16 +138,7 @@ var ImageCacheDir = localpath.MakeMiniPath("cache", "images") const ( // GvisorFilesPath is the path to the gvisor files saved by go-bindata GvisorFilesPath = "/tmp/gvisor" - // ContainerdConfigTomlPath is the path to the containerd config.toml - ContainerdConfigTomlPath = "/etc/containerd/config.toml" - // StoredContainerdConfigTomlPath is the path where the default config.toml will be stored - StoredContainerdConfigTomlPath = "/tmp/config.toml" // GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml GvisorConfigTomlTargetName = "gvisor-config.toml" - - // GvisorContainerdShimURL is the url to download gvisor-containerd-shim - GvisorContainerdShimURL = "https://github.com/google/gvisor-containerd-shim/releases/download/v0.0.3/containerd-shim-runsc-v1.linux-amd64" - // GvisorURL is the url to download gvisor - GvisorURL = "https://storage.googleapis.com/gvisor/releases/nightly/2019-01-14/runsc" ) diff --git a/pkg/minikube/service/service.go b/pkg/minikube/service/service.go index 1dd8785c4548..1315779f3012 100644 --- a/pkg/minikube/service/service.go +++ b/pkg/minikube/service/service.go @@ -41,12 +41,13 @@ import ( clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/proxy" "k8s.io/minikube/pkg/util/retry" ) +const defaultK8sClientTimeout = 60 * time.Second + // K8sClient represents a kubernetes client type K8sClient interface { GetCoreClient() (typed_core.CoreV1Interface, error) @@ -65,7 +66,7 @@ func init() { // GetCoreClient returns a core client func (k *K8sClientGetter) GetCoreClient() (typed_core.CoreV1Interface, error) { - client, err := k.GetClientset(constants.DefaultK8sClientTimeout) + client, err := k.GetClientset(defaultK8sClientTimeout) if err != nil { return nil, errors.Wrap(err, "getting clientset") } diff --git a/site/content/en/docs/Contributing/addons.en.md b/site/content/en/docs/Contributing/addons.en.md index d0bd11398655..5c8c1a45b6b7 100644 --- a/site/content/en/docs/Contributing/addons.en.md +++ b/site/content/en/docs/Contributing/addons.en.md @@ -43,19 +43,19 @@ To add a new addon to minikube the following steps are required: "efk": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/efk/efk-configmap.yaml", - constants.GuestAddonsDir, + guestAddonsDir, "efk-configmap.yaml", "0640", false), MustBinAsset( "deploy/addons/efk/efk-rc.yaml", - constants.GuestAddonsDir, + guestAddonsDir, "efk-rc.yaml", "0640", false), MustBinAsset( "deploy/addons/efk/efk-svc.yaml", - constants.GuestAddonsDir, + guestAddonsDir, "efk-svc.yaml", "0640", false),