@TOC


Resources | website

K8S and Docker are introduced

Installation scheme reference

K8S pull mirror solution

The official documentation

dockerHub

virtualization

Minikube Testing Tutorial


The installation guide


preface

The installation environment is a cloud server, Ubuntu18 system, can not take the form of virtual machine. The installation purpose is mainly for learning, so I chose Minikube.

Generate the environment version, after perhaps also will give a tutorial, but temporarily do not want to sacrifice their server swap partition, so forgive me.


Minikube

Minikube is a set of tools provided by the K8S authorities for developers to run the K8S on personal computers. By the Go language, by calling the hypervisor, create a running in the virtual machine in the single point cluster.


Install kubectl

The K8S cluster is a typical C/S architecture with an officially provided CLI tool called Kubectl. Try to keep the Kubectl version consistent with the K8S cluster version, or within a small version.

You can choose to specify a version, or you can choose to install the latest version directly.

This is the specified version:

The curl – LO, https://dl.k8s.io/release/v1.10.7/bin/linux/amd64/kubectl

The curl – LO, https://dl.k8s.io/v1.10.7/bin/linux/amd64/kubectl.sha256

echo “$(<kubectl.sha256) kubectl” | sha256sum –check -c



You may encounter the above error, but you can solve it as follows:

install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl


Install the latest version

The official documentation

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" curl -LO  "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256" echo "$(<kubectl.sha256) kubectl" | sha256sum --check

Install Minikube

Look first, don’t rush operation!

  • wget -O minikube https://github.com/kubernetes…
  • Chmod +x minikube grants execution permissions
  • sudo mv minikube /usr/local/bin/minikube
  • /usr/local/bin/minikube version

    minikube version: v0.28.2
# Install the latest: curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 chmod +x minikube sudo cp  ./minikube /usr/local/bin/minikube

To create a cluster using Minikube, simply execute Minikube Start

root@VM-0-11-ubuntu:/dbroot/NNroot# minikube start Starting local Kubernetes v1.10.0 cluster... Starting VM... E0709 16:38:40.267790 7566 start. Go :174] Error starting host: Error creating host: Error starting date: Error starting date: Error starting date: Error synchronizing Running precreate checks. : VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path.retry.e0709 16:38:40.268011 7566 start.go:180] Error starting host: Error creating host: Error executing step: Running precreate checks. : VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path ================================================================================ An error has occurred. Would you like to opt in to sending anonymized crash information to minikube to help prevent future errors? To opt out of these messages, run the command: minikube config set WantReportErrorPrompt false ================================================================================ Please enter your response [Y/n]: Y E0709 16:38:48.449769 Util. Go :151] Error uploading Error message: Post https://clouderrorreporting.googleapis.com/v1beta1/projects/k8s-minikube/events:report?key=AIzaSyACUwzG0dEPcl-eOgpDKnyKo UFgHdfoFuA: read TCP 172.17.0.11.41168-> 172.217.160.744:443: read: connection reset by peer

Error starting host: Error creating host: Error executing step: Running precreate checks.: VBoxManage not found.

Since you are not using a virtual machine, you should set the –vm-driver parameter of Minikube to None and have Docker installed correctly on your native machine. This approach does not require virtualization support. minikube start –vm-driver=none

