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

Do not include the default CNI config by default #3441

Merged
merged 2 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
containerRuntime = "container-runtime"
criSocket = "cri-socket"
networkPlugin = "network-plugin"
enableDefaultCNI = "enable-default-cni"
hypervVirtualSwitch = "hyperv-virtual-switch"
kvmNetwork = "kvm-network"
keepContext = "keep-context"
Expand Down Expand Up @@ -238,6 +239,7 @@ func runStart(cmd *cobra.Command, args []string) {
ServiceCIDR: viper.GetString(serviceCIDR),
ExtraOptions: extraOptions,
ShouldLoadCachedImages: shouldCacheImages,
EnableDefaultCNI: viper.GetBool(enableDefaultCNI),
}

k8sBootstrapper, err := GetClusterBootstrapper(api, clusterBootstrapper)
Expand Down Expand Up @@ -481,6 +483,7 @@ func init() {
startCmd.Flags().String(criSocket, "", "The cri socket path to be used")
startCmd.Flags().String(kubernetesVersion, constants.DefaultKubernetesVersion, "The kubernetes version that the minikube VM will use (ex: v1.2.3)")
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\"")
startCmd.Flags().String(featureGates, "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
startCmd.Flags().Bool(cacheImages, false, "If true, cache docker images for the current bootstrapper and load them into the machine.")
startCmd.Flags().Var(&extraOptions, "extra-config",
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/gvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ When starting minikube, specify the following flags, along with any additional d
```shell
$ minikube start --container-runtime=containerd \
--docker-opt containerd=/var/run/containerd/containerd.sock \
--network-plugin=cni
--network-plugin=cni --enable-default-cni
```

### Enabling gVisor
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 5 additions & 0 deletions docs/alternative_runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ To use [rkt](https://github.com/coreos/rkt) as the container runtime run:
```shell
$ minikube start \
--network-plugin=cni \
--enable-default-cni \
--container-runtime=rkt
```

Expand All @@ -16,6 +17,7 @@ To use [CRI-O](https://github.com/kubernetes-incubator/cri-o) as the container r
```shell
$ minikube start \
--network-plugin=cni \
--enable-default-cni \
--container-runtime=cri-o
```

Expand All @@ -24,6 +26,7 @@ Or you can use the extended version:
```shell
$ minikube start \
--network-plugin=cni \
--enable-default-cni \
--cri-socket=/var/run/crio/crio.sock \
--extra-config=kubelet.container-runtime=remote \
--extra-config=kubelet.container-runtime-endpoint=unix:///var/run/crio/crio.sock \
Expand All @@ -37,6 +40,7 @@ To use [containerd](https://github.com/containerd/containerd) as the container r
```shell
$ minikube start \
--network-plugin=cni \
--enable-default-cni \
--container-runtime=containerd
```

Expand All @@ -45,6 +49,7 @@ Or you can use the extended version:
```shell
$ minikube start \
--network-plugin=cni \
--enable-default-cni \
--cri-socket=/run/containerd/containerd.sock \
--extra-config=kubelet.container-runtime=remote \
--extra-config=kubelet.container-runtime-endpoint=unix:///run/containerd/containerd.sock \
Expand Down
1 change: 1 addition & 0 deletions docs/contributors/minikube_iso.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The bootable ISO image will be available in `out/minikube.iso`.
$ ./out/minikube start \
--container-runtime=rkt \
--network-plugin=cni \
--enable-default-cni \
--iso-url=file://$GOPATH/src/k8s.io/minikube/out/minikube.iso
```

Expand Down
43 changes: 43 additions & 0 deletions pkg/minikube/bootstrapper/kubeadm/default_cni.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2018 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 kubeadm

// defaultCNIConfig is the CNI config which is provisioned when --enable-default-cni
// has been passed to `minikube start`.
//
// The config is being written to /etc/cni/net.d/k8s.conf and /etc/rkt/net.d/k8s.conf.
const defaultCNIConfig = `
{
"name": "rkt.kubernetes.io",
"type": "bridge",
"bridge": "mybridge",
"mtu": 1460,
"addIf": "true",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "10.1.0.0/16",
"gateway": "10.1.0.1",
"routes": [
{
"dst": "0.0.0.0/0"
}
]
}
}
`
9 changes: 9 additions & 0 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ func (k *KubeadmBootstrapper) UpdateCluster(cfg config.KubernetesConfig) error {
assets.NewMemoryAssetTarget([]byte(kubeadmCfg), constants.KubeadmConfigFile, "0640"),
}

// Copy the default CNI config (k8s.conf), so that kubelet can successfully
// start a Pod in the case a user hasn't manually installed any CNI plugin
// and minikube was started with "--extra-config=kubelet.network-plugin=cni".
if cfg.EnableDefaultCNI {
files = append(files,
assets.NewMemoryAssetTarget([]byte(defaultCNIConfig), constants.DefaultCNIConfigPath, "0644"),
assets.NewMemoryAssetTarget([]byte(defaultCNIConfig), constants.DefaultRktNetConfigPath, "0644"))
}

var g errgroup.Group
for _, bin := range []string{"kubelet", "kubeadm"} {
bin := bin
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ type KubernetesConfig struct {
ExtraOptions util.ExtraOptionSlice

ShouldLoadCachedImages bool
EnableDefaultCNI bool
}
8 changes: 5 additions & 3 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ const AddonsPath = "/etc/kubernetes/addons"
const FilesPath = "/files"

const (
KubeletServiceFile = "/lib/systemd/system/kubelet.service"
KubeletSystemdConfFile = "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf"
KubeadmConfigFile = "/var/lib/kubeadm.yaml"
KubeletServiceFile = "/lib/systemd/system/kubelet.service"
KubeletSystemdConfFile = "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf"
KubeadmConfigFile = "/var/lib/kubeadm.yaml"
DefaultCNIConfigPath = "/etc/cni/net.d/k8s.conf"
DefaultRktNetConfigPath = "/etc/rkt/net.d/k8s.conf"
)

var Preflights = []string{
Expand Down
2 changes: 1 addition & 1 deletion test/integration/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (m *MinikubeRunner) SSH(command string) (string, error) {
func (m *MinikubeRunner) Start() {
switch r := m.Runtime; r {
case constants.ContainerdRuntime:
containerdFlags := "--container-runtime=containerd --network-plugin=cni --docker-opt containerd=/var/run/containerd/containerd.sock"
containerdFlags := "--container-runtime=containerd --network-plugin=cni --enable-default-cni --docker-opt containerd=/var/run/containerd/containerd.sock"
m.RunCommand(fmt.Sprintf("start %s %s %s --alsologtostderr --v=5", m.StartArgs, m.Args, containerdFlags), true)
default:
m.RunCommand(fmt.Sprintf("start %s %s --alsologtostderr --v=5", m.StartArgs, m.Args), true)
Expand Down