Rebased on master

pull/6863/head
Priya Wadhwa 2020-02-20 16:20:54 -08:00
commit 86df9ffb2c
7 changed files with 117 additions and 17 deletions

View File

@ -20,13 +20,13 @@ RAW_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).${VERSION_BUILD}
VERSION ?= v$(RAW_VERSION)
KUBERNETES_VERSION ?= $(shell egrep "DefaultKubernetesVersion =" pkg/minikube/constants/constants.go | cut -d \" -f2)
KIC_VERSION ?= $(shell egrep "Version =" pkg/drivers/kic/types.go | cut -d \" -f2)
# Default to .0 for higher cache hit rates, as build increments typically don't require new ISO versions
ISO_VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).3
# Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta
DEB_VERSION ?= $(subst -,~,$(RAW_VERSION))
RPM_VERSION ?= $(DEB_VERSION)
KIC_VERSION ?= 0.0.5
# used by hack/jenkins/release_build_and_upload.sh and KVM_BUILD_IMAGE, see also BUILD_IMAGE below
GO_VERSION ?= 1.13.4
@ -508,9 +508,8 @@ storage-provisioner-image: out/storage-provisioner-$(GOARCH) ## Build storage-pr
.PHONY: kic-base-image
kic-base-image: ## builds the base image used for kic.
docker rmi -f $(REGISTRY)/kicbase:v$(KIC_VERSION)-snapshot || true
docker build -f ./hack/images/kicbase.Dockerfile -t $(REGISTRY)/kicbase:v$(KIC_VERSION)-snapshot --build-arg COMMIT_SHA=${VERSION}-$(COMMIT) --target base .
docker rmi -f $(REGISTRY)/kicbase:$(KIC_VERSION)-snapshot || true
docker build -f ./hack/images/kicbase.Dockerfile -t $(REGISTRY)/kicbase:$(KIC_VERSION)-snapshot --build-arg COMMIT_SHA=${VERSION}-$(COMMIT) --target base .
.PHONY: upload-preloaded-images-tar
upload-preloaded-images-tar: generate-preloaded-images-tar # Upload the preloaded images tar to the GCS bucket. Specify a specific kubernetes version to build via `KUBERNETES_VERSION=vx.y.z make upload-preloaded-images-tar`.

View File

@ -97,7 +97,9 @@ func runDelete(cmd *cobra.Command, args []string) {
profileFlag := viper.GetString(config.MachineProfile)
validProfiles, invalidProfiles, err := pkg_config.ListProfiles()
glog.Warningf("Couldn't find any profiles in minikube home %q: %v", localpath.MiniPath(), err)
if err != nil {
glog.Warningf("'error loading profiles in minikube home %q: %v", localpath.MiniPath(), err)
}
profilesToDelete := append(validProfiles, invalidProfiles...)
// in the case user has more than 1 profile and runs --purge
// to prevent abandoned VMs/containers, force user to run with delete --all

View File

@ -21,6 +21,7 @@ import (
"net"
"os"
"os/signal"
"runtime"
"strconv"
"strings"
"sync"
@ -151,6 +152,15 @@ var mountCmd = &cobra.Command{
cfg.Options[parts[0]] = parts[1]
}
// An escape valve to allow future hackers to try NFS, VirtFS, or other FS types.
if !supportedFilesystems[cfg.Type] {
out.T(out.WarningType, "{{.type}} is not yet a supported filesystem. We will try anyways!", out.V{"type": cfg.Type})
}
bindIP := ip.String() // the ip to listen on the user's host machine
if driver.IsKIC(host.Driver.DriverName()) && runtime.GOOS != "linux" {
bindIP = "127.0.0.1"
}
out.T(out.Mounting, "Mounting host path {{.sourcePath}} into VM as {{.destinationPath}} ...", out.V{"sourcePath": hostPath, "destinationPath": vmPath})
out.T(out.Option, "Mount type: {{.name}}", out.V{"type": cfg.Type})
out.T(out.Option, "User ID: {{.userID}}", out.V{"userID": cfg.UID})
@ -159,18 +169,14 @@ var mountCmd = &cobra.Command{
out.T(out.Option, "Message Size: {{.size}}", out.V{"size": cfg.MSize})
out.T(out.Option, "Permissions: {{.octalMode}} ({{.writtenMode}})", out.V{"octalMode": fmt.Sprintf("%o", cfg.Mode), "writtenMode": cfg.Mode})
out.T(out.Option, "Options: {{.options}}", out.V{"options": cfg.Options})
// An escape valve to allow future hackers to try NFS, VirtFS, or other FS types.
if !supportedFilesystems[cfg.Type] {
out.T(out.WarningType, "{{.type}} is not yet a supported filesystem. We will try anyways!", out.V{"type": cfg.Type})
}
out.T(out.Option, "Bind Address: {{.Address}}", out.V{"Address": net.JoinHostPort(bindIP, fmt.Sprint(port))})
var wg sync.WaitGroup
if cfg.Type == nineP {
wg.Add(1)
go func() {
out.T(out.Fileserver, "Userspace file server: ")
ufs.StartServer(net.JoinHostPort(ip.String(), strconv.Itoa(port)), debugVal, hostPath)
ufs.StartServer(net.JoinHostPort(bindIP, strconv.Itoa(port)), debugVal, hostPath)
out.T(out.Stopped, "Userspace file server is shutdown")
wg.Done()
}()

View File

@ -0,0 +1,79 @@
/*
Copyright 2019 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 oci
import (
"fmt"
"net"
"os/exec"
"runtime"
"strings"
"github.com/golang/glog"
"github.com/pkg/errors"
)
// RoutableHostIPFromInside returns the ip/dns of the host that container lives on
// is routable from inside the container
func RoutableHostIPFromInside(ociBin string, containerName string) (net.IP, error) {
if ociBin != Docker {
return nil, fmt.Errorf("RoutableHostIPFromInside is currently only implemented for docker https://github.com/containers/libpod/issues/5205")
}
if runtime.GOOS == "linux" {
return dockerGatewayIP()
}
// for windows and mac, the gateway ip is not routable so we use dns trick.
return digDNS(ociBin, containerName, "host.docker.internal")
}
// digDNS will get the IP record for a dns
func digDNS(ociBin, containerName, dns string) (net.IP, error) {
if err := PointToHostDockerDaemon(); err != nil {
return nil, errors.Wrap(err, "point host docker-daemon")
}
cmd := exec.Command(ociBin, "exec", "-t", containerName, "dig", "+short", dns)
out, err := cmd.CombinedOutput()
ip := net.ParseIP(strings.TrimSpace(string(out)))
if err != nil {
return ip, errors.Wrapf(err, "resolve dns to ip", string(out))
}
glog.Infof("got host ip for mount in container by digging dns: %s", ip.String())
return ip, nil
}
// 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() (net.IP, error) {
if err := PointToHostDockerDaemon(); err != nil {
return nil, errors.Wrap(err, "point host docker-daemon")
}
cmd := exec.Command(Docker, "network", "ls", "--filter", "name=bridge", "--format", "{{.ID}}")
out, err := cmd.CombinedOutput()
if err != nil {
return nil, errors.Wrapf(err, "get network bridge. output: %s", string(out))
}
bridgeID := strings.TrimSpace(string(out))
cmd = exec.Command(Docker, "inspect",
"--format", "{{(index .IPAM.Config 0).Gateway}}", bridgeID)
out, err = cmd.CombinedOutput()
if err != nil {
return nil, errors.Wrapf(err, "inspect IP gatway for bridge network: %q. output: %s", string(out), bridgeID)
}
ip := net.ParseIP(strings.TrimSpace(string(out)))
glog.Infof("got host ip for mount in container by inspect docker network: %s", ip.String())
return ip, nil
}

View File

@ -16,7 +16,11 @@ limitations under the License.
package kic
import "k8s.io/minikube/pkg/drivers/kic/oci"
import (
"fmt"
"k8s.io/minikube/pkg/drivers/kic/oci"
)
const (
// Docker default bridge network is named "bridge" (https://docs.docker.com/network/bridge/#use-the-default-bridge-network)
@ -25,14 +29,20 @@ const (
DefaultPodCIDR = "10.244.0.0/16"
// Version is the current version of kic
Version = "v0.0.5"
// BaseImage is the base image is used to spin up kic containers. it uses same base-image as kind.
BaseImage = "gcr.io/k8s-minikube/kicbase:v0.0.5@sha256:3ddd8461dfb5c3e452ccc44d87750b87a574ec23fc425da67dccc1f0c57d428a" // CNI plugin image used for kic drivers created by kind.
Version = "v0.0.6"
// SHA of the kic base image
baseImageSHA = "53725be5106d1d797dff4041d8c297383f32ab2edeff0a69fc3f50263cf17c79"
// OverlayImage is the cni plugin used for overlay image, created by kind.
// CNI plugin image used for kic drivers created by kind.
OverlayImage = "kindest/kindnetd:0.5.3"
)
var (
// BaseImage is the base image is used to spin up kic containers. it uses same base-image as kind.
BaseImage = fmt.Sprintf("gcr.io/k8s-minikube/kicbase:%s@sha256:%s", Version, baseImageSHA)
)
// Config is configuration for the kic driver used by registry
type Config struct {
MachineName string // maps to the container name being created

View File

@ -33,6 +33,10 @@ import (
// GetVMHostIP gets the ip address to be used for mapping host -> VM and VM -> host
func GetVMHostIP(host *host.Host) (net.IP, error) {
switch host.DriverName {
case driver.Docker:
return oci.RoutableHostIPFromInside(oci.Docker, host.Name)
case driver.Podman:
return oci.RoutableHostIPFromInside(oci.Podman, host.Name)
case driver.KVM2:
return net.ParseIP("192.168.39.1"), nil
case driver.HyperV:

View File

@ -60,7 +60,7 @@ func Mount(r mountRunner, source string, target string, c *MountConfig) error {
return errors.Wrap(err, "umount")
}
if _, err := r.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -m %o -p %s && %s", c.Mode, target, mntCmd(source, target, c)))); err != nil {
if _, err := r.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -m %o -p %s", c.Mode, target))); err != nil {
return errors.Wrap(err, "create folder pre-mount")
}