Skip to content

Commit

Permalink
Support enabling alpha features with feature gates
Browse files Browse the repository at this point in the history
This sets the feature gates on every kube-system component (apiserver,
kubelet, etc.)

Fixes kubernetes#896
  • Loading branch information
r2d4 committed Jan 9, 2017
1 parent 7950a72 commit 2334e6d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/localkube/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func AddFlags(s *localkube.LocalkubeServer) {
flag.IPVar(&s.NodeIP, "node-ip", s.NodeIP, "IP address of the node. If set, kubelet will use this IP address for the node.")
flag.StringVar(&s.ContainerRuntime, "container-runtime", "", "The container runtime to be used")
flag.StringVar(&s.NetworkPlugin, "network-plugin", "", "The name of the network plugin")
flag.StringVar(&s.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
flag.Var(&s.ExtraConfig, "extra-config", "A set of key=value pairs that describe configuration that may be passed to different components. The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.")

// These two come from vendor/ packages that use flags. We should hide them
Expand Down
10 changes: 10 additions & 0 deletions cmd/localkube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/coreos/pkg/capnslog"
"k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util/config"
"k8s.io/minikube/pkg/localkube"
"k8s.io/minikube/pkg/version"
)
Expand Down Expand Up @@ -65,6 +66,15 @@ func SetupServer(s *localkube.LocalkubeServer) {
}
}

//Set feature gates
fmt.Println("Feature gates:", s.FeatureGates)
if s.FeatureGates != "" {
err := config.DefaultFeatureGate.Set(s.FeatureGates)
if err != nil {
fmt.Printf("Error setting feature gates: %s")
}
}

// Setup capabilities. This can only be done once per binary.
allSources, _ := types.GetValidatedSources([]string{types.AllSource})
c := capabilities.Capabilities{
Expand Down
3 changes: 3 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
hypervVirtualSwitch = "hyperv-virtual-switch"
kvmNetwork = "kvm-network"
keepContext = "keep-context"
featureGates = "feature-gates"
)

var (
Expand Down Expand Up @@ -110,6 +111,7 @@ func runStart(cmd *cobra.Command, args []string) {
kubernetesConfig := cluster.KubernetesConfig{
KubernetesVersion: viper.GetString(kubernetesVersion),
NodeIP: ip,
FeatureGates: viper.GetString(featureGates),
ContainerRuntime: viper.GetString(containerRuntime),
NetworkPlugin: viper.GetString(networkPlugin),
ExtraOptions: extraOptions,
Expand Down Expand Up @@ -231,6 +233,7 @@ func init() {
startCmd.Flags().String(kubernetesVersion, constants.DefaultKubernetesVersion, "The kubernetes version that the minikube VM will use (ex: v1.2.3) \n OR a URI which contains a localkube binary (ex: https://storage.googleapis.com/minikube/k8sReleases/v1.3.0/localkube-linux-amd64)")
startCmd.Flags().String(containerRuntime, "", "The container runtime to be used")
startCmd.Flags().String(networkPlugin, "", "The name of the network plugin")
startCmd.Flags().String(featureGates, "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
startCmd.Flags().Var(&extraOptions, "extra-config",
`A set of key=value pairs that describe configuration that may be passed to different components.
The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
Expand Down
2 changes: 2 additions & 0 deletions docs/bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ _minikube_start()
local_nonpersistent_flags+=("--docker-env=")
flags+=("--extra-config=")
local_nonpersistent_flags+=("--extra-config=")
flags+=("--feature-gates=")
local_nonpersistent_flags+=("--feature-gates=")
flags+=("--host-only-cidr=")
local_nonpersistent_flags+=("--host-only-cidr=")
flags+=("--hyperv-virtual-switch=")
Expand Down
1 change: 1 addition & 0 deletions docs/minikube_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ minikube start
--extra-config ExtraOption A set of key=value pairs that describe configuration that may be passed to different components.
The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
Valid components are: kubelet, apiserver, controller-manager, etcd, proxy, scheduler.
--feature-gates string A set of key=value pairs that describe feature gates for alpha/experimental features.
--host-only-cidr string The CIDR to be used for the minikube VM (only supported with Virtualbox driver) (default "192.168.99.1/24")
--hyperv-virtual-switch string The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)
--insecure-registry stringSlice Insecure Docker registries to pass to the Docker daemon
Expand Down
1 change: 1 addition & 0 deletions pkg/localkube/localkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type LocalkubeServer struct {
NodeIP net.IP
ContainerRuntime string
NetworkPlugin string
FeatureGates string
ExtraConfig util.ExtraOptionSlice
}

Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ type KubernetesConfig struct {
NodeIP string
ContainerRuntime string
NetworkPlugin string
FeatureGates string
ExtraOptions util.ExtraOptionSlice
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/minikube/cluster/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func GenLocalkubeStartCmd(kubernetesConfig KubernetesConfig) (string, error) {
flagVals = append(flagVals, "--network-plugin="+kubernetesConfig.NetworkPlugin)
}

if kubernetesConfig.FeatureGates != "" {
flagVals = append(flagVals, "--feature-gates="+kubernetesConfig.FeatureGates)
}

for _, e := range kubernetesConfig.ExtraOptions {
flagVals = append(flagVals, fmt.Sprintf("--extra-config=%s", e.String()))
}
Expand Down

0 comments on commit 2334e6d

Please sign in to comment.