Merge pull request #5543 from govargo/feature/start-with-addons-flag

Add ability to enable addon through  'minikube start' flag
pull/5586/head
Medya Ghazizadeh 2019-10-09 20:05:33 -07:00 committed by GitHub
commit d139781470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 13 deletions

View File

@ -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"
@ -124,6 +125,7 @@ var (
dockerOpt []string
insecureRegistry []string
apiServerNames []string
addonList []string
apiServerIPs []net.IP
extraOptions cfg.ExtraOptionSlice
enableUpdateNotification = true
@ -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\".")
@ -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.")
}

View File

@ -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)

View File

@ -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

View File

@ -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:

View File

@ -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)
@ -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)
@ -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)
}
@ -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)
@ -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)
}