Skip to content

Fasten Minikube by Downloading the Cache

Yi Wang edited this page Jun 4, 2020 · 5 revisions

The Short Version

For developers who have a slow Internet connection to Google Cloud, but wants to run a Kubernetes (v1.18.3) cluster locally on a Linux host (VM or bare metal), you can use our mirror site.

  1. Download and install minikube

    curl -Lo minikube http://cdn.sqlflow.tech/minikube/minikube-linux-1.11.0
    chmod +x minikube
    sudo mv minikube /usr/local/bin/
  2. Download dependencies into the cache directory.

    mkdir -p $HOME/.minikube/cache/preloaded-tarball
    cd $HOME/.minikube/cache/preloaded-tarball
    curl -LO http://cdn.sqlflow.tech/minikube/v1.18.3/cache/preloaded-tarball/preloaded-images-k8s-v3-v1.18.3-docker-overlay2-amd64.tar.lz4
  3. Run the Kubernetes cluster.

    minikube start --vm-driver=docker
  4. To verify the cluster is running, you need kubectl.

    cd ~
    curl -LO http://cdn.sqlflow.tech/minikube/v1.18.3/cache/linux/v1.18.3/kubectl
    chmod +x kubectl
    sudo mv kubectl /usr/local/bin

    then, you can run the following command to inquiry (virtual) nodes in the local cluster:

    kubectl get nodes

The Longer Version

Minikube is important for developers to run a Kubernetes cluster locally. SQLFlow developers and end-users use it to run local deployment of the SQLFlow service.

Download and Install

At the time of writing, the most recent version of minikube is 1.11.0, which you can download from its official distribution site

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

or a mirror site

curl -Lo minikube http://cdn.sqlflow.tech/minikube/minikube-linux-1.11.0

The installation is simply moving it to a directory in the PATH environment variable.

chmod +x minikube
sudo mv minikube /usr/local/bin

Run a Local Cluster

Assuming that you are working in a Linux host (VM or bare metal) with Docker installed, you can start and run your local Kubernetes cluster using the following command.

minikube config set memory 8192  # Use more memory than the default.
minikube config set cpus 4       # Use more CPUs than the default.
minikube set vm-driver docker    # Use Docker containers than VirtualBox VMs.
minikube start                   # Start and run the local Kubernetes cluster.

Download and Cache Dependencies

However, the above process could be slow as minikube downloads necessary Docker images and other necessary files. If you have a slow Internet connection to the official distribution sites of the above files, you can alternatively download these files from a mirror site (if there is any) into your $HOME/.minikube/cache directory before running the minikube start command. This works because minikube tries to find cached files before downloading. An example checking is as follows:

https://github.com/kubernetes/minikube/blob/ecaaeaf99c6aa6fd8d4229b9b754854abc506159/pkg/minikube/download/preload.go#L100-L105

For the special case that

  • you want to run Kubernetes 1.18.3
  • on a Linux host (VM or bare metal)
  • with Docker installed

you can create the following directory hierarchy and download the required files from a mirror.

$HOME/.minikube/cache/
└── preloaded-tarball
    └── preloaded-images-k8s-v3-v1.18.3-docker-overlay2-amd64.tar.lz4

SQLFlow developers can download the above files from our development mirror.

mkdir -p $HOME/.minikube/cache/preloaded-tarball
cd $HOME/.minikube/cache/preloaded-tarball

export CACHE_SITE="http://cdn.sqlflow.tech/minikube/v1.18.3/cache"
curl -LO $CACHE_SITE/preloaded-tarball/preloaded-images-k8s-v3-v1.18.3-docker-overlay2-amd64.tar.lz4