Skip to content

Commit a7d5684

Browse files
committed
Remove localkube from bindata
This makes the minikube build simpler and the the binary smaller. Localkube will always be remotely fetched and locally cached on the host.
1 parent 3f08a3f commit a7d5684

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ ISO_BUCKET ?= minikube/iso
3232
GOOS ?= $(shell go env GOOS)
3333
GOARCH ?= $(shell go env GOARCH)
3434
BUILD_DIR ?= ./out
35+
$(shell mkdir -p $(BUILD_DIR))
36+
3537
ORG := k8s.io
3638
REPOPATH ?= $(ORG)/minikube
3739

@@ -53,11 +55,9 @@ LOCALKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/local
5355
MINIKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/minikube/ | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
5456
HYPERKIT_FILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' k8s.io/minikube/cmd/drivers/hyperkit | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
5557

56-
KVM_DRIVER_FILES := $(shell go list -f '{{join .Deps "\n"}}' ./cmd/drivers/kvm/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')
58+
MINIKUBE_TEST_FILES := go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./... | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
5759

58-
MINIKUBE_ENV_linux := CGO_ENABLED=1 GOARCH=amd64 GOOS=linux
59-
MINIKUBE_ENV_darwin := CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin
60-
MINIKUBE_ENV_windows := CGO_ENABLED=0 GOARCH=amd64 GOOS=windows
60+
KVM_DRIVER_FILES := $(shell go list -f '{{join .Deps "\n"}}' ./cmd/drivers/kvm/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')
6161

6262
# extra env vars that need to be set in cross build container
6363
MINIKUBE_ENV_darwin_DOCKER := CC=o64-clang CXX=o64-clang++
@@ -70,7 +70,7 @@ KUBE_CROSS_DOCKER_CMD := docker run -w /go/src/$(REPOPATH) --user $(shell id -u)
7070

7171
# $(call MINIKUBE_GO_BUILD_CMD, output file, OS)
7272
define MINIKUBE_GO_BUILD_CMD
73-
$(MINIKUBE_ENV_$(2)) go build -tags "$(MINIKUBE_BUILD_TAGS)" --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
73+
GOOS=$(2) go build -tags "$(MINIKUBE_BUILD_TAGS)" --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
7474
endef
7575

7676
ifeq ($(BUILD_IN_DOCKER),y)
@@ -179,7 +179,7 @@ integration-versioned: out/minikube
179179
go test -v -test.timeout=30m $(REPOPATH)/test/integration --tags="$(MINIKUBE_INTEGRATION_BUILD_TAGS) versioned" $(TEST_ARGS)
180180

181181
.PHONY: test
182-
test: pkg/minikube/assets/assets.go
182+
test: $(shell $(MINIKUBE_TEST_FILES)) pkg/minikube/assets/assets.go
183183
./test.sh
184184

185185
.PHONY: gopath
@@ -188,8 +188,8 @@ ifneq ($(GOPATH)/src/$(REPOPATH),$(PWD))
188188
$(warning Warning: Building minikube outside the GOPATH, should be $(GOPATH)/src/$(REPOPATH) but is $(PWD))
189189
endif
190190

191-
pkg/minikube/assets/assets.go: out/localkube $(GOPATH)/bin/go-bindata $(shell find deploy/addons -type f)
192-
$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets ./out/localkube deploy/addons/...
191+
pkg/minikube/assets/assets.go: $(GOPATH)/bin/go-bindata $(shell find deploy/addons -type f)
192+
$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets deploy/addons/...
193193

194194
$(GOPATH)/bin/go-bindata:
195195
GOBIN=$(GOPATH)/bin go get github.com/jteeuwen/go-bindata/...
@@ -255,9 +255,9 @@ out/minikube-installer.exe: out/minikube-windows-amd64.exe
255255

256256
out/docker-machine-driver-hyperkit: $(shell $(HYPERKIT_FILES))
257257
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
258-
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_darwin_DOCKER) $(MINIKUBE_ENV_darwin) go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit'
258+
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_darwin_DOCKER) GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit'
259259
else
260-
$(MINIKUBE_ENV_darwin) go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
260+
GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
261261
endif
262262

263263
.PHONY: install-hyperkit-driver

pkg/minikube/bootstrapper/localkube/localkube.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,10 @@ func (lk *LocalkubeBootstrapper) UpdateCluster(config bootstrapper.KubernetesCon
116116
var err error
117117

118118
//add url/file/bundled localkube to file list
119-
if localkubeURIWasSpecified(config) && config.KubernetesVersion != constants.DefaultKubernetesVersion {
120-
lCacher := localkubeCacher{config}
121-
localkubeFile, err = lCacher.fetchLocalkubeFromURI()
122-
if err != nil {
123-
return errors.Wrap(err, "Error updating localkube from uri")
124-
}
125-
} else {
126-
localkubeFile = assets.NewBinDataAsset("out/localkube", "/usr/local/bin", "localkube", "0777")
119+
lCacher := localkubeCacher{config}
120+
localkubeFile, err = lCacher.fetchLocalkubeFromURI()
121+
if err != nil {
122+
return errors.Wrap(err, "Error updating localkube from uri")
127123
}
128124
copyableFiles = append(copyableFiles, localkubeFile)
129125

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ COV_TMP_FILE=coverage_tmp.txt
3232
# Run "go test" on packages that have test files. Also create coverage profile
3333
echo "Running go tests..."
3434
cd ${GOPATH}/src/${REPO_PATH}
35-
rm -f out/$COV_FILE
35+
rm -f out/$COV_FILE || true
3636
echo "mode: count" > out/$COV_FILE
3737
for pkg in $(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...); do
3838
go test -tags "container_image_ostree_stub containers_image_openpgp" -v $pkg -covermode=count -coverprofile=out/$COV_TMP_FILE

0 commit comments

Comments
 (0)