diff --git a/.cobra.yaml b/.cobra.yaml deleted file mode 100644 index 948aebbfa1..0000000000 --- a/.cobra.yaml +++ /dev/null @@ -1,2 +0,0 @@ -author: The Kubernetes Authors -license: Apache 2.0 diff --git a/Makefile b/Makefile index 4a2235e9a6..4d641d3323 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Use the native vendor/ dependency system +export GO15VENDOREXPERIMENT=1 + GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) BUILD_DIR ?= ./out +REPOPATH ?= k8s.io/minikube +BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.6.2-1 ifeq ($(IN_DOCKER),1) GOPATH := /go @@ -22,11 +27,9 @@ else GOPATH := $(shell pwd)/_gopath endif -REPOPATH ?= k8s.io/minikube -export GO15VENDOREXPERIMENT=1 - -# Set the version information in kubernetes. -LD_FLAGS = "-s -w $(shell python hack/get_k8s_version.py)" +# Set the version information for the Kubernetes servers, and build localkube statically +VERSION_LDFLAGS := $(shell docker run --rm -it -v $(shell pwd):/minikube -w /minikube python python hack/get_k8s_version.py) +LDFLAGS := "$(VERSION_LDFLAGS) -s -w -extldflags '-static'" clean: rm -rf $(GOPATH) @@ -43,9 +46,9 @@ out/minikube: out/minikube-$(GOOS)-$(GOARCH) out/localkube: $(LOCALKUBEFILES) $(MKGOPATH) ifeq ($(GOOS),linux) - CGO_ENABLED=1 go build -ldflags=$(LD_FLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube + CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube else - docker run -w /go/src/$(REPOPATH) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) golang:1.6 make out/localkube + docker run -w /go/src/$(REPOPATH) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) $(BUILD_IMAGE) make out/localkube endif out/minikube-$(GOOS)-$(GOARCH): $(MINIKUBEFILES) pkg/minikube/cluster/localkubecontents.go diff --git a/cmd/localkube/cmd/options.go b/cmd/localkube/cmd/options.go index bc1bc20bb5..da89007986 100644 --- a/cmd/localkube/cmd/options.go +++ b/cmd/localkube/cmd/options.go @@ -27,14 +27,14 @@ import ( func NewLocalkubeServer() *localkube.LocalkubeServer { // net.ParseCIDR returns multiple values. Use the IPNet return value - _, defaultServiceClusterIPRange, _ := net.ParseCIDR("10.0.0.1/24") + _, defaultServiceClusterIPRange, _ := net.ParseCIDR(util.DefaultServiceClusterIP + "/24") return &localkube.LocalkubeServer{ Containerized: false, EnableDNS: true, - DNSDomain: util.DNSDomain, - DNSIP: net.ParseIP("10.0.0.10"), - LocalkubeDirectory: util.LocalkubeDirectory, + DNSDomain: util.DefaultDNSDomain, + DNSIP: net.ParseIP(util.DefaultDNSIP), + LocalkubeDirectory: util.DefaultLocalkubeDirectory, ServiceClusterIPRange: *defaultServiceClusterIPRange, APIServerAddress: net.ParseIP("0.0.0.0"), APIServerPort: 443, diff --git a/cmd/localkube/cmd/version.go b/cmd/localkube/cmd/version.go index ef7e225a55..9940d92e09 100644 --- a/cmd/localkube/cmd/version.go +++ b/cmd/localkube/cmd/version.go @@ -24,7 +24,7 @@ import ( "k8s.io/minikube/pkg/version" ) -var VersionCmd = &cobra.Command{ +var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version of localkube.", Long: `Print the version of localkube.`, @@ -35,5 +35,5 @@ var VersionCmd = &cobra.Command{ } func init() { - RootCmd.AddCommand(VersionCmd) + RootCmd.AddCommand(versionCmd) } diff --git a/cmd/minikube/cmd/version.go b/cmd/minikube/cmd/version.go new file mode 100644 index 0000000000..c34f8123ef --- /dev/null +++ b/cmd/minikube/cmd/version.go @@ -0,0 +1,39 @@ +/* +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 cmd + +import ( + "fmt" + + "github.com/spf13/cobra" + + "k8s.io/minikube/pkg/version" +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the version of minikube.", + Long: `Print the version of minikube.`, + Run: func(command *cobra.Command, args []string) { + + fmt.Println("Version: ", version.Version) + }, +} + +func init() { + RootCmd.AddCommand(versionCmd) +} diff --git a/hack/get_k8s_version.py b/hack/get_k8s_version.py index c55fbc5c0c..d74f57839c 100644 --- a/hack/get_k8s_version.py +++ b/hack/get_k8s_version.py @@ -18,6 +18,7 @@ import json import subprocess +import sys K8S_PACKAGE = 'k8s.io/kubernetes/' X_ARG_BASE = '-X k8s.io/minikube/vendor/k8s.io/kubernetes/pkg/version.' @@ -46,4 +47,4 @@ def main(): return ' '.join([X_ARG_BASE + arg for arg in args]) if __name__ == '__main__': - print main() + sys.exit(main()) diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index ed44999e33..993d7a92a2 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -205,7 +205,7 @@ func SetupCerts(d drivers.Driver) error { if err != nil { return err } - if err := sshutil.Transfer(data, util.CertPath, cert, "0644", client); err != nil { + if err := sshutil.Transfer(data, util.DefaultCertPath, cert, "0644", client); err != nil { return err } } diff --git a/pkg/minikube/cluster/credentials.go b/pkg/minikube/cluster/credentials.go index 758cb6e9ac..497b853f42 100644 --- a/pkg/minikube/cluster/credentials.go +++ b/pkg/minikube/cluster/credentials.go @@ -24,12 +24,12 @@ import ( var ( // This is the internalIP the the API server and other components communicate on. - internalIP = net.ParseIP("10.0.0.1") + internalIP = net.ParseIP(util.DefaultServiceClusterIP) ) func GenerateCerts(pub, priv string, ip net.IP) error { ips := []net.IP{ip, internalIP} - if err := util.GenerateSelfSignedCert(pub, priv, ips, util.GetAlternateDNS(util.DNSDomain)); err != nil { + if err := util.GenerateSelfSignedCert(pub, priv, ips, util.GetAlternateDNS(util.DefaultDNSDomain)); err != nil { return err } return nil diff --git a/pkg/util/constants.go b/pkg/util/constants.go index f483f96f5a..7c0bc88132 100644 --- a/pkg/util/constants.go +++ b/pkg/util/constants.go @@ -16,14 +16,15 @@ limitations under the License. package util -import "fmt" - +// These constants are used by both minikube and localkube const ( - LocalkubeDirectory = "/var/lib/localkube" - DNSDomain = "cluster.local" - CertPath = "/var/lib/localkube/certs/" + DefaultLocalkubeDirectory = "/var/lib/localkube" + DefaultCertPath = DefaultLocalkubeDirectory + "/certs/" + DefaultServiceClusterIP = "10.0.0.1" + DefaultDNSDomain = "cluster.local" + DefaultDNSIP = "10.0.0.10" ) func GetAlternateDNS(domain string) []string { - return []string{fmt.Sprintf("%s.%s", "kubernetes.default.svc", domain), "kubernetes.default.svc", "kubernetes.default", "kubernetes"} + return []string{"kubernetes.default.svc." + domain, "kubernetes.default.svc", "kubernetes.default", "kubernetes"} } diff --git a/pkg/version/version.go b/pkg/version/version.go index 572ba64baa..0043f7dc27 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -16,5 +16,5 @@ limitations under the License. package version -// The current version of the binary -const Version = "0.0.5" +// The current version of the minikube and localkube +const Version = "0.0.1-developing" diff --git a/test.sh b/test.sh index 6aac48a1f7..3204074368 100755 --- a/test.sh +++ b/test.sh @@ -17,8 +17,10 @@ set -e REPO_PATH="k8s.io/minikube" +PYTHON=${PYTHON:-"docker run --rm -it -v $(pwd):/minikube -w /minikube python python"} # Run "go test" on packages that have test files. +echo "Running go tests..." cd ${GOPATH}/src/${REPO_PATH} TESTS=$(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...) go test -v ${TESTS} @@ -35,7 +37,7 @@ echo "Checking boilerplate..." BOILERPLATEDIR=./hack/boilerplate # Grep returns a non-zero exit code if we don't match anything, which is good in this case. set +e -files=$(python ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR} | grep -v $ignore) +files=$(${PYTHON} ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR} | grep -v $ignore) set -e if [ ! -z ${files} ]; then echo "Boilerplate missing in: ${files}."