🎓 What will you learn?

  • Under Windows installationminikubeDetailed steps of
  • Problems that may occur during installation and their solutions

Today we are going to do a bit of mischief installing Minikube on Windows

🙋 Egg Neil: What is minikuke?

Let’s take a look at the official introduction:

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

K8s is a tool that allows you to run a single node K8S cluster locally (usually for learning or experimental purposes)

🙋 Egg Neil: What is K8S?

Oh my god! Maybe this article isn’t for you.

Throw a link under the first to get to know yourself: kubernetes. IO/useful/docs/con…


On Windows, the recommended installation method is to run a Linux (such as CentOS) on the VIRTUAL machine and install minikube on Linux.

🙋 Egg Neil: Why is that?

First, this way you can export virtual machines, so you can easily share your work.

Second, in this isolated way, there is no “contamination” of the operating system.

Note: The following prerequisites must be met, if not, give up the struggle:

  • Windows 8 or later
  • Support virtualization

🙋 Egg Neil: How do I know if my machine supports virtualization?

Open the command line, run systeminfo, output the following OK:

# English version:
Hyper-V Requirements:     VM Monitor Mode Extensions: Yes
                          Virtualization Enabled In Firmware: Yes
                          Second Level Address Translation: Yes
                          Data Execution Prevention Available: Yes

# Chinese version:Hyper-v requirements: Vm monitor extended: Yes Virtualization is enabled in the firmware: Yes Secondary ADDRESS translation: Yes Data execution protection available: YesCopy the code

OK, let’s get started happily.

1. Install CentOS on the VM

VirtualBox download address: www.virtualbox.org/wiki/Downlo…

CentOS download address: www.centos.org/download/

CentOS 7.6 is used as an example. Why is that? Because I already downloaded this version on my computer

1.1 Creating a VM

  • Select Type:Linux and Version:Red Hat (64-bit)

  • Next, set the memory and hard disk size

Do not change the default value. Don’t be stingy with a hard drive of 15 gigabytes or more.

1.2 Installing disks, setting networks, and adjusting the number of cpus

  • Install the CentOS ISO file you downloaded

  • Example Set the vm network toBrided Adapter

🙋 Egg Neil: Why is that? Why not choose the default NAT

That’s a good question. Take a quick look at the difference between a NAT and a Bridged Adapter

  • NAT: The VM has no independent IP address. Therefore, the VM can access the host, but the host cannot access the VM
  • Bridged Adapter: A virtual machine has a separate IP address. Like other computers on the same LAN, the host and the virtual machine can access each other

In our scenario, we want to be able to access virtual machine services in the host, such as K8S Dashboard, so we choose Bridged Adapter

  • Set the number of cpus to 2 or more

🙋 Egg Neil: Why not one?

Don’t worry, I’ll explain it in due course.

1.3 install CentOS

Click Start to Start the VM.

Basically follow the instructions of the interface step by step operation. Here are some steps that require a little setup.

When you see the following screen, wait for a moment, each item automatically checked will turn to normal black.

Focus on two of them. For other items, you do not need to set the default value.

  • Item 1: INSTALLATION DESTINATION

Click in and select the hard disk to install

  • Item 2: NETWORK & HOST NAME

Click in to enable network connection

The next step can be taken as shown below

After clicking ROOT PASSWORD to set your PASSWORD, you can make a cup of coffee at this point.

It’s been a long time coming. Oh yeah!

Click Reboot

2. Start the SSHD service

🙋 Egg Neil: Isn’t it possible to operate on a virtual machine? What do you want to enable this service for?

Is that what you mean? You can try it yourself and see how difficult it is to use. You can’t cut the mouse, you can’t copy and paste, you can’t open multiple terminals, and so on.

Execute the following command

# systemctl start sshd
Copy the code

Now you can log in to CentOS using your favorite terminal tool, such as putty.

🙋 Egg Neil: Wait, what’s the IP again?

This is easy, use the ifconfig command to check. Ahhh ~ ~ ~

Oh, no. There’s not even an order.

Yum yum yum yum yum yum yum yum yum yum

Step 1: Check the package to which the command belongs:

# yum provides ifconfig
Copy the code

Step 2: Install the specified package

# yum install net-tools
Copy the code

OK, after installation you can use ifConfig to view the IP address of your virtual machine

3. Install the Docker

