Merge pull request #4593 from josedonizetti/add-hyperkit-version

Add version to hyperkit driver
pull/4659/head
Medya Ghazizadeh 2019-07-01 14:38:30 -07:00 committed by GitHub
commit 2aac268ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 1 deletions

View File

@ -86,6 +86,9 @@ 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)
# hyperkit ldflags
HYPERKIT_LDFLAGS := -X k8s.io/minikube/pkg/drivers/hyperkit.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/hyperkit.gitCommitID=$(COMMIT)
# $(call DOCKER, image, command)
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)'
@ -329,7 +332,9 @@ out/docker-machine-driver-hyperkit:
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
$(call DOCKER,$(HYPERKIT_BUILD_IMAGE),CC=o64-clang CXX=o64-clang++ /usr/bin/make $@)
else
GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
GOOS=darwin CGO_ENABLED=1 go build \
-ldflags="$(HYPERKIT_LDFLAGS)" \
-o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
endif
.PHONY: install-hyperkit-driver

View File

@ -19,10 +19,19 @@ limitations under the License.
package main
import (
"fmt"
"os"
"github.com/docker/machine/libmachine/drivers/plugin"
"k8s.io/minikube/pkg/drivers/hyperkit"
)
func main() {
if len(os.Args) > 1 && os.Args[1] == "version" {
fmt.Println("version:", hyperkit.GetVersion())
fmt.Println("commit:", hyperkit.GetGitCommitID())
return
}
plugin.RegisterDriver(hyperkit.NewDriver("", ""))
}

View File

@ -133,6 +133,14 @@ or, to use hyperkit as a default driver for minikube:
minikube config set vm-driver hyperkit
```
### Troubleshoot
Make sure you are running the lastest version of your driver.
```shell
docker-machine-driver-hyperkit version
```
## HyperV driver
Hyper-v users may need to create a new external network switch as described [here](https://docs.docker.com/machine/drivers/hyper-v/). This step may prevent a problem in which `minikube start` hangs indefinitely, unable to ssh into the minikube virtual machine. In this add, add the `--hyperv-virtual-switch=switch-name` argument to the `minikube start` command.

View File

@ -0,0 +1,35 @@
/*
Copyright 2016 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 hyperkit
// The current version of the docker-machine-driver-hyperkit
// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/drivers/hyperkit.version=vX.Y.Z"
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/hyperkit.gitCommitID=<commit-id>"
var gitCommitID = ""
// GetVersion returns the current docker-machine-driver-hyperkit version
func GetVersion() string {
return version
}
// GetGitCommitID returns the git commit id from which it is being built
func GetGitCommitID() string {
return gitCommitID
}