Turn addon manager off by default
Add run kubectl apply command directly if addons are changed by the user if the addon manager is disabled.pull/6046/head
parent
87af761c50
commit
7477050192
|
|
@ -23,6 +23,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/addons"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/cluster"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
|
|
@ -172,6 +173,11 @@ func isAddonAlreadySet(addon *assets.Addon, enable bool) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
func isAddonManagerEnabled() (bool, error) {
|
||||
addonManager := assets.Addons["addon-manager"]
|
||||
return addonManager.IsEnabled()
|
||||
}
|
||||
|
||||
func enableOrDisableAddonInternal(addon *assets.Addon, cmd command.Runner, data interface{}, enable bool) error {
|
||||
var err error
|
||||
|
||||
|
|
@ -208,7 +214,17 @@ func enableOrDisableAddonInternal(addon *assets.Addon, cmd command.Runner, data
|
|||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
// If addon manager is enabled, return as it will handle this.
|
||||
// If not, reconcile addons ourselves.
|
||||
|
||||
enabled, err := isAddonManagerEnabled()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "checking if addon manager is enabled")
|
||||
}
|
||||
if enabled {
|
||||
return nil
|
||||
}
|
||||
return addons.ReconcileAddons(cmd)
|
||||
}
|
||||
|
||||
// EnableOrDisableStorageClasses enables or disables storage classes
|
||||
|
|
|
|||
3
go.mod
3
go.mod
|
|
@ -21,14 +21,11 @@ require (
|
|||
github.com/docker/machine v0.7.1-0.20190718054102-a555e4f7a8f5 // version is 0.7.1 to pin to a555e4f7a8f5
|
||||
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f
|
||||
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
|
||||
github.com/ghodss/yaml v1.0.0 // indirect
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/google/btree v1.0.0 // indirect
|
||||
github.com/google/go-cmp v0.3.0
|
||||
github.com/gorilla/mux v1.7.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.5.0 // indirect
|
||||
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect
|
||||
github.com/hashicorp/go-getter v1.4.0
|
||||
github.com/hashicorp/go-multierror v0.0.0-20160811015721-8c5f0ad93604 // indirect
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package addons
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
)
|
||||
|
||||
var kubectlPruneWhitelist = []string{
|
||||
"core/v1/ConfigMap",
|
||||
"core/v1/Endpoints",
|
||||
"core/v1/Namespace",
|
||||
"core/v1/PersistentVolumeClaim",
|
||||
"core/v1/PersistentVolume",
|
||||
"core/v1/Pod",
|
||||
"core/v1/ReplicationController",
|
||||
"core/v1/Secret",
|
||||
"core/v1/Service",
|
||||
"batch/v1/Job",
|
||||
"batch/v1beta1/CronJob",
|
||||
"apps/v1/DaemonSet",
|
||||
"apps/v1/Deployment",
|
||||
"apps/v1/ReplicaSet",
|
||||
"apps/v1/StatefulSet",
|
||||
"extensions/v1beta1/Ingress",
|
||||
}
|
||||
|
||||
// ReconcileAddons runs kubectl apply -f on the addons directory
|
||||
// to reconcile addons state
|
||||
func ReconcileAddons(cmd command.Runner) error {
|
||||
if _, err := cmd.RunCmd(kubectlCommand()); err != nil {
|
||||
glog.Warningf("reconciling addons failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func kubectlCommand() *exec.Cmd {
|
||||
args := []string{"apply", "-f", "/etc/kubernetes/addons", "-l", "kubernetes.io/cluster-service!=true,addonmanager.kubernetes.io/mode=Reconcile", "--prune=true"}
|
||||
for _, k := range kubectlPruneWhitelist {
|
||||
args = append(args, []string{"--prune-whitelist", k}...)
|
||||
}
|
||||
args = append(args, "--recursive")
|
||||
cmd := exec.Command("kubectl", args...)
|
||||
return cmd
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ var Addons = map[string]*Addon{
|
|||
vmpath.GuestManifestsDir,
|
||||
"addon-manager.yaml.tmpl",
|
||||
"0640",
|
||||
true),
|
||||
false),
|
||||
}, true, "addon-manager"),
|
||||
"dashboard": NewAddon([]*BinAsset{
|
||||
MustBinAsset("deploy/addons/dashboard/dashboard-clusterrole.yaml", vmpath.GuestAddonsDir, "dashboard-clusterrole.yaml", "0640", false),
|
||||
|
|
|
|||
Loading…
Reference in New Issue