Originally published at 狗和留美者不得入内. You can comment here or there.
跑minikube start
老是被卡住,得到如以下的结果
yunhenyanshideMacBook-Pro:~ yunhenyanshi$ minikube start 😄 minikube v1.2.0 on darwin (amd64) 💡 Tip: Use 'minikube start -p ' to create a new cluster, or 'minikube delete' to delete this one. 🏃 Re-using the currently running virtualbox VM for "minikube" ... ⌛ Waiting for SSH access ... 🐳 Configuring environment for Kubernetes v1.15.0 on Docker 18.09.6 E0805 20:53:39.879197 55701 start.go:403] Error caching images: Caching images for kubeadm: caching images: caching image /Users/yunhenyanshi/.minikube/cache/images/k8s.gcr.io/k8s-dns-kube-dns-amd64_1.14.13: fetching remote image: Get https://k8s.gcr.io/v2/: dial tcp 64.233.187.82:443: i/o timeout ❌ Unable to load cached images: loading cached images: loading image /Users/yunhenyanshi/.minikube/cache/images/k8s.gcr.io/kube-controller-manager_v1.15.0: stat /Users/yunhenyanshi/.minikube/cache/images/k8s.gcr.io/kube-controller-manager_v1.15.0: no such file or directory 🔄 Relaunching Kubernetes v1.15.0 using kubeadm ...
查百度只得到加个参数
minikube start --registry-mirror=https://registry.docker-cn.com
也不解决这个问题。查了半天,试了半天还是不行,终于灵活起来了,
localhost:k8s.gcr.io yunhenyanshi$ minikube --help Minikube is a CLI tool that provisions and manages single-node Kubernetes clusters optimized for development workflows. Usage: minikube [command] Available Commands: addons Modify minikube's kubernetes addons cache Add or delete an image from the local cache. completion Outputs minikube shell completion for the given shell (bash or zsh) config Modify minikube config dashboard Access the kubernetes dashboard running within the minikube cluster delete Deletes a local kubernetes cluster docker-env Sets up docker env variables; similar to '$(docker-machine env)' help Help about any command ip Retrieves the IP address of the running cluster kubectl Run kubectl logs Gets the logs of the running instance, used for debugging minikube, not user code mount Mounts the specified directory into minikube profile Profile gets or sets the current minikube profile service Gets the kubernetes URL(s) for the specified service in your local cluster ssh Log into or run a command on a machine with SSH; similar to 'docker-machine ssh' ssh-key Retrieve the ssh identity key path of the specified cluster start Starts a local kubernetes cluster status Gets the status of a local kubernetes cluster stop Stops a running local kubernetes cluster tunnel tunnel makes services of type LoadBalancer accessible on localhost update-check Print current and latest version number update-context Verify the IP address of the running cluster in kubeconfig. version Print the version of minikube Flags: --alsologtostderr log to standard error as well as files -b, --bootstrapper string The name of the cluster bootstrapper that will set up the kubernetes cluster. (default "kubeadm") -h, --help help for minikube --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files -p, --profile string The name of the minikube VM being used. This can be modified to allow for multiple minikube instances to be run independently (default "minikube") --stderrthreshold severity logs at or above this threshold go to stderr (default 2) -v, --v Level log level for V logs --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging Use "minikube [command] --help" for more information about a command. localhost:k8s.gcr.io yunhenyanshi$ minikube start -h Starts a local kubernetes cluster using VM. This command assumes you have already installed one of the VM drivers: virtualbox/parallels/vmwarefusion/kvm/xhyve/hyperv. Usage: minikube start [flags] Flags: --apiserver-ips ipSlice A set of apiserver IP Addresses which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default []) --apiserver-name string The apiserver name which is used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default "minikubeCA") --apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine --apiserver-port int The apiserver listening port (default 8443) --cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --vm-driver=none. (default true) --container-runtime string The container runtime to be used (docker, crio, containerd) (default "docker") --cpus int Number of CPUs allocated to the minikube VM (default 2) --cri-socket string The cri socket path to be used --disable-driver-mounts Disables the filesystem mounts provided by the hypervisors (vboxfs, xhyve-9p) --disk-size string Disk size allocated to the minikube VM (format: [], where unit = b, k, m or g) (default "20g") --dns-domain string The cluster dns domain name used in the kubernetes cluster (default "cluster.local") --docker-env stringArray Environment variables to pass to the Docker daemon. (format: key=value) --docker-opt stringArray Specify arbitrary flags to pass to the Docker daemon. (format: key=value) --download-only If true, only download and cache files for later use - don't install or start anything. --enable-default-cni Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with "--network-plugin=cni" --extra-config ExtraOption A set of key=value pairs that describe configuration that may be passed to different components. The key should be '.' separated, and the first part before the dot is the component to apply the configuration to. Valid components are: kubelet, kubeadm, apiserver, controller-manager, etcd, proxy, scheduler Valid kubeadm parameters: ignore-preflight-errors, dry-run, kubeconfig, kubeconfig-dir, node-name, cri-socket, experimental-upload-certs, certificate-key, rootfs, pod-network-cidr --feature-gates string A set of key=value pairs that describe feature gates for alpha/experimental features. --gpu Enable experimental NVIDIA GPU support in minikube (works only with kvm2 driver on Linux) -h, --help help for start --hidden Hide the hypervisor signature from the guest in minikube (works only with kvm2 driver on Linux) --host-only-cidr string The CIDR to be used for the minikube VM (only supported with Virtualbox driver) (default "192.168.99.1/24") --hyperkit-vpnkit-sock string Location of the VPNKit socket used for networking. If empty, disables Hyperkit VPNKitSock, if 'auto' uses Docker for Mac VPNKit connection, otherwise uses the specified VSock. --hyperkit-vsock-ports strings List of guest VSock ports that should be exposed as sockets on the host (Only supported on with hyperkit now). --hyperv-virtual-switch string The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver) --image-mirror-country string Country code of the image mirror to be used. Leave empty to use the global one. For Chinese mainland users, set it to cn --image-repository string Alternative image repository to pull docker images from. This can be used when you have limited access to gcr.io. Set it to "auto" to let minikube decide one for you. For Chinese mainland users, you may use local gcr.io mirrors such as registry.cn-hangzhou.aliyuncs.com/google_containers --insecure-registry strings Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added. --iso-url string Location of the minikube iso (default "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso") --keep-context This will keep the existing kubectl context and will create a minikube context. --kubernetes-version string The kubernetes version that the minikube VM will use (ex: v1.2.3) (default "v1.15.0") --kvm-network string The KVM network name. (only supported with KVM driver) (default "default") --memory int Amount of RAM allocated to the minikube VM in MB (default 2048) --mount This will start the mount daemon and automatically mount files into minikube --mount-string string The argument to pass the minikube mount command on start (default "/Users:/minikube-host") --network-plugin string The name of the network plugin --nfs-share strings Local folders to share with Guest via NFS mounts (Only supported on with hyperkit now) --nfs-shares-root string Where to root the NFS Shares (defaults to /nfsshares, only supported with hyperkit now) (default "/nfsshares") --no-vtx-check Disable checking for the availability of hardware virtualization before the vm is started (virtualbox) --registry-mirror strings Registry mirrors to pass to the Docker daemon --service-cluster-ip-range string The CIDR to be used for service cluster IPs. (default "10.96.0.0/12") --uuid string Provide VM UUID to restore MAC address (only supported with Hyperkit driver). --vm-driver string VM driver is one of: [virtualbox parallels vmwarefusion kvm xhyve hyperv hyperkit kvm2 vmware none] (default "virtualbox") --xhyve-disk-driver string The disk driver to use [ahci-hd|virtio-blk] (only supported with xhyve driver) (default "ahci-hd") Global Flags: --alsologtostderr log to standard error as well as files -b, --bootstrapper string The name of the cluster bootstrapper that will set up the kubernetes cluster. (default "kubeadm") --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files -p, --profile string The name of the minikube VM being used. This can be modified to allow for multiple minikube instances to be run independently (default "minikube") --stderrthreshold severity logs at or above this threshold go to stderr (default 2) -v, --v Level log level for V logs --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging localhost:k8s.gcr.io yunhenyanshi$
我这傻逼没早想到在终端里的minikube
弄个help
,毕竟这样说已被搜索结果所建议的--registry-mirror=https://registry.docker-cn.com
所暗示,也没想到查了”mainland china minikube”之类的,英语在谷歌查这个能把我带到
https://www.kkito.cn/posts/2019-05-29/kubernetes%E5%AD%A6%E4%B9%A01-%E4%BD%BF%E7%94%A8minikube%E5%AE%89%E8%A3%85kubectl.html以及在百度上搜到的https://www.jianshu.com/p/ba7dd2d04ae3所包含的在github上的minikube的源代码对对应的参数的实现及解释,其为
startCmd.Flags().String(imageRepository, "", "Alternative image repository to pull docker images from. This can be used when you have limited access to gcr.io. For Chinese mainland users, you may use local gcr.io mirrors such as registry.cn-hangzhou.aliyuncs.com/google_containers")
好多我查到的结果(它们好多都是2017-8年的吧)只包含--registry-mirror=https://registry.docker-cn.com
而非关键的--image-repository=registry.cn-hangzhou.a
,这才是问题解决的根本。
yunhenyanshideMacBook-Pro:k8s.gcr.io yunhenyanshi$ minikube start --vm-driver=none --registry-mirror=https://registry.docker-cn.com --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers 😄 minikube v1.2.0 on darwin (amd64) ✅ using image repository registry.cn-hangzhou.aliyuncs.com/google_containers ⚠️ Ignoring --vm-driver=none, as the existing "minikube" VM was created using the virtualbox driver. ⚠️ To switch drivers, you may create a new VM using `minikube start -p --vm-driver=none` ⚠️ Alternatively, you may delete the existing VM using `minikube delete -p minikube` 🏃 Re-using the currently running virtualbox VM for "minikube" ... ⌛ Waiting for SSH access ... 🐳 Configuring environment for Kubernetes v1.15.0 on Docker 18.09.6 🔄 Relaunching Kubernetes v1.15.0 using kubeadm ... 🤹 Configuring local host environment ... ⚠️ The 'none' driver provides limited isolation and may reduce system security and reliability. ⚠️ For more information, see: 👉 https://github.com/kubernetes/minikube/blob/master/docs/vmdriver-none.md ⚠️ kubectl and minikube configuration will be stored in /Users/yunhenyanshi ⚠️ To use kubectl or minikube commands as your own user, you may ⚠️ need to relocate them. For example, to overwrite your own settings: ▪ sudo mv /Users/yunhenyanshi/.kube /Users/yunhenyanshi/.minikube $HOME ▪ sudo chown -R $USER $HOME/.kube $HOME/.minikube 💡 This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true ⌛ Verifying: apiserver proxy etcd scheduler controller dns 🏄 Done! kubectl is now configured to use "minikube" yunhenyanshideMacBook-Pro:k8s.gcr.io yunhenyanshi$
希望我这个博文得到一些点击,帮一些中国的程序员节省一些时间!
若被以下的iso下载卡住,那是因为它在试从谷歌的https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso下载,先下载它,再将它复制到~/.minikube/cache/iso
yunhenyanshideMacBook-Pro:kubernetes-ci-cd yunhenyanshi$ minikube start --registry-mirror=https://registry.docker-cn.com --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers 😄 minikube v1.2.0 on darwin (amd64) ✅ using image repository registry.cn-hangzhou.aliyuncs.com/google_containers 💿 Downloading Minikube ISO ..
然后(在不翻墙的情况下)跑
minikube start --registry-mirror=https://registry.docker-cn.com --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
可能得试个一俩三次,这不太稳定。