Skip to content

Commit

Permalink
Merge to master
Browse files Browse the repository at this point in the history
  • Loading branch information
tstromberg committed Sep 2, 2020
2 parents 51d1f20 + 2dac55a commit 72e786f
Show file tree
Hide file tree
Showing 81 changed files with 510 additions and 374 deletions.
4 changes: 3 additions & 1 deletion cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
},
}
cc.VerifyComponents = interpretWaitFlag(*cmd)

if viper.GetBool(createMount) && driver.IsKIC(drvName) {
cc.ContainerVolumeMounts = []string{viper.GetString(mountString)}
}
cnm, err := cni.New(cc)
if err != nil {
return cc, config.Node{}, errors.Wrap(err, "cni")
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/dashboard/dashboard-dp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ spec:
containers:
- name: kubernetes-dashboard
# WARNING: This must match pkg/minikube/bootstrapper/images/images.go
image: kubernetesui/dashboard:v2.0.1
image: kubernetesui/dashboard:v2.0.3
ports:
- containerPort: 9090
protocol: TCP
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/ingress/ingress-dp.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
serviceAccountName: ingress-nginx
containers:
- name: controller
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.33.0
image: us.gcr.io/k8s-artifacts-prod/ingress-nginx/controller:v0.34.1@sha256:0e072dddd1f7f8fc8909a2ca6f65e76c5f0d2fcfb8be47935ae3457e8bbceb20
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
Expand Down
1 change: 0 additions & 1 deletion pkg/addons/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ func verifyAddonStatusInternal(cc *config.ClusterConfig, name string, val string

// Start enables the default addons for a profile, plus any additional
func Start(wg *sync.WaitGroup, cc *config.ClusterConfig, toEnable map[string]bool, additional []string) {
wg.Add(1)
defer wg.Done()

start := time.Now()
Expand Down
15 changes: 14 additions & 1 deletion pkg/addons/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/tests"
)

func createTestProfile(t *testing.T) string {
Expand All @@ -35,6 +36,13 @@ func createTestProfile(t *testing.T) string {
t.Fatalf("tempdir: %v", err)
}

t.Cleanup(func() {
err := os.RemoveAll(td)
t.Logf("remove path %q", td)
if err != nil {
t.Errorf("failed to clean up temp folder %q", td)
}
})
err = os.Setenv(localpath.MinikubeHome, td)
if err != nil {
t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome)
Expand Down Expand Up @@ -122,6 +130,10 @@ func TestSetAndSave(t *testing.T) {
}

func TestStart(t *testing.T) {
// this test will write a config.json into MinikubeHome, create a temp dir for it
tempDir := tests.MakeTempDir()
defer tests.RemoveTempDir(tempDir)

cc := &config.ClusterConfig{
Name: "start",
CPUs: 2,
Expand All @@ -130,7 +142,8 @@ func TestStart(t *testing.T) {
}

var wg sync.WaitGroup
Start(&wg, cc, map[string]bool{}, []string{"dashboard"})
wg.Add(1)
go Start(&wg, cc, map[string]bool{}, []string{"dashboard"})
wg.Wait()

if !assets.Addons["dashboard"].IsEnabled(cc) {
Expand Down
1 change: 1 addition & 0 deletions pkg/drivers/kic/kic.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func NewDriver(c Config) *Driver {
// Create a host using the driver's config
func (d *Driver) Create() error {
params := oci.CreateParams{
Mounts: d.NodeConfig.Mounts,
Name: d.NodeConfig.MachineName,
Image: d.NodeConfig.ImageDigest,
ClusterLabel: oci.ProfileLabelKey + "=" + d.MachineName,
Expand Down
30 changes: 29 additions & 1 deletion pkg/drivers/kic/oci/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,20 @@ func digDNS(ociBin, containerName, dns string) (net.IP, error) {
return ip, nil
}

// profileInContainers checks whether the profile is within the containers list
func profileInContainers(profile string, containers []string) bool {
for _, container := range containers {
if container == profile {
return true
}
}
return false
}

// dockerGatewayIP gets the default gateway ip for the docker bridge on the user's host machine
// gets the ip from user's host docker
func dockerGatewayIP(profile string) (net.IP, error) {
var bridgeID string
// check if using custom network first
if networkExists(profile) {
ip := net.ParseIP(DefaultGateway)
Expand All @@ -70,8 +81,25 @@ func dockerGatewayIP(profile string) (net.IP, error) {
if err != nil {
return nil, errors.Wrapf(err, "get network bridge")
}
networksOutput := strings.TrimSpace(rr.Stdout.String())
networksSlice := strings.Fields(networksOutput)
// Look for the minikube container within each docker network
for _, net := range networksSlice {
// get all containers in the network
rs, err := runCmd(exec.Command(Docker, "network", "inspect", net, "-f", "{{range $k, $v := .Containers}}{{$v.Name}} {{end}}"))
if err != nil {
return nil, errors.Wrapf(err, "get containers in network")
}
containersSlice := strings.Fields(rs.Stdout.String())
if profileInContainers(profile, containersSlice) {
bridgeID = net
break
}
}

bridgeID := strings.TrimSpace(rr.Stdout.String())
if bridgeID == "" {
return nil, errors.Errorf("unable to determine bridge network id from %q", networksOutput)
}
rr, err = runCmd(exec.Command(Docker, "network", "inspect",
"--format", "{{(index .IPAM.Config 0).Gateway}}", bridgeID))
if err != nil {
Expand Down
47 changes: 47 additions & 0 deletions pkg/drivers/kic/oci/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ limitations under the License.

package oci

import (
"errors"
"fmt"
"path/filepath"
"strings"
)

const (
// DefaultBindIPV4 is The default IP the container will listen on.
DefaultBindIPV4 = "127.0.0.1"
Expand Down Expand Up @@ -102,6 +109,46 @@ type Mount struct {
Propagation MountPropagation `protobuf:"varint,5,opt,name=propagation,proto3,enum=runtime.v1alpha2.MountPropagation" json:"propagation,omitempty"`
}

// ParseMountString parses a mount string of format:
// '[host-path:]container-path[:<options>]' The comma-delimited 'options' are
// [rw|ro], [Z], [srhared|rslave|rprivate].
func ParseMountString(spec string) (m Mount, err error) {
switch fields := strings.Split(spec, ":"); len(fields) {
case 0:
err = errors.New("invalid empty spec")
case 1:
m.ContainerPath = fields[0]
case 3:
for _, opt := range strings.Split(fields[2], ",") {
switch opt {
case "Z":
m.SelinuxRelabel = true
case "ro":
m.Readonly = true
case "rw":
m.Readonly = false
case "rslave":
m.Propagation = MountPropagationHostToContainer
case "rshared":
m.Propagation = MountPropagationBidirectional
case "private":
m.Propagation = MountPropagationNone
default:
err = fmt.Errorf("unknown mount option: '%s'", opt)
}
}
fallthrough
case 2:
m.HostPath, m.ContainerPath = fields[0], fields[1]
if !filepath.IsAbs(m.ContainerPath) {
err = fmt.Errorf("'%s' container path must be absolute", m.ContainerPath)
}
default:
err = errors.New("spec must be in form: <host path>:<container path>[:<options>]")
}
return m, err
}

// PortMapping specifies a host port mapped into a container port.
// In yaml this looks like:
// containerPort: 80
Expand Down
6 changes: 0 additions & 6 deletions pkg/minikube/bootstrapper/bsutil/ktmpl/v1beta1.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ etcd:
dataDir: {{.EtcdDataDir}}
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://{{.AdvertiseAddress}}:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: {{.KubernetesVersion}}
networking:
dnsDomain: {{if .DNSDomain}}{{.DNSDomain}}{{else}}cluster.local{{end}}
Expand Down
6 changes: 0 additions & 6 deletions pkg/minikube/bootstrapper/bsutil/ktmpl/v1beta2.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ etcd:
{{- range $i, $val := printMapInOrder .EtcdExtraArgs ": " }}
{{$val}}
{{- end}}
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: {{.KubernetesVersion}}
networking:
dnsDomain: {{if .DNSDomain}}{{.DNSDomain}}{{else}}cluster.local{{end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ apiServer:
certSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
extraArgs:
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
controllerManager:
extraArgs:
leader-elect: "false"
scheduler:
extraArgs:
leader-elect: "false"
certificatesDir: /var/lib/minikube/certs
clusterName: mk
controlPlaneEndpoint: control-plane.minikube.internal:12345
Expand All @@ -33,12 +39,6 @@ etcd:
dataDir: /var/lib/minikube/etcd
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://1.1.1.1:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: v1.14.0
networking:
dnsDomain: cluster.local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ apiServer:
certSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
extraArgs:
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
controllerManager:
extraArgs:
leader-elect: "false"
scheduler:
extraArgs:
leader-elect: "false"
certificatesDir: /var/lib/minikube/certs
clusterName: mk
controlPlaneEndpoint: control-plane.minikube.internal:8443
Expand All @@ -33,12 +39,6 @@ etcd:
dataDir: /var/lib/minikube/etcd
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://1.1.1.1:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: v1.14.0
networking:
dnsDomain: cluster.local
Expand Down
12 changes: 6 additions & 6 deletions pkg/minikube/bootstrapper/bsutil/testdata/v1.14/containerd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ apiServer:
certSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
extraArgs:
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
controllerManager:
extraArgs:
leader-elect: "false"
scheduler:
extraArgs:
leader-elect: "false"
certificatesDir: /var/lib/minikube/certs
clusterName: mk
controlPlaneEndpoint: control-plane.minikube.internal:8443
Expand All @@ -33,12 +39,6 @@ etcd:
dataDir: /var/lib/minikube/etcd
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://1.1.1.1:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: v1.14.0
networking:
dnsDomain: cluster.local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ controllerManager:
extraArgs:
feature-gates: "a=b"
kube-api-burst: "32"
leader-elect: "false"
scheduler:
extraArgs:
feature-gates: "a=b"
leader-elect: "false"
scheduler-name: "mini-scheduler"
certificatesDir: /var/lib/minikube/certs
clusterName: mk
Expand All @@ -43,12 +45,6 @@ etcd:
dataDir: /var/lib/minikube/etcd
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://1.1.1.1:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: v1.14.0
networking:
dnsDomain: cluster.local
Expand Down
12 changes: 6 additions & 6 deletions pkg/minikube/bootstrapper/bsutil/testdata/v1.14/crio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ apiServer:
certSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
extraArgs:
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
controllerManager:
extraArgs:
leader-elect: "false"
scheduler:
extraArgs:
leader-elect: "false"
certificatesDir: /var/lib/minikube/certs
clusterName: mk
controlPlaneEndpoint: control-plane.minikube.internal:8443
Expand All @@ -33,12 +39,6 @@ etcd:
dataDir: /var/lib/minikube/etcd
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://1.1.1.1:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: v1.14.0
networking:
dnsDomain: cluster.local
Expand Down
12 changes: 6 additions & 6 deletions pkg/minikube/bootstrapper/bsutil/testdata/v1.14/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ apiServer:
certSANs: ["127.0.0.1", "localhost", "1.1.1.1"]
extraArgs:
enable-admission-plugins: "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
controllerManager:
extraArgs:
leader-elect: "false"
scheduler:
extraArgs:
leader-elect: "false"
certificatesDir: /var/lib/minikube/certs
clusterName: mk
controlPlaneEndpoint: control-plane.minikube.internal:8443
Expand All @@ -33,12 +39,6 @@ etcd:
dataDir: /var/lib/minikube/etcd
extraArgs:
listen-metrics-urls: http://127.0.0.1:2381,http://1.1.1.1:2381
controllerManager:
extraArgs:
"leader-elect": "false"
scheduler:
extraArgs:
"leader-elect": "false"
kubernetesVersion: v1.14.0
networking:
dnsDomain: cluster.local
Expand Down
Loading

0 comments on commit 72e786f

Please sign in to comment.