1. minikube 离线安装
下载离线镜像包
以下离线包支持 kubernetes v1.17.0~ v1.24.0
挂载离线包到 registry docker run tmp-registry
指定本地镜像参考
准备离线镜像( K8s 版本 v1.20.13)
minikube cache add calico/cni:v3.14.1
minikube cache add calico/kube-controllers:v3.14.1 calico/node:v3.14.1
minikube cache add calico/pod2daemon-flexvol:v3.14.1
minikube cache add gcr.io/k8s-minikube/storage-provisioner:v5
minikube cache add k8s.gcr.io/coredns:1.7.0 k8s.gcr.io/etcd:3.4.13-0
minikube cache add k8s.gcr.io/kube-apiserver:v1.20.13
minikube cache add k8s.gcr.io/kube-controller-manager:v1.20.13
minikube cache add k8s.gcr.io/kube-proxy:v1.20.13 k8s.gcr.io/kube-scheduler:v1.20.13
minikube cache add k8s.gcr.io/ingress-nginx/controller:v0.47.0
minikube cache add docker.io/jettech/kube-webhook-certgen:v1.5.1
minikube cache add docker.io/jettech/kube-webhook-certgen:v1.5.1
minikube cache add k8s.gcr.io/ingress-nginx/controller:v0.44.0
minikube cache add docker.io/jettech/kube-webhook-certgen:v1.5.1
minikube cache add docker.io/kubernetesui/dashboard:v2.1.0
minikube cache add docker.io/kubernetesui/metrics-scraper:v1.0.4
制作离线缓存文件
cd /root/.minikube/
tar czvf minikube-cache.tar.gz cache
复制并解压到目标 minikube 机器
chmod +x minikube && sudo mv minikube /usr/local/bin/
tar xf minikube-cache.tar.gz -C /root/.minikube/
基于缓存的镜像启动
minikube start \
--kubernetes-version v1.20.13 \
--vm-driver=none \
--cache-images=true \
--cni=calico \
--extra-config=kubelet.cgroup-driver=systemd \
--addons=ingress
查看集群 pod 状态
cp /root/.minikube/cache/linux/v1.20.13/kubectl /usr/local/bin/kubectl
kubectl get pod -A
2. 离线使用
minikube has built-in support for caching downloaded resources into $MINIKUBE_HOME/cache
. Here are the important file locations:
minikube内置了对缓存下载资源到' $MINIKUBE_HOME/cache '的支持。以下是重要的文件位置:
~/.minikube/cache
- Top-level folder~/.minikube/cache/iso
- VM ISO image. Typically updated once per major minikube release.~/.minikube/cache/images
- Docker images used by Kubernetes.~/.minikube/cache/<version>
- Kubernetes binaries, such askubeadm
andkubelet
2.1. Kubernetes image cache
NOTE: the none
driver caches images directly into Docker rather than a separate disk cache.
minikube start
caches all required Kubernetes images by default. This default may be changed by setting --cache-images=false
. These images are not displayed by the minikube cache
command.
2.2. Sharing the minikube cache
For offline use on other hosts, one can copy the contents of ~/.minikube/cache
. As of the v1.0 release, this directory contains 685MB of data:
cache/iso/minikube-v1.0.0.iso
cache/images/gcr.io/k8s-minikube/storage-provisioner_v1.8.1
cache/images/k8s.gcr.io/k8s-dns-sidecar-amd64_1.14.13
cache/images/k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64_1.14.13
cache/images/k8s.gcr.io/kubernetes-dashboard-amd64_v1.10.1
cache/images/k8s.gcr.io/kube-scheduler_v1.14.0
cache/images/k8s.gcr.io/coredns_1.3.1
cache/images/k8s.gcr.io/kube-controller-manager_v1.14.0
cache/images/k8s.gcr.io/kube-apiserver_v1.14.0
cache/images/k8s.gcr.io/pause_3.1
cache/images/k8s.gcr.io/etcd_3.3.10
cache/images/k8s.gcr.io/kube-addon-manager_v9.0
cache/images/k8s.gcr.io/k8s-dns-kube-dns-amd64_1.14.13
cache/images/k8s.gcr.io/kube-proxy_v1.14.0
cache/v1.14.0/kubeadm
cache/v1.14.0/kubelet
If any of these files exist, minikube will use copy them into the VM directly rather than pulling them from the internet.