introduce

Minikube is a set of tools provided by K8S for developers to run K8S on personal computers. The implementation is written by Go language, by calling the virtualization manager, to create a single node cluster running in the virtual machine.

Note: As can be seen here, there is no limit to the number of nodes for the basic functionality of a K8S cluster. Only one node can also create a cluster.

When you are actually developing and playing with Kubernetes, you may encounter network access problems or other bugs that prevent many of your friends from experimenting with Minikube. So by writing this blog post, I want you to avoid a few detours. Ali Cloud provides a modified version of Minikube, you can obtain Docker image and configuration from ali Cloud image address.

Pit a physical count

  1. unable to cache ISO: connection failed because connected host has failed to respond.

    The terminal displays an error message:

    Minikube start o minikube V0.35.0 on Windows (AMD64) > Creating Virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB)... @ Downloading Minikube ISO ... ! Unable to start the VM: Unable to cache the ISO: https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: failed to download: failed to download to temp file: download failed: 5 error(s) occurred : * Temporary download error: Get https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: dial TCP 216.58.207.144:443: connectex: A connection attempt failed because the connected party did no t properly respond after a period of time, or established connection failed because connected host has failed to respond. * Temporary download error: Get https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: dial TCP 216.58.207.144:443: connectex: A connection attempt failed because the connected party did no t properly respond after a period of time, or established connection failed because connected host has failed to respond. * Temporary download error: Get https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: dial TCP 216.58.207.144:443: connectex: A connection attempt failed because the connected party did no t properly respond after a period of time, or established connection failed because connected host has failed to respond. * Temporary download error: Get https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: dial TCP 216.58.207.144:443: connectex: A connection attempt failed because the connected party did no t properly respond after a period of time, or established connection failed because connected host has failed to respond. * Temporary download error: Get https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: dial TCP 216.58.207.144:443: connectex: A connection attempt failed because the connected party did no t properly respond after a period of time, or established connection failed because connected host has failed to respond.Copy the code

    Error: The Minikube ISO file cannot be downloaded from the Internet.

    Solution: Change the IP address of the mirror to a domestic resource to resolve network errors.

  2. Minikube doesn’t run on VirtualBox

    The terminal displays an error message:

    Minikube start ๐Ÿ˜„ minikube V1.0.1 on Linux (AMD64) ๐Ÿคน Downloading Kubernetes v1.14.1 imagesinthe background ... ๐Ÿ”ฅ Creating Virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB)... ๐Ÿ’ฃ Unable to start VM: create: creating: Unable to start the VM: /usr/bin/VBoxManage startvm minikube --type headless failed: VBoxManage: error: The virtual machine'minikube' has terminated unexpectedly during startup with exitcode 1 (0x1) VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, Interface IMachine ๐Ÿ˜ฟ Sorry that minikube is crashed. If this was unexpected, we would love to hear from you: ๐Ÿ‘‰ https://github.com/kubernetes/minikube/issues/newCopy the code

    Vt-x/AMD-V virtualization is disabled on all cpus.

    Solution: VT-X/AMD-V virtualization must be enabled in the BIOS.

    Reference: jingyan.baidu.com/article/fc0…

  3. [MACHINE_DOES_NOT_EXST] Error getting state for host: machine does not exist

    The terminal reported an error message. Procedure

    [sudo] James' password: ๐Ÿ˜„ minikube V1.2.0 on Linux (AMD64) โš ๏ธ Please don't run minikube as root or with 'sudo' privileges. It isn'T necessary. โœ… using image repository registry.cn-hangzhou.aliyuncs.com/google_containers ๐Ÿ’ก Tip: Use'minikube start -p <name>' to create a new cluster, or 'minikube delete'To delete this one. E0722 14:57:51.637843 5215 start.go:559] StartHost: Error getting stateforHost: Machine does not exist ๐Ÿ’ฃ Unable to start VM โŒ Error: [MACHINE_DOES_NOT_EXST] Error getting stateforHost: Machine does not exist ๐Ÿ’ก Advice: Run'minikube delete'To delete the stale VM โ‰ ๏ธ Related issues: a forced the https://github.com/kubernetes/minikube/issues/3864 ๐Ÿ˜ฟ If the above advice does nothelp, please letUs know: ๐Ÿ‘‰ https://github.com/kubernetes/minikube/issues/newCopy the code

    Error cause: The VM has been used

    Solutions:minikute delete

Note:

  • This article has been updated to Minikube V1.2.0 /Kubernetes V1.15 +

  • To update minikube, you need to update the minikube installation package

    • minikube deleteDelete an existing VIRTUAL machine~/.minikubeDirectory cache files
    • Recreate the minikube environment
  • Docker community edition also provides for Mac and Windows users Kubernetes development environment support yq.aliyun.com/articles/50… , you can try it

configuration

A prerequisite for

  • Install kubectl

Minikube supports different drivers on different operating systems

  • macOS
    • Xhyve Driver, VirtualBox or VMware Fusion
  • Linux
    • VirtualBox or KVM
    • NOTE:Minikube also support--vm-driver=noneOption to run Kubernetes components on the machine, which requires Docker installed on the machine. Executes when using none drivers prior to version 0.27minikube deleteCommand will remove the /data directory, please note thatProblem specification; In addition, the None driver runs an insecure API Server, which is a security risk and is not recommended to be installed in a personal work environment.
  • Windows
    • VirtualBox or Hyper-V – see below