Because we are going to run the K8S components directly on the host (in this case, CentOS) instead of the VIRTUAL machine (i.e. start minikube with — vM-driver = None), we need to install Docker.

The reason for doing this is that it is difficult to run another virtual machine in a virtual machine.

As mentioned here — vM-driver = None, remember the step above to set the CPU to 2? The reason is that starting minikube with this parameter requires at least two cores.

To install and start the Docker service, run the following command

# curl -fsSL https://get.docker.com -o get-docker.sh
# sh get-docker.sh
# systemctl start docker
# systemctl enable docker
Copy the code

Again, verify:

# docker version
Copy the code

At this point, the docker version number installed is 19.03.5

4. Install kubectl

Kubectl is a command line tool for K8S, through which you can operate k8S clusters. The installation process is as follows:

# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
# chmod +x ./kubectl
# mv ./kubectl /usr/local/bin/kubectl
Copy the code

Let’s verify this:

# kubectl version --client
Copy the code

The installed kubectl version number is v1.17.3

5. Install and start minikube

Next comes the installation of the main character. Execute the following command and you’re done.

# curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube
# mkdir -p /usr/local/bin/
# install minikube /usr/local/bin/
Copy the code

Let’s verify that

# minikube version
Copy the code

The installed minikube version is V1.7.2

Then start:

# minikube start --vm-driver=none
Copy the code

🙋 Egg Neil: Started waiting for a long time also did not prompt success, see: VM is unable to access K8s.gcr. IO, you may need to configure a proxy or set –image-repository yesterday?

OK, according to the prompt information, it should be the domestic network problem. Let’s add another parameter to restart:

# minikube start --vm-driver=none --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
Copy the code

If there is no accident, it will start successfully. Let’s verify:

# minikube status
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Copy the code

6. Start the K8S Dashboard

Next, enable the Dashboard service, which will allow us to easily manage the K8S cluster through the interface:

# minikube dashboard
Copy the code

🙋 Egg Neil: Oh, not so smooth ah, did not successfully start again, error: /api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ is not accessible: Temporary Error: unexpected response code: 503

OK. Well, let’s try and find some clues by looking at the logs.

Check the pods status first

# kubectl get pods -A
Copy the code

We found that the pod status of Kubernetes-Dashboard is abnormal, then we can check the run log of this pod

# kubectl logs kubernetes-dashboard-79d9cd965-kj5ln -n kubernetes-dashboard
Copy the code

🙋 Egg Neal: Error message found: connect: no route to host

Yeah, local routing problem. After a lot of googling and trying, the solution was flush iptables with the following command:

# systemctl stop kubelet
# systemctl stop docker
# iptables --flush
# iptables -tnat --flush
# systemctl start kubelet
# systemctl start docker
Copy the code

Re-run minikube Dashboard to try to start.

🙋 Egg Neil: It started successfully. But how do you access Dashboard on a Windows host?

Stop the minikube dashboard command first, we will change to kubectl proxy to start the proxy service, so that outside can access k8S dashboard through IP

// where --address is the IP address of your virtual machine, available via ifconfig# kubectl proxy --port=8001 --accept-hosts='^. *' --address='192.168.31.136'
Copy the code

Visit address: http://192.168.31.136:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview? namespace=default

If you still cannot access Dashboard in the browser on your Windows host, you may have a CentOS port exposure problem. Add firewall rules as follows

# firewall-cmd --zone=public --add-port=8001/tcp --permanent
success
# firewall-cmd --reload
success
Copy the code

7. Since the start

/etc/rc.d/rc.local /etc/rc.d/rc.local /etc/rc.d/rc.local /etc/rc.d/rc.local /etc/rc.d/rc.local /etc/rc.d/rc.local

iptables --flush
iptables -tnat --flush

systemctl start docker
minikube start --vm-driver=none --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers

sleep 10
kubectl proxy --port=8001 --accept-hosts='^. *' --address='192.168.31.136'
Copy the code

After the CentOS is started each time, run the sh start-k8s.sh script

OK, done, ready to reboot and try.

I don’t have to spend any more time here, there is still a lot of space to optimize, if you can handle the system startup minikube, please tell me the solution

8. Export the VM

Finally, you can export your work and share it with your friends. Right-click the VM and choose Export to OCI from the shortcut menu. Menu, all the way to complete the export by default.


Finally, it’s done. Give it a thumbs up if you think it works. Bye bye!