Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache images in minikube #1881

Merged
merged 9 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 176 additions & 8 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ KUBE_CROSS_DOCKER_CMD := docker run -w /go/src/$(REPOPATH) --user $(shell id -u)

# $(call MINIKUBE_GO_BUILD_CMD, output file, OS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file perms changed on here too to 755.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

define MINIKUBE_GO_BUILD_CMD
$(MINIKUBE_ENV_$(2)) go build --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
$(MINIKUBE_ENV_$(2)) go build -tags "container_image_ostree_stub containers_image_openpgp" --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
endef

ifeq ($(BUILD_IN_DOCKER),y)
Expand Down Expand Up @@ -113,7 +113,7 @@ endif

.PHONY: e2e-%-amd64
e2e-%-amd64:
GOOS=$* GOARCH=amd64 go test -c k8s.io/minikube/test/integration --tags=integration -o out/$@
GOOS=$* GOARCH=amd64 go test -c k8s.io/minikube/test/integration --tags="integration container_image_ostree_stub containers_image_openpgp" -o out/$@

e2e-windows-amd64.exe: e2e-windows-amd64
mv $(BUILD_DIR)/e2e-windows-amd64 $(BUILD_DIR)/e2e-windows-amd64.exe
Expand Down
1 change: 1 addition & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ assumes you have already installed one of the VM drivers: virtualbox/vmwarefusio
}

func runStart(cmd *cobra.Command, args []string) {
go machine.CacheImagesForBootstrapper(viper.GetString(cmdcfg.Bootstrapper))
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
Expand Down
3 changes: 3 additions & 0 deletions deploy/addons/kube-dns/kube-dns-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ spec:
containers:
- name: kubedns
image: gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.4
imagePullPolicy: IfNotPresent
resources:
# TODO: Set memory limits when we've profiled the container for large
# clusters, then set request = limit to keep this container in
Expand Down Expand Up @@ -96,6 +97,7 @@ spec:
mountPath: /kube-dns-config
- name: dnsmasq
image: gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.4
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /healthcheck/dnsmasq
Expand Down Expand Up @@ -134,6 +136,7 @@ spec:
mountPath: /etc/k8s/dns/dnsmasq-nanny
- name: sidecar
image: gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.4
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /metrics
Expand Down
13 changes: 5 additions & 8 deletions hack/jenkins/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox.yaml testda
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/pvc.yaml testdata/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox-mount-test.yaml testdata/

export MINIKUBE_WANTREPORTERRORPROMPT=False
sudo ./out/minikube-${OS_ARCH} delete || true
./out/minikube-${OS_ARCH} delete || true

# Add the out/ directory to the PATH, for using new drivers.
export PATH="$(pwd)/out/":$PATH

Expand Down Expand Up @@ -70,17 +74,12 @@ if [ -e out/docker-machine-driver-hyperkit ]; then
sudo chmod u+s out/docker-machine-driver-hyperkit || true
fi

MINIKUBE_WANTREPORTERRORPROMPT=False sudo ./out/minikube-${OS_ARCH} delete \
|| MINIKUBE_WANTREPORTERRORPROMPT=False ./out/minikube-${OS_ARCH} delete \
|| true
sudo rm -rf $HOME/.minikube || true
sudo rm -rf $HOME/.kube || true

# See the default image
./out/minikube-${OS_ARCH} start -h | grep iso

# see what driver we are using
which docker-machine-driver-${VM_DRIVER} || true
tree ~/.minikube || true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "find ~/.minikube"? Not all systems have tree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up putting it on the build slaves, find is probably simpler


# Allow this to fail, we'll switch on the return code below.
set +e
Expand All @@ -94,8 +93,6 @@ sudo cat $KUBECONFIG
MINIKUBE_WANTREPORTERRORPROMPT=False sudo ./out/minikube-${OS_ARCH} delete \
|| MINIKUBE_WANTREPORTERRORPROMPT=False ./out/minikube-${OS_ARCH} delete \
|| true
sudo rm -rf $HOME/.minikube || true
sudo rm -rf $HOME/.kube || true

if [[ $result -eq 0 ]]; then
status="success"
Expand Down
9 changes: 8 additions & 1 deletion pkg/minikube/bootstrapper/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ limitations under the License.

package bootstrapper

import "k8s.io/minikube/pkg/util"
import (
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/util"
)

// Bootstrapper contains all the methods needed to bootstrap a kubernetes cluster
type Bootstrapper interface {
Expand Down Expand Up @@ -44,3 +47,7 @@ type KubernetesConfig struct {
const (
BootstrapperTypeLocalkube = "localkube"
)

var CachedImagesForBootstrapper = map[string][]string{
BootstrapperTypeLocalkube: constants.LocalkubeCachedImages,
}
4 changes: 4 additions & 0 deletions pkg/minikube/bootstrapper/localkube/localkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/sshutil"

"github.com/docker/machine/libmachine"
Expand Down Expand Up @@ -105,6 +106,9 @@ func (lk *LocalkubeBootstrapper) RestartCluster(kubernetesConfig bootstrapper.Ku
}

func (lk *LocalkubeBootstrapper) UpdateCluster(config bootstrapper.KubernetesConfig) error {
// Make best effort to load any cached images
go machine.LoadImages(lk.cmd, constants.LocalkubeCachedImages, constants.ImageCacheDir)

copyableFiles := []assets.CopyableFile{}
var localkubeFile assets.CopyableFile
var err error
Expand Down
Loading