Note:

  • Because Minikube has multiplexed docker-machine, the corresponding VirtualBox and VMware Fusion drivers are already supported in its software package
  • Vt-x/AMD-V virtualization must be enabled in the BIOS
  • On Windows, if Hyper-V is enabled, VirtualBox is not supported

Kubernetes + 1.14 release

We provide the latest Minikube modified version of the file, you can download directly to use

Mac OSX

The curl - Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.2.0/minikube-darwin-amd64 && chmod  +x minikube && sudo mv minikube /usr/local/bin/
Copy the code

Linux

The curl - Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.2.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Copy the code

Windows

Download the minikube-Windows-amd64. exe file and rename it minikube.exe

Build yourself

You can also get the corresponding project from Github and build it yourself.

Note: Golang development environment and Docker engine must be installed and configured locally

git clone https://github.com/AliyunContainerService/minikube
cdGit checkout aliyun-v1.2.0 make sudo cp out/minikube /usr/local/bin/
Copy the code

Start the

The default Minikube uses the VirtualBox driver to create the Kubernetes local environment

Minikube start --registry-mirror=https://registry.docker-cn.com ๐Ÿ˜„ minikube V1.2.0 on Linux (AMD64) โš ๏ธ Please don't run minikube as root or with 'sudo' privileges. It isn'T necessary. โœ… using image repository registry.cn-hangzhou.aliyuncs.com/google_containers ๐Ÿ”ฅ Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ... ๐Ÿณ you environmentforKubernetes v1.15.0 on Docker 18.09.6 ๐Ÿšœ Pulling images... ๐Ÿš€ Launching Kubernetes... โŒ› Verifying: Apiserver proxy ETCD Scheduler Controller DNS ๐Ÿ„ Done! kubectl is now configured to use"minikube"
Copy the code

Different versions of Kubernetes are supported

Install Kubernetes V1.12.1Minikube start --registry-mirror=https://registry.docker-cn.com --kubernetes-version v1.12.1Copy the code

Open the Kubernetes console

minikube dashboard

Copy the code

Users of a Hyper-V environment should first open the Hyper-V manager to create an external virtual switch,

After that, we can create the Kubernetes test environment based on Hyper-V with the following command

.\minikube.exe start --registry-mirror=https://registry.docker-cn.com --vm-driver="hyperv" --memory=4096 --hyperv-virtual-switch="MinikubeSwitch"

Copy the code

Note: Administrator rights are required to create hyper-V virtual machines

Minikube basic operation

Detect cluster status, run:

Kubectl cluster - info Kubernetes master is running at https://192.168.99.100:8443 KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use'kubectl cluster-info dump'.

Copy the code

In Ubuntu, the Minikube configuration file is in the following path

~/.minikube/machines/minikube/config.json

Viewing the contents of the configuration file:

kubectl config view apiVersion: v1 clusters: - cluster: certificate-authority: /home/james/.minikube/ca.crt server: https://192.168.99.100:8443 name: minikube contexts: - the context: cluster: minikube user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /home/james/.minikube/client.crt client-key: /home/james/.minikube/client.keyCopy the code

Check Node status:

Kubectl get Nodes NAME STATUS ROLES AGE VERSION minikube Ready master 11m V1.15.0Copy the code

Enter the Minikube virtual machine using SSH:

sudo minikube ssh

Copy the code
                         _             _            
            _         _ ( )           ( )           
  ___ ___  (_)  ___  (_)| |/') _ _ | | _ __ / '_ ` _ ` \ | | /'_ ` \ | | |, < () () |'_ ` \ /'__ ` \ | () () | | | | () | | | | | \ ` \ | (_) | | | _) (___)/(_) (_) (_) (_) (_) (_) (_) (_) (_) ` \ ___ /'(_ __ /'` \ $____)Copy the code

Stop running Kubernetes cluster:

$ minikube stop

Copy the code

Delete local Kubernetes cluster:

$ minikube delete

Copy the code

Open the Kubernetes console

Kubernete comes with a Web that allows you to manage clusters without interacting with the command line. The dashboard plug-in is installed and enabled by default on Minikube

$ minikube addons list

- addon-manager: enabled
- coredns: disabled
- dashboard: enabled
- default-storageclass: enabled
- efk: disabled
- freshpod: disabled
- heapster: disabled
- ingress: disabled
- kube-dns: enabled
- metrics-server: disabled
- registry: disabled
- registry-creds: disabled
- storage-provisioner: enabled

Copy the code

To open directly in the default browser, use:

$ minikube dashboard

Copy the code

Gets the URL of the dashboard

$minikube dashboard - the url http://192.168.39.117:30000Copy the code

Access the Kubernetes Dashboard by opening the URL on your favorite browser. For further reading, check out:

  • Hello Minikube series: kubernetes. IO/docs/tutori…

  • Minkube newbie guide: kubernetes. IO/docs/gettin…

Using Minikube

Minikube deploys Kubernetes using a local virtual machine environment, and its basic architecture is shown below.

Users use Minikube CLI to manage virtual machine Kubernetes environment, such as: start, stop, delete, get status, etc. Once the Minikube virtual machine is started, users can perform operations on the Kubernetes cluster using the familiar Kubectl CLI.

Now, explore the world of Kubernetes! : -)

Reference connection:

  • Computingforgeeks.com/how-to-inst…
  • www.virtualbox.org/wiki/Linux_…
  • Github.com/kubernetes/…
  • Stackoverflow.com/questions/5…
  • Github.com/AliyunConta…
  • Yq.aliyun.com/articles/22…
  • Jingyan.baidu.com/article/fc0…
  • Cr.console.aliyun.com/cn-hangzhou…
  • Github.com/kubernetes/…