Skip to content

Commit

Permalink
Merge pull request #5543 from govargo/feature/start-with-addons-flag
Browse files Browse the repository at this point in the history
Add ability to enable addon through  'minikube start' flag
  • Loading branch information
medyagh committed Oct 10, 2019
2 parents 4916c04 + f111f09 commit d139781
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
12 changes: 12 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const (
imageMirrorCountry = "image-mirror-country"
mountString = "mount-string"
disableDriverMounts = "disable-driver-mounts"
addons = "addons"
cacheImages = "cache-images"
uuid = "uuid"
vpnkitSock = "hyperkit-vpnkit-sock"
Expand All @@ -124,6 +125,7 @@ var (
dockerOpt []string
insecureRegistry []string
apiServerNames []string
addonList []string
apiServerIPs []net.IP
extraOptions cfg.ExtraOptionSlice
enableUpdateNotification = true
Expand Down Expand Up @@ -162,6 +164,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().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 @@ -342,6 +345,15 @@ func runStart(cmd *cobra.Command, args []string) {
// pull images or restart cluster
bootstrapCluster(bs, cr, mRunner, config.KubernetesConfig, preExists, isUpgrade)
configureMounts()

// enable addons with start command
for _, a := range addonList {
err = cmdcfg.Set(a, "true")
if err != nil {
exit.WithError("addon enable failed", err)
}
}

if err = loadCachedImagesInConfigFile(); err != nil {
out.T(out.FailureType, "Unable to load cached images from config file.")
}
Expand Down
6 changes: 6 additions & 0 deletions site/content/en/docs/Reference/Commands/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ Enables the addon w/ADDON_NAME within minikube (example: minikube addons enable
minikube addons enable ADDON_NAME [flags]
```

or

```
minikube start --addons ADDON_NAME [flags]
```

## minikube addons list

Lists all available minikube addons as well as their current statuses (enabled/disabled)
Expand Down
1 change: 1 addition & 0 deletions site/content/en/docs/Reference/Commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ minikube start [flags]
### Options

```
--addons Enable addons. see `minikube addons list` for a list of valid addon names.
--apiserver-ips ipSlice A set of apiserver IP Addresses which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default [])
--apiserver-name string The apiserver name which is used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default "minikubeCA")
--apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine
Expand Down
6 changes: 6 additions & 0 deletions site/content/en/docs/Tasks/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ Example output:
minikube addons enable <name>
```

or

```shell
minikube start --addons <name>
```

## Interacting with an addon

For addons that expose a browser endpoint, use:
Expand Down
16 changes: 3 additions & 13 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestAddons(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute)
defer CleanupWithLogs(t, profile, cancel)

args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "-v=1"}, StartArgs()...)
args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "-v=1", "--addons=ingress", "--addons=registry"}, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Args, err)
Expand Down Expand Up @@ -72,11 +72,6 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
t.Skipf("skipping: ssh unsupported by none")
}

rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "ingress"))
if err != nil {
t.Fatalf("%s failed: %v", rr.Args, err)
}

client, err := kapi.Client(profile)
if err != nil {
t.Fatalf("kubernetes client: %v", client)
Expand All @@ -89,7 +84,7 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
t.Fatalf("wait: %v", err)
}

rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ing.yaml")))
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ing.yaml")))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
Expand Down Expand Up @@ -131,11 +126,6 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
}

func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "registry"))
if err != nil {
t.Fatalf("%s failed: %v", rr.Args, err)
}

client, err := kapi.Client(profile)
if err != nil {
t.Fatalf("kubernetes client: %v", client)
Expand All @@ -155,7 +145,7 @@ func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) {
}

// Test from inside the cluster (no curl available on busybox)
rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "delete", "po", "-l", "run=registry-test", "--now"))
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "delete", "po", "-l", "run=registry-test", "--now"))
if err != nil {
t.Logf("pre-cleanup %s failed: %v (not a problem)", rr.Args, err)
}
Expand Down

0 comments on commit d139781

Please sign in to comment.