root@VM-0-11-ubuntu:/dbroot/NNroot# minikube start --vm-driver=none Starting local Kubernetes v1.10.0 cluster... Starting VM... Getting VM IP address... Moving files into cluster... The complete range of podcasts and podcasts of the complete range of podcasts and podcasts Kubelet v1.10.0 settingup certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... E0709 17:15:00.768230 21541 start.go:300] Error Starting Cluster: kubeadm init error sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors= DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data- minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailabl e--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvaila ble--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvai lable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-erro rs=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI && sudo /usr/bin/kubeadm alpha phase addon kube-dns running command: : running command: sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors= DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data- minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailabl e--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvaila ble--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvai lable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-erro rs=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI && sudo /usr/bin/kubeadm alpha phase addon kube-dns output: [init] Using Kubernetes version: V1.10.0 [init] Using Authorization modes: [Node RBAC] [preflight] Running pre-flight checks. [preflight] The system verification failed. Printing the output from The verificatio n: KERNEL_VERSION: 4.15.0- generic CONFIG_NAMESPACES: enabled CONFIG_NET_NS: enabled CONFIG_PID_NS: enabled CONFIG_PID_NS: enabled CONFIG_NET_NS: enabled CONFIG_PID_NS: enabled enabled CONFIG_IPC_NS: enabled CONFIG_UTS_NS: enabled CONFIG_CGROUPS: enabled CONFIG_CGROUP_CPUACCT: enabled CONFIG_CGROUP_DEVICE: enabled CONFIG_CGROUP_FREEZER: enabled CONFIG_CGROUP_SCHED: enabled CONFIG_CPUSETS: enabled CONFIG_MEMCG: enabled CONFIG_INET: enabled CONFIG_EXT4_FS: enabled CONFIG_PROC_FS: enabled CONFIG_NETFILTER_XT_TARGET_REDIRECT: enabled (as module) CONFIG_NETFILTER_XT_MATCH_COMMENT: enabled (as module) CONFIG_OVERLAY_FS: enabled (as module) CONFIG_AUFS_FS: enabled (as module) CONFIG_BLK_DEV_DM: Enabled DOCKER_VERSION: 20.10.0 OS: Linux cgroups_CPU: enabled CGROUPS_CPUACCT: enabled CGROUPS_CPUSET: enabled CGROUPS_DEVICES: enabled CGROUPS_FREEZER: enabled CGROUPS_MEMORY: enabled [WARNING Hostname]: Hostname "minikube" could not be reached [WARNING hostname]: hostname "minikube" lookup minikube on 127.0.0.53:53: se rver misbehaving [WARNING FileExisting-crictl]: crictl not found in system path Suggestion: go get github.com/kubernetes-incubator/cri-tools/cmd/crictl Flag --admission-control has been deprecated, Use --enable-admission-plugins or --di sable-admission-plugins instead. Will be removed in a future version. [preflight]  Some fatal errors occurred: [ERROR SystemVerification]: unsupported docker version: 20.10.0 [preflight] If you know what you are doing, you can make a check non-fatal with '-- I gnore-preflight-errors=... ` : running command: sudo /usr/bin/kubeadm init --config /var/lib/kubeadm.yaml --ignore-preflight-errors= DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=DirAvailable--data- minikube --ignore-preflight-errors=Port-10250 --ignore-preflight-errors=FileAvailabl e--etc-kubernetes-manifests-kube-scheduler.yaml --ignore-preflight-errors=FileAvaila ble--etc-kubernetes-manifests-kube-apiserver.yaml --ignore-preflight-errors=FileAvai lable--etc-kubernetes-manifests-kube-controller-manager.yaml --ignore-preflight-erro rs=FileAvailable--etc-kubernetes-manifests-etcd.yaml --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI && sudo /usr/bin/kubeadm alpha phase addon kube-dns .: Exit status 2 E0709 17:15:30.768922 21541 util. Go :151] Error uploading Error message: : Post https://clouderrorreporting.googleapis.com/v1beta1/projects/k8s-minikube/events:report?key=AIzaSyACUwzG0dEPcl-eOgpDKnyKo UfGHdFofua: Dial TCP 172.217.160.74:443: I/O timeout

It seems that the Docker version is too high, it’s 20. Try to lower the version

sudo systemctl stop docker sudo apt-get remove -y docker-ce docker-ce-cli sudo apt-get update sudo apt-get install -y Docker - ce = easier. 09.4 ~ 3-0 ~ ubuntu - bionic docker - ce - cli = easier. 09.4 ~ 3-0 ~ ubuntu - bionic docker version
sudo systemctl stop docker sudo apt-get remove -y docker-ce docker-ce-cli sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt - the key to the add sudo apt - get the install - y docker - ce = 17.12.0 ~ ce - 0 ~ ubuntu Docker-ce-cli =17.12.0~ce-0~ Ubuntu docker version apt-get install docker-ce=17.03.0~ce-0~ Ubuntu Docker - ce - cli = 17.03.0 ~ ce - 0 ~ ubuntu

I found that I couldn’t install my Docker because of all the fidgeting. Life is short, I choose to install quickly, I want to install my original high version of Docker.

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

If you encounter an error with APT_PKG

1. Enter the package file directory

cd /usr/lib/python3/dist-packages/

Select CodeCopy

2. Perform a soft connection

Ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so Select CodeCopy if apt_pkg.so already exists:

Ln -fs apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so Select CodeCopy

apt install python3-apt

cd /usr/lib/python3/dist-packages

cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.cpython-36m-x86_64-linux-gnu.so

add-apt-repository “deb [arch=amd64] https://download.docker.com/l… xenial stable”


If you encounter an error with cgroupFS

Referred to the big man’s blog for processing:



Create daemon.json in /etc/docker and edit it:

/etc/docker/daemon.json: /etc/docker/daemon.

{

“exec-opts”:[“native.cgroupdriver=systemd”]

}


I want to use the latest!

It turns out that using the old version is better than using the new one. Start over and upgrade everything from Docker to the new one!

This is the result of starting over:

My server is dual core, if you are single core may need to set up again.

For single-core CPU configuration, please set 1


sudo minikube start –driver=none \

                --extra-config=kubeadm.ignore-preflight-errors=NumCPU \
                --force --cpus 1 \
                --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers

Still encountered the problem of mirror image 😭



Tried the following means completely not good, too painful 😣

  • minikube start –driver=none –image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
  • minikube start –driver=none –registry-mirror=https://dockerhub.azk8s.cn –image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers

Setting Image-Repository does not work! Here are the detailed errors:

[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/doc s/setup/cri/ error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR ImagePull]: Failed to pull image k8s.gcr. IO /kube-apiserver:v1.21.2: output: ERROR response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled whil e waiting for connection (Client.Timeout exceeded while awaiting headers) , error: Exit status 1 [ERROR ImagePull]: Failed to pull image k8s.gcr. IO /kube-controller-manager: v1.21.2: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canc eled while waiting for connection (Client.Timeout exceeded while awaiting headers) , error: Exit status 1 [Error ImagePull]: Failed to pull image k8s.gcr. IO/Kube-scheduler :v1.21.2: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled whil e waiting for connection (Client.Timeout exceeded while awaiting headers) , error: Exit status 1 [ERROR ImagePull]: Failed to pull image k8s.gcr. IO /kube-proxy:v1.21.2: output: Er ror response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while wa iting for connection (Client.Timeout exceeded while awaiting headers) , error: Exit status 1 [ERROR ImagePull]: Failed to pull image k8s.gcr. IO /pause:3.4.1: output: ERROR res ponse from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting f or connection (Client.Timeout exceeded while awaiting headers) , error: Exit status 1 [ERROR ImagePull]: Failed to pull image k8s.gcr. IO /etcd:3.4.13-0: output: ERROR r esponse from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) , error: The exit status 1 [ERROR ImagePull] : failed to pull the image k8s. GCR. IO/coredns/coredns: v1.8.0: the output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled whil e waiting for connection (Client.Timeout exceeded while awaiting headers) , error: exit status 1 [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore -preflight-errors=... ` To see the stack trace of this error execute with --v=5 or higher

Scripts solve mirroring problems!

The above series of errors were caused by a domestic mirroring problem.

Write scripts to pull images from DockerHub’s other repositories.

Go to DockerHub and search for kube_proxy, kube_kube-apiserver, etc.



These are the things that I’ve framed in the error report above.

Search as follows:

vim pull_k8s_images.sh

Content:

Set-o errexit set-o nounset set-o pipefail KUBE_VERSION=v1.21.2 KUBE_PAUSE_VERSION=3.4.1 ETCD_VERSION=3.4.13-0 DNS_VERSION= v1.8.0gcr_url =k8s.gcr. IO ## k8smx dockerHub_url =k8smx images=(kube-proxy:${KUBE_VERSION}) kube-scheduler:${KUBE_VERSION} kube-controller-manager:${KUBE_VERSION} kube-apiserver:${KUBE_VERSION} pause:${KUBE_PAUSE_VERSION} etcd:${ETCD_VERSION} coredns:${DNS_VERSION} ) for imageName in ${images[@]} ; do docker pull $DOCKERHUB_URL/$imageName docker tag $DOCKERHUB_URL/$imageName $GCR_URL/$imageName docker rmi $DOCKERHUB_URL/$imageName done

Grant executive power

chmod +x ./pull_k8s_images.sh

perform

./pull_k8s_images.sh

You can check which images you already have:

docker images



So for example, the ones that I’ve put in there, they match the contents of the ERROR



If you find any images that are not pulled down, you can write another script to handle them separately.

For example, coredns=v1.8.0 is not dropped:

Set -o errexit set -o nounset set -o pipefail DNS_VERSION= v1.8.0gcr_url =k8s.gcr. IO /coredns DOCKERHUB_URL=gotok8s images=( coredns:${DNS_VERSION} ) for imageName in ${images[@]} ; do docker pull $DOCKERHUB_URL/$imageName docker tag $DOCKERHUB_URL/$imageName $GCR_URL/$imageName docker rmi $DOCKERHUB_URL/$imageName done

Use the same way as above.

You can choose K8SMX and GOTOK8S by yourself. If this warehouse fails, you can change to another one.



When I get all the images,minikube start --driver=none



That’s OK.