Skip to content
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

Add addon enablement to start #6440

Merged
merged 11 commits into from
Feb 1, 2020
12 changes: 6 additions & 6 deletions cmd/minikube/cmd/config/addons_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ var printAddonsList = func() {

for _, addonName := range addonNames {
addonBundle := assets.Addons[addonName]
addonStatus, err := addonBundle.IsEnabled()
addonStatus, err := addonBundle.IsEnabled(pName)
if err != nil {
exit.WithError("Error getting addons status", err)
out.WarningT("Unable to get addon status for {{.name}}: {{.error}}", out.V{"name": addonName, "error": err})
}
tData = append(tData, []string{addonName, pName, fmt.Sprintf("%s %s", stringFromStatus(addonStatus), iconFromStatus(addonStatus))})
}
Expand All @@ -114,12 +114,11 @@ var printAddonsList = func() {

v, _, err := config.ListProfiles()
if err != nil {
glog.Infof("error getting list of porfiles: %v", err)
glog.Errorf("list profiles returned error: %v", err)
}
if len(v) > 1 {
out.T(out.Tip, "To see addons list for other profiles use: `minikube addons -p name list`")
}

}

var printAddonsJSON = func() {
Expand All @@ -135,9 +134,10 @@ var printAddonsJSON = func() {
for _, addonName := range addonNames {
addonBundle := assets.Addons[addonName]

addonStatus, err := addonBundle.IsEnabled()
addonStatus, err := addonBundle.IsEnabled(pName)
if err != nil {
exit.WithError("Error getting addons status", err)
glog.Errorf("Unable to get addon status for %s: %v", addonName, err)
continue
}

addonsMap[addonName] = map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/config/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var addonsDisableCmd = &cobra.Command{
if err != nil {
exit.WithError("disable failed", err)
}
out.SuccessT(`"{{.minikube_addon}}" was successfully disabled`, out.V{"minikube_addon": addon})
out.T(out.AddonDisable, `"The '{{.minikube_addon}}' addon is disabled`, out.V{"minikube_addon": addon})
},
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/minikube/cmd/config/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ var addonsEnableCmd = &cobra.Command{
if len(args) != 1 {
exit.UsageT("usage: minikube addons enable ADDON_NAME")
}

addon := args[0]
err := addons.Set(addon, "true", viper.GetString(config.MachineProfile))
if err != nil {
exit.WithError("enable failed", err)
}
out.SuccessT("{{.addonName}} was successfully enabled", out.V{"addonName": addon})
out.T(out.AddonEnable, "The '{{.addonName}}' addon is enabled", out.V{"addonName": addon})
},
}

Expand Down
7 changes: 5 additions & 2 deletions cmd/minikube/cmd/config/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import (
"github.com/pkg/browser"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/cluster"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/out"
Expand Down Expand Up @@ -66,7 +68,8 @@ var addonsOpenCmd = &cobra.Command{
}
defer api.Close()

if !cluster.IsMinikubeRunning(api) {
profileName := viper.GetString(pkg_config.MachineProfile)
if !cluster.IsHostRunning(api, profileName) {
os.Exit(1)
}
addon, ok := assets.Addons[addonName] // validate addon input
Expand All @@ -75,7 +78,7 @@ var addonsOpenCmd = &cobra.Command{
To see the list of available addons run:
minikube addons list`, out.V{"name": addonName})
}
ok, err = addon.IsEnabled()
ok, err = addon.IsEnabled(profileName)
if err != nil {
exit.WithError("IsEnabled failed", err)
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/minikube/cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
pkgaddons "k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
Expand Down Expand Up @@ -103,18 +102,18 @@ var dashboardCmd = &cobra.Command{
exit.WithCodeT(exit.NoInput, "kubectl not found in PATH, but is required for the dashboard. Installation guide: https://kubernetes.io/docs/tasks/tools/install-kubectl/")
}

if !cluster.IsMinikubeRunning(api) {
if !cluster.IsHostRunning(api, profileName) {
os.Exit(1)
}

// Check dashboard status before enabling it
dashboardAddon := assets.Addons["dashboard"]
dashboardStatus, _ := dashboardAddon.IsEnabled()
dashboardStatus, _ := dashboardAddon.IsEnabled(profileName)
if !dashboardStatus {
// Send status messages to stderr for folks re-using this output.
out.ErrT(out.Enabling, "Enabling dashboard ...")
// Enable the dashboard add-on
err = pkgaddons.Set("dashboard", "true", viper.GetString(config.MachineProfile))
err = pkgaddons.Set("dashboard", "true", profileName)
if err != nil {
exit.WithError("Unable to enable dashboard", err)
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/minikube/cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (
"github.com/golang/glog"
"github.com/pkg/browser"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"k8s.io/minikube/pkg/minikube/cluster"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/out"
Expand Down Expand Up @@ -71,7 +73,8 @@ var serviceCmd = &cobra.Command{
}
defer api.Close()

if !cluster.IsMinikubeRunning(api) {
profileName := viper.GetString(pkg_config.MachineProfile)
if !cluster.IsHostRunning(api, profileName) {
os.Exit(1)
}

Expand Down
18 changes: 4 additions & 14 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"github.com/spf13/viper"
"golang.org/x/sync/errgroup"
cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config"
pkgaddons "k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
Expand Down Expand Up @@ -104,7 +104,6 @@ const (
imageMirrorCountry = "image-mirror-country"
mountString = "mount-string"
disableDriverMounts = "disable-driver-mounts"
addons = "addons"
cacheImages = "cache-images"
uuid = "uuid"
vpnkitSock = "hyperkit-vpnkit-sock"
Expand Down Expand Up @@ -172,7 +171,7 @@ func initMinikubeFlags() {
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+":/minikube-host", "The argument to pass the minikube mount command on start.")
startCmd.Flags().StringArrayVar(&addonList, addons, nil, "Enable addons. see `minikube addons list` for a list of valid addon names.")
startCmd.Flags().StringArrayVar(&addonList, "addons", nil, "Enable addons. see `minikube addons list` for a list of valid addon names.")
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\".")
Expand Down Expand Up @@ -368,8 +367,8 @@ func runStart(cmd *cobra.Command, args []string) {
bootstrapCluster(bs, cr, mRunner, mc, preExists, isUpgrade)
configureMounts()

// enable addons with start command
enableAddons()
// enable addons
addons.Start(viper.GetString(config.MachineProfile), addonList)

if err = cacheAndLoadImagesInConfig(); err != nil {
out.T(out.FailureType, "Unable to load cached images from config file.")
Expand Down Expand Up @@ -408,15 +407,6 @@ func cacheISO(cfg *config.MachineConfig, driverName string) {
}
}

func enableAddons() {
for _, a := range addonList {
err := pkgaddons.Set(a, "true", viper.GetString(config.MachineProfile))
if err != nil {
exit.WithError("addon enable failed", err)
}
}
}

func displayVersion(version string) {
prefix := ""
if viper.GetString(config.MachineProfile) != constants.DefaultMachineName {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ require (
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456
golang.org/x/text v0.3.2
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gotest.tools v2.2.0+incompatible
k8s.io/api v0.17.2
k8s.io/apimachinery v0.17.2
k8s.io/client-go v11.0.0+incompatible
Expand Down
Loading