Creating K8S Single Machine Environment-Pit Filling Guide with minikube

Keywords: Docker Kubernetes DNS CentOS

Reminder

This blog post mainly records how to install minikube using CentOS system in the local environment. It fills in the hole for the problem of mirror download failure in the process of installation. It mainly uses kubernete version 1.12.1. For other different versions, the method is the same.

1. Download the Deployment Installation Package

wget https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-linux-amd64
mv minikube-linux-amd64  /usr/bin/minikube

wget https://dl.k8s.io/v1.12.1/kubernetes-server-linux-amd64.tar.gz
tar xf kubernetes-server-linux-amd64.tar.gz && cd kubernetes/server/bin/
cp kubectl kubeadm kubelet /usr/local/bin/

2. Install docker

Upload docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm and docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm to the server. Run the following command to install docker:

yum install docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm -y
yum install docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm -y

Start the docker service and set the docker to boot self-startup:

systemctl start docker
systemctl enable docker

3. Download the docker image of kubernetes

Create the following script:

vi auto_pull_images.sh

Add the following to the script:

#!/bin/bash
images=(kube-proxy-amd64:v1.12.1 kube-scheduler-amd64:v1.12.1 kube-controller-manager-amd64:v1.12.1 kube-apiserver-amd64:v1.12.1 etcd-amd64:3.2.24  pause-amd64:3.1 kubernetes-dashboard-amd64:v1.10.0 k8s-dns-sidecar-amd64:1.14.8 k8s-dns-kube-dns-amd64:1.14.8
k8s-dns-dnsmasq-nanny-amd64:1.14.8)
for imageName in ${images[@]} ; do
  docker pull mirrorgooglecontainers/$imageName
  docker tag mirrorgooglecontainers/$imageName k8s.gcr.io/$imageName
  docker rmi mirrorgooglecontainers/$imageName
done

for n in $(docker images|awk '{print $1":"$2}'|grep -v REPOSITORY); do docker tag $n  `echo $n|sed 's/-amd64//g'` && docker rmi $n; done
docker tag k8s.gcr.io/kubernetes-dashboard:v1.10.0  k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0

docker pull coredns/coredns:1.2.2 
docker tag coredns/coredns:1.2.2 k8s.gcr.io/coredns:1.2.2
docker rmi coredns/coredns:1.2.2

docker pull registry.cn-hangzhou.aliyuncs.com/anoy/kube-addon-manager:v8.6
docker tag  registry.cn-hangzhou.aliyuncs.com/anoy/kube-addon-manager:v8.6  k8s.gcr.io/kube-addon-manager:v8.6
docker rmi registry.cn-hangzhou.aliyuncs.com/anoy/kube-addon-manager:v8.6

docker pull registry.cn-hangzhou.aliyuncs.com/anoy/storage-provisioner:v1.8.1
docker tag registry.cn-hangzhou.aliyuncs.com/anoy/storage-provisioner:v1.8.1 gcr.io/k8s-minikube/storage-provisioner:v1.8.1
docker rmi registry.cn-hangzhou.aliyuncs.com/anoy/storage-provisioner:v1.8.1

Run the script:

sh auto_pull_images.sh

Waiting for the script to run successfully, execute the following command to confirm that the required image has been downloaded locally:

[root@node-2 ~]# docker images
REPOSITORY                                TAG                 IMAGE ID            CREATED             SIZE
k8s.gcr.io/kube-proxy                     v1.12.1             61afff57f010        2 weeks ago         96.6 MB
k8s.gcr.io/kube-apiserver                 v1.12.1             dcb029b5e3ad        2 weeks ago         194 MB
k8s.gcr.io/kube-scheduler                 v1.12.1             d773ad20fd80        2 weeks ago         58.3 MB
k8s.gcr.io/kube-controller-manager        v1.12.1             aa2dd57c7329        2 weeks ago         164 MB
k8s.gcr.io/etcd                           3.2.24              3cab8e1b9802        5 weeks ago         220 MB
k8s.gcr.io/coredns                        1.2.2               367cdc8433a4        8 weeks ago         39.2 MB
k8s.gcr.io/kubernetes-dashboard-amd64     v1.10.0             0dab2435c100        2 months ago        122 MB
k8s.gcr.io/kube-addon-manager             v8.6                9c16409588eb        8 months ago        78.4 MB
k8s.gcr.io/kubernetes-dashboard           v1.8.3              0c60bcf89900        8 months ago        102 MB
k8s.gcr.io/k8s-dns-dnsmasq-nanny          1.14.8              c2ce1ffb51ed        9 months ago        40.9 MB
k8s.gcr.io/k8s-dns-sidecar                1.14.8              6f7f2dc7fab5        9 months ago        42.2 MB
k8s.gcr.io/k8s-dns-kube-dns               1.14.8              80cc5ea4b547        9 months ago        50.5 MB
k8s.gcr.io/pause                          3.1                 da86e6ba6ca1        10 months ago       742 kB
gcr.io/k8s-minikube/storage-provisioner   v1.8.1              4689081edb10        11 months ago       80.8 MB

4. Start up the service

Start the minikube cluster

minikube start --vm-driver=none --registry-mirror=https://registry.docker-cn.com --kubernetes-version v1.12.1

Start dashboard:

minikube dashboard

Add an external access agent to dashboard, where IP is the local system IP:

kubectl proxy  --port=8001 --address='10.0.0.2' --accept-hosts='^.*' &

Through url: http://10.0.0.2:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ Visit dashboard.

Posted by faheemhameed on Thu, 24 Jan 2019 01:42:12 -0800