提交 ad97983d 编写于 作者: J Jose Donizetti 提交者: Ben Ebsworth

# This is a combination of 8 commits.

# This is the 1st commit message:

Fix doc comment version.gitCommitID doc


# This is the commit message #2:

Add hyperkit doc


# This is the commit message #3:

Add commit id to docker-machine-driver-kvm2 version


# This is the commit message #4:

removed label selector for registry-proxy daemonset

# This is the commit message #5:

Add support to custom qemu uri on kvm2 driver


# This is the commit message #6:

Improve hyperkit vm stop


# This is the commit message #7:

Make virtualbox DNS settings configurable 


# This is the commit message #8:

added integration tests for registry addon
上级 d5ded276
...@@ -83,6 +83,9 @@ CMD_SOURCE_DIRS = cmd pkg ...@@ -83,6 +83,9 @@ CMD_SOURCE_DIRS = cmd pkg
SOURCE_DIRS = $(CMD_SOURCE_DIRS) test SOURCE_DIRS = $(CMD_SOURCE_DIRS) test
SOURCE_PACKAGES = ./cmd/... ./pkg/... ./test/... SOURCE_PACKAGES = ./cmd/... ./pkg/... ./test/...
# kvm2 ldflags
KVM2_LDFLAGS := -X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=$(COMMIT)
# $(call DOCKER, image, command) # $(call DOCKER, image, command)
define DOCKER define DOCKER
docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /app -v $(PWD):/app -v $(GOPATH):/go --entrypoint /bin/bash $(1) -c '$(2)' docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /app -v $(PWD):/app -v $(GOPATH):/go --entrypoint /bin/bash $(1) -c '$(2)'
...@@ -387,11 +390,11 @@ release-minikube: out/minikube checksum ...@@ -387,11 +390,11 @@ release-minikube: out/minikube checksum
gsutil cp out/minikube-$(GOOS)-$(GOARCH).sha256 $(MINIKUBE_UPLOAD_LOCATION)/$(MINIKUBE_VERSION)/minikube-$(GOOS)-$(GOARCH).sha256 gsutil cp out/minikube-$(GOOS)-$(GOARCH).sha256 $(MINIKUBE_UPLOAD_LOCATION)/$(MINIKUBE_VERSION)/minikube-$(GOOS)-$(GOARCH).sha256
out/docker-machine-driver-kvm2: out/docker-machine-driver-kvm2:
go build \ go build \
-installsuffix "static" \ -installsuffix "static" \
-ldflags "-X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION)" \ -ldflags="$(KVM2_LDFLAGS)" \
-tags libvirt.1.3.1 \ -tags libvirt.1.3.1 \
-o $(BUILD_DIR)/docker-machine-driver-kvm2 \ -o $(BUILD_DIR)/docker-machine-driver-kvm2 \
k8s.io/minikube/cmd/drivers/kvm k8s.io/minikube/cmd/drivers/kvm
chmod +X $@ chmod +X $@
......
...@@ -27,8 +27,9 @@ import ( ...@@ -27,8 +27,9 @@ import (
) )
func main() { func main() {
if len(os.Args) > 1 && os.Args[1] == "--version" { if len(os.Args) > 1 && os.Args[1] == "version" {
fmt.Println(kvm.GetVersion()) fmt.Println("version:", kvm.GetVersion())
fmt.Println("commit:", kvm.GetGitCommitID())
return return
} }
......
...@@ -77,6 +77,7 @@ const ( ...@@ -77,6 +77,7 @@ const (
enableDefaultCNI = "enable-default-cni" enableDefaultCNI = "enable-default-cni"
hypervVirtualSwitch = "hyperv-virtual-switch" hypervVirtualSwitch = "hyperv-virtual-switch"
kvmNetwork = "kvm-network" kvmNetwork = "kvm-network"
kvmQemuURI = "kvm-qemu-uri"
keepContext = "keep-context" keepContext = "keep-context"
createMount = "mount" createMount = "mount"
featureGates = "feature-gates" featureGates = "feature-gates"
...@@ -97,6 +98,8 @@ const ( ...@@ -97,6 +98,8 @@ const (
embedCerts = "embed-certs" embedCerts = "embed-certs"
noVTXCheck = "no-vtx-check" noVTXCheck = "no-vtx-check"
downloadOnly = "download-only" downloadOnly = "download-only"
dnsProxy = "dns-proxy"
hostDNSResolver = "host-dns-resolver"
) )
var ( var (
...@@ -122,6 +125,7 @@ func init() { ...@@ -122,6 +125,7 @@ func init() {
startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minikube VM (only supported with Virtualbox driver)") startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minikube VM (only supported with Virtualbox driver)")
startCmd.Flags().String(hypervVirtualSwitch, "", "The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)") startCmd.Flags().String(hypervVirtualSwitch, "", "The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)")
startCmd.Flags().String(kvmNetwork, "default", "The KVM network name. (only supported with KVM driver)") startCmd.Flags().String(kvmNetwork, "default", "The KVM network name. (only supported with KVM driver)")
startCmd.Flags().String(kvmQemuURI, "qemu:///system", "The KVM QEMU connection URI. (works only with kvm2 driver on linux)")
startCmd.Flags().String(xhyveDiskDriver, "ahci-hd", "The disk driver to use [ahci-hd|virtio-blk] (only supported with xhyve driver)") startCmd.Flags().String(xhyveDiskDriver, "ahci-hd", "The disk driver to use [ahci-hd|virtio-blk] (only supported with xhyve driver)")
startCmd.Flags().StringSlice(nfsShare, []string{}, "Local folders to share with Guest via NFS mounts (Only supported on with hyperkit now)") startCmd.Flags().StringSlice(nfsShare, []string{}, "Local folders to share with Guest via NFS mounts (Only supported on with hyperkit now)")
startCmd.Flags().String(nfsSharesRoot, "/nfsshares", "Where to root the NFS Shares (defaults to /nfsshares, only supported with hyperkit now)") startCmd.Flags().String(nfsSharesRoot, "/nfsshares", "Where to root the NFS Shares (defaults to /nfsshares, only supported with hyperkit now)")
...@@ -156,6 +160,8 @@ func init() { ...@@ -156,6 +160,8 @@ func init() {
startCmd.Flags().Bool(gpu, false, "Enable experimental NVIDIA GPU support in minikube (works only with kvm2 driver on Linux)") startCmd.Flags().Bool(gpu, false, "Enable experimental NVIDIA GPU support in minikube (works only with kvm2 driver on Linux)")
startCmd.Flags().Bool(hidden, false, "Hide the hypervisor signature from the guest in minikube (works only with kvm2 driver on Linux)") startCmd.Flags().Bool(hidden, false, "Hide the hypervisor signature from the guest in minikube (works only with kvm2 driver on Linux)")
startCmd.Flags().Bool(noVTXCheck, false, "Disable checking for the availability of hardware virtualization before the vm is started (virtualbox)") startCmd.Flags().Bool(noVTXCheck, false, "Disable checking for the availability of hardware virtualization before the vm is started (virtualbox)")
startCmd.Flags().Bool(dnsProxy, false, "Enable proxy for NAT DNS requests (virtualbox)")
startCmd.Flags().Bool(hostDNSResolver, true, "Enable host resolver for NAT DNS requests (virtualbox)")
if err := viper.BindPFlags(startCmd.Flags()); err != nil { if err := viper.BindPFlags(startCmd.Flags()); err != nil {
exit.WithError("unable to bind flags", err) exit.WithError("unable to bind flags", err)
} }
...@@ -520,13 +526,16 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) { ...@@ -520,13 +526,16 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
RegistryMirror: registryMirror, RegistryMirror: registryMirror,
HostOnlyCIDR: viper.GetString(hostOnlyCIDR), HostOnlyCIDR: viper.GetString(hostOnlyCIDR),
HypervVirtualSwitch: viper.GetString(hypervVirtualSwitch), HypervVirtualSwitch: viper.GetString(hypervVirtualSwitch),
KvmNetwork: viper.GetString(kvmNetwork), KVMNetwork: viper.GetString(kvmNetwork),
KVMQemuURI: viper.GetString(kvmQemuURI),
Downloader: pkgutil.DefaultDownloader{}, Downloader: pkgutil.DefaultDownloader{},
DisableDriverMounts: viper.GetBool(disableDriverMounts), DisableDriverMounts: viper.GetBool(disableDriverMounts),
UUID: viper.GetString(uuid), UUID: viper.GetString(uuid),
GPU: viper.GetBool(gpu), GPU: viper.GetBool(gpu),
Hidden: viper.GetBool(hidden), Hidden: viper.GetBool(hidden),
NoVTXCheck: viper.GetBool(noVTXCheck), NoVTXCheck: viper.GetBool(noVTXCheck),
DNSProxy: viper.GetBool(dnsProxy),
HostDNSResolver: viper.GetBool(hostDNSResolver),
}, },
KubernetesConfig: cfg.KubernetesConfig{ KubernetesConfig: cfg.KubernetesConfig{
KubernetesVersion: k8sVersion, KubernetesVersion: k8sVersion,
......
...@@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1 ...@@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
labels: labels:
kubernetes.io/minikube-addons: registry kubernetes.io/minikube-addons: registry-proxy
addonmanager.kubernetes.io/mode: Reconcile addonmanager.kubernetes.io/mode: Reconcile
name: registry-proxy name: registry-proxy
namespace: kube-system namespace: kube-system
...@@ -10,7 +10,7 @@ spec: ...@@ -10,7 +10,7 @@ spec:
template: template:
metadata: metadata:
labels: labels:
kubernetes.io/minikube-addons: registry kubernetes.io/minikube-addons: registry-proxy
addonmanager.kubernetes.io/mode: Reconcile addonmanager.kubernetes.io/mode: Reconcile
spec: spec:
containers: containers:
......
...@@ -99,7 +99,7 @@ virsh net-start default ...@@ -99,7 +99,7 @@ virsh net-start default
Make sure you are running the lastest version of your driver. Make sure you are running the lastest version of your driver.
```shell ```shell
docker-machine-driver-kvm2 --version docker-machine-driver-kvm2 version
``` ```
## Hyperkit driver ## Hyperkit driver
......
...@@ -54,6 +54,7 @@ const ( ...@@ -54,6 +54,7 @@ const (
"sudo chown root:wheel %s && sudo chmod u+s %s" "sudo chown root:wheel %s && sudo chmod u+s %s"
) )
// Driver is the machine driver for Hyperkit
type Driver struct { type Driver struct {
*drivers.BaseDriver *drivers.BaseDriver
*pkgdrivers.CommonDriver *pkgdrivers.CommonDriver
...@@ -69,6 +70,7 @@ type Driver struct { ...@@ -69,6 +70,7 @@ type Driver struct {
VSockPorts []string VSockPorts []string
} }
// NewDriver creates a new driver for a host
func NewDriver(hostName, storePath string) *Driver { func NewDriver(hostName, storePath string) *Driver {
return &Driver{ return &Driver{
BaseDriver: &drivers.BaseDriver{ BaseDriver: &drivers.BaseDriver{
...@@ -98,6 +100,7 @@ func (d *Driver) verifyRootPermissions() error { ...@@ -98,6 +100,7 @@ func (d *Driver) verifyRootPermissions() error {
return nil return nil
} }
// Create a host using the driver's config
func (d *Driver) Create() error { func (d *Driver) Create() error {
if err := d.verifyRootPermissions(); err != nil { if err := d.verifyRootPermissions(); err != nil {
return err return err
...@@ -194,6 +197,7 @@ func (d *Driver) Remove() error { ...@@ -194,6 +197,7 @@ func (d *Driver) Remove() error {
return nil return nil
} }
// Restart a host
func (d *Driver) Restart() error { func (d *Driver) Restart() error {
return pkgdrivers.Restart(d) return pkgdrivers.Restart(d)
} }
...@@ -342,7 +346,26 @@ func (d *Driver) Stop() error { ...@@ -342,7 +346,26 @@ func (d *Driver) Stop() error {
return err return err
} }
d.cleanupNfsExports() d.cleanupNfsExports()
return d.sendSignal(syscall.SIGTERM) err := d.sendSignal(syscall.SIGTERM)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("hyperkit sigterm failed"))
}
// wait 5s for graceful shutdown
for i := 0; i < 5; i++ {
log.Debug("waiting for graceful shutdown")
time.Sleep(time.Second * 1)
s, err := d.GetState()
if err != nil {
return errors.Wrap(err, fmt.Sprintf("hyperkit waiting graceful shutdown failed"))
}
if s == state.Stopped {
return nil
}
}
log.Debug("sending sigkill")
return d.Kill()
} }
func (d *Driver) extractKernel(isoPath string) error { func (d *Driver) extractKernel(isoPath string) error {
......
...@@ -128,7 +128,7 @@ func randomMAC() (net.HardwareAddr, error) { ...@@ -128,7 +128,7 @@ func randomMAC() (net.HardwareAddr, error) {
} }
func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) { func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) {
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "getting domain") return nil, nil, errors.Wrap(err, "getting domain")
} }
...@@ -141,8 +141,8 @@ func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) { ...@@ -141,8 +141,8 @@ func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) {
return dom, conn, nil return dom, conn, nil
} }
func getConnection() (*libvirt.Connect, error) { func getConnection(connectionURI string) (*libvirt.Connect, error) {
conn, err := libvirt.NewConnect(qemusystem) conn, err := libvirt.NewConnect(connectionURI)
if err != nil { if err != nil {
return nil, errors.Wrap(err, connectionErrorText) return nil, errors.Wrap(err, connectionErrorText)
} }
...@@ -186,7 +186,7 @@ func (d *Driver) createDomain() (*libvirt.Domain, error) { ...@@ -186,7 +186,7 @@ func (d *Driver) createDomain() (*libvirt.Domain, error) {
return nil, errors.Wrap(err, "executing domain xml") return nil, errors.Wrap(err, "executing domain xml")
} }
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "Error getting libvirt connection") return nil, errors.Wrap(err, "Error getting libvirt connection")
} }
......
...@@ -82,6 +82,9 @@ type Driver struct { ...@@ -82,6 +82,9 @@ type Driver struct {
// XML that needs to be added to passthrough GPU devices. // XML that needs to be added to passthrough GPU devices.
DevicesXML string DevicesXML string
// QEMU Connection URI
ConnectionURI string
} }
const ( const (
...@@ -107,12 +110,13 @@ func NewDriver(hostName, storePath string) *Driver { ...@@ -107,12 +110,13 @@ func NewDriver(hostName, storePath string) *Driver {
Network: defaultNetworkName, Network: defaultNetworkName,
DiskPath: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), fmt.Sprintf("%s.rawdisk", config.GetMachineName())), DiskPath: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), fmt.Sprintf("%s.rawdisk", config.GetMachineName())),
ISO: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), "boot2docker.iso"), ISO: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), "boot2docker.iso"),
ConnectionURI: qemusystem,
} }
} }
// PreCommandCheck checks the connection before issuing a command // PreCommandCheck checks the connection before issuing a command
func (d *Driver) PreCommandCheck() error { func (d *Driver) PreCommandCheck() error {
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return errors.Wrap(err, "Error connecting to libvirt socket. Have you added yourself to the libvirtd group?") return errors.Wrap(err, "Error connecting to libvirt socket. Have you added yourself to the libvirtd group?")
} }
...@@ -424,7 +428,7 @@ func (d *Driver) Stop() (err error) { ...@@ -424,7 +428,7 @@ func (d *Driver) Stop() (err error) {
// Remove a host // Remove a host
func (d *Driver) Remove() error { func (d *Driver) Remove() error {
log.Debug("Removing machine...") log.Debug("Removing machine...")
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return errors.Wrap(err, "getting connection") return errors.Wrap(err, "getting connection")
} }
......
...@@ -81,7 +81,7 @@ func setupNetwork(conn *libvirt.Connect, name string) error { ...@@ -81,7 +81,7 @@ func setupNetwork(conn *libvirt.Connect, name string) error {
// ensureNetwork is called on start of the VM // ensureNetwork is called on start of the VM
func (d *Driver) ensureNetwork() error { func (d *Driver) ensureNetwork() error {
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return errors.Wrap(err, "getting libvirt connection") return errors.Wrap(err, "getting libvirt connection")
} }
...@@ -108,12 +108,11 @@ func (d *Driver) ensureNetwork() error { ...@@ -108,12 +108,11 @@ func (d *Driver) ensureNetwork() error {
// createNetwork is called during creation of the VM only (and not on start) // createNetwork is called during creation of the VM only (and not on start)
func (d *Driver) createNetwork() error { func (d *Driver) createNetwork() error {
if d.Network == defaultPrivateNetworkName { if d.Network == defaultPrivateNetworkName {
return fmt.Errorf("KVM network can't be named %s. This is the name of the private network created by minikube", defaultPrivateNetworkName) return fmt.Errorf("KVM network can't be named %s. This is the name of the private network created by minikube", defaultPrivateNetworkName)
} }
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return errors.Wrap(err, "getting libvirt connection") return errors.Wrap(err, "getting libvirt connection")
} }
...@@ -151,7 +150,7 @@ func (d *Driver) createNetwork() error { ...@@ -151,7 +150,7 @@ func (d *Driver) createNetwork() error {
} }
func (d *Driver) deleteNetwork() error { func (d *Driver) deleteNetwork() error {
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return errors.Wrap(err, "getting libvirt connection") return errors.Wrap(err, "getting libvirt connection")
} }
...@@ -269,7 +268,7 @@ func (d *Driver) checkDomains(conn *libvirt.Connect) error { ...@@ -269,7 +268,7 @@ func (d *Driver) checkDomains(conn *libvirt.Connect) error {
} }
func (d *Driver) lookupIP() (string, error) { func (d *Driver) lookupIP() (string, error) {
conn, err := getConnection() conn, err := getConnection(d.ConnectionURI)
if err != nil { if err != nil {
return "", errors.Wrap(err, "getting connection and domain") return "", errors.Wrap(err, "getting connection and domain")
} }
......
...@@ -21,7 +21,15 @@ package kvm ...@@ -21,7 +21,15 @@ package kvm
// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.version=vX.Y.Z" // version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.version=vX.Y.Z"
var version = "v0.0.0-unset" var version = "v0.0.0-unset"
// gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=<commit-id>"
var gitCommitID = ""
// GetVersion returns the current docker-machine-driver-kvm2 version // GetVersion returns the current docker-machine-driver-kvm2 version
func GetVersion() string { func GetVersion() string {
return version return version
} }
// GetGitCommitID returns the git commit id from which it is being built
func GetGitCommitID() string {
return gitCommitID
}
...@@ -45,7 +45,8 @@ type MachineConfig struct { ...@@ -45,7 +45,8 @@ type MachineConfig struct {
RegistryMirror []string RegistryMirror []string
HostOnlyCIDR string // Only used by the virtualbox driver HostOnlyCIDR string // Only used by the virtualbox driver
HypervVirtualSwitch string HypervVirtualSwitch string
KvmNetwork string // Only used by the KVM driver KVMNetwork string // Only used by the KVM driver
KVMQemuURI string // Only used by kvm2
Downloader util.ISODownloader `json:"-"` Downloader util.ISODownloader `json:"-"`
DockerOpt []string // Each entry is formatted as KEY=VALUE. DockerOpt []string // Each entry is formatted as KEY=VALUE.
DisableDriverMounts bool // Only used by virtualbox and xhyve DisableDriverMounts bool // Only used by virtualbox and xhyve
...@@ -55,6 +56,8 @@ type MachineConfig struct { ...@@ -55,6 +56,8 @@ type MachineConfig struct {
GPU bool // Only used by kvm2 GPU bool // Only used by kvm2
Hidden bool // Only used by kvm2 Hidden bool // Only used by kvm2
NoVTXCheck bool // Only used by virtualbox NoVTXCheck bool // Only used by virtualbox
DNSProxy bool // Only used by virtualbox
HostDNSResolver bool // Only used by virtualbox
} }
// KubernetesConfig contains the parameters used to configure the VM Kubernetes. // KubernetesConfig contains the parameters used to configure the VM Kubernetes.
......
...@@ -64,7 +64,7 @@ func createKVMHost(config cfg.MachineConfig) interface{} { ...@@ -64,7 +64,7 @@ func createKVMHost(config cfg.MachineConfig) interface{} {
}, },
Memory: config.Memory, Memory: config.Memory,
CPU: config.CPUs, CPU: config.CPUs,
Network: config.KvmNetwork, Network: config.KVMNetwork,
PrivateNetwork: "docker-machines", PrivateNetwork: "docker-machines",
Boot2DockerURL: config.Downloader.GetISOFileURI(config.MinikubeISO), Boot2DockerURL: config.Downloader.GetISOFileURI(config.MinikubeISO),
DiskSize: config.DiskSize, DiskSize: config.DiskSize,
......
...@@ -53,6 +53,7 @@ type kvmDriver struct { ...@@ -53,6 +53,7 @@ type kvmDriver struct {
DiskPath string DiskPath string
GPU bool GPU bool
Hidden bool Hidden bool
ConnectionURI string
} }
func createKVM2Host(config cfg.MachineConfig) interface{} { func createKVM2Host(config cfg.MachineConfig) interface{} {
...@@ -64,7 +65,7 @@ func createKVM2Host(config cfg.MachineConfig) interface{} { ...@@ -64,7 +65,7 @@ func createKVM2Host(config cfg.MachineConfig) interface{} {
}, },
Memory: config.Memory, Memory: config.Memory,
CPU: config.CPUs, CPU: config.CPUs,
Network: config.KvmNetwork, Network: config.KVMNetwork,
PrivateNetwork: "minikube-net", PrivateNetwork: "minikube-net",
Boot2DockerURL: config.Downloader.GetISOFileURI(config.MinikubeISO), Boot2DockerURL: config.Downloader.GetISOFileURI(config.MinikubeISO),
DiskSize: config.DiskSize, DiskSize: config.DiskSize,
...@@ -72,5 +73,6 @@ func createKVM2Host(config cfg.MachineConfig) interface{} { ...@@ -72,5 +73,6 @@ func createKVM2Host(config cfg.MachineConfig) interface{} {
ISO: filepath.Join(constants.GetMinipath(), "machines", cfg.GetMachineName(), "boot2docker.iso"), ISO: filepath.Join(constants.GetMinipath(), "machines", cfg.GetMachineName(), "boot2docker.iso"),
GPU: config.GPU, GPU: config.GPU,
Hidden: config.Hidden, Hidden: config.Hidden,
ConnectionURI: config.KVMQemuURI,
} }
} }
...@@ -54,8 +54,8 @@ func createVirtualboxHost(config cfg.MachineConfig) interface{} { ...@@ -54,8 +54,8 @@ func createVirtualboxHost(config cfg.MachineConfig) interface{} {
d.NoVTXCheck = config.NoVTXCheck d.NoVTXCheck = config.NoVTXCheck
d.NatNicType = defaultVirtualboxNicType d.NatNicType = defaultVirtualboxNicType
d.HostOnlyNicType = defaultVirtualboxNicType d.HostOnlyNicType = defaultVirtualboxNicType
d.DNSProxy = false d.DNSProxy = config.DNSProxy
d.HostDNSResolver = true d.HostDNSResolver = config.HostDNSResolver
return d return d
} }
...@@ -30,7 +30,7 @@ const VersionPrefix = "v" ...@@ -30,7 +30,7 @@ const VersionPrefix = "v"
// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.version=vX.Y.Z" // version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.version=vX.Y.Z"
var version = "v0.0.0-unset" var version = "v0.0.0-unset"
// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.gitCommitID=<commit-id>" // gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.gitCommitID=<commit-id>"
var gitCommitID = "" var gitCommitID = ""
// isoVersion is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.isoVersion=vX.Y.Z" // isoVersion is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.isoVersion=vX.Y.Z"
......
...@@ -190,7 +190,57 @@ func testServicesList(t *testing.T) { ...@@ -190,7 +190,57 @@ func testServicesList(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
} }
func testRegistry(t *testing.T) {
t.Parallel()
minikubeRunner := NewMinikubeRunner(t)
kubectlRunner := util.NewKubectlRunner(t)
minikubeRunner.RunCommand("addons enable registry", true)
t.Log("wait for registry to come up")
if err := util.WaitForDockerRegistryRunning(t); err != nil {
t.Fatalf("waiting for registry to be up: %v", err)
}
// Check access from outside the cluster on port 5000, validing connectivity via registry-proxy
checkExternalAccess := func() error {
t.Log("checking registry access from outside cluster")
expectedStr := "200"
runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000")
externalCheckOutput, _ := minikubeRunner.SSH(runCmd)
if !strings.Contains(externalCheckOutput, expectedStr) {
return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput)
}
return nil
}
if err := util.Retry(t, checkExternalAccess, 2*time.Second, 5); err != nil {
t.Fatalf(err.Error())
}
// check access from inside the cluster via a busybox container running inside cluster
t.Log("checking registry access from inside cluster")
expectedStr := "200"
out, _ := kubectlRunner.RunCommand([]string{
"run",
"registry-test",
"--restart=Never",
"--image=busybox",
"-it",
"--",
"sh",
"-c",
"wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'"})
internalCheckOutput := string(out)
if !strings.Contains(internalCheckOutput, expectedStr) {
t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput)
}
defer func() {
if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil {
t.Fatalf("failed to delete pod registry-test")
}
}()
minikubeRunner.RunCommand("addons disable registry", true)
}
func testGvisor(t *testing.T) { func testGvisor(t *testing.T) {
minikubeRunner := NewMinikubeRunner(t) minikubeRunner := NewMinikubeRunner(t)
minikubeRunner.RunCommand("addons enable gvisor", true) minikubeRunner.RunCommand("addons enable gvisor", true)
......
...@@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) { ...@@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) {
t.Run("DNS", testClusterDNS) t.Run("DNS", testClusterDNS)
t.Run("Logs", testClusterLogs) t.Run("Logs", testClusterLogs)
t.Run("Addons", testAddons) t.Run("Addons", testAddons)
t.Run("Registry", testRegistry)
t.Run("Dashboard", testDashboard) t.Run("Dashboard", testDashboard)
t.Run("ServicesList", testServicesList) t.Run("ServicesList", testServicesList)
t.Run("Provisioning", testProvisioning) t.Run("Provisioning", testProvisioning)
......
...@@ -41,6 +41,7 @@ func TestStartStop(t *testing.T) { ...@@ -41,6 +41,7 @@ func TestStartStop(t *testing.T) {
// default is the network created by libvirt, if we change the name minikube won't boot // default is the network created by libvirt, if we change the name minikube won't boot
// because the given network doesn't exist // because the given network doesn't exist
"--kvm-network=default", "--kvm-network=default",
"--kvm-qemu-uri=qemu:///system",
}}, }},
{"feature_gates_newest_cni", []string{ {"feature_gates_newest_cni", []string{
"--feature-gates", "--feature-gates",
......
...@@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error { ...@@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error {
return nil return nil
} }
// WaitForDockerRegistryRunning waits until docker registry pod to be running
func WaitForDockerRegistryRunning(t *testing.T) error {
client, err := commonutil.GetClient()
if err != nil {
return errors.Wrap(err, "getting kubernetes client")
}
if err := commonutil.WaitForRCToStabilize(client, "kube-system", "registry", time.Minute*10); err != nil {
return errors.Wrap(err, "waiting for registry replicacontroller to stabilize")
}
registrySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry"}))
if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", registrySelector); err != nil {
return errors.Wrap(err, "waiting for registry pods")
}
proxySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry-proxy"}))
if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", proxySelector); err != nil {
return errors.Wrap(err, "waiting for registry-proxy pods")
}
return nil
}
// WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running // WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running
func WaitForIngressDefaultBackendRunning(t *testing.T) error { func WaitForIngressDefaultBackendRunning(t *testing.T) error {
client, err := commonutil.GetClient() client, err := commonutil.GetClient()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册