Minikube installation

Time:2020-5-19

demand

Install kubernetes – minikube local environment

Preparation conditions

  1. A VPS (used in this articleAlicloud Hong Kong-CentOS 7.7) – it’s been a long time since using domestic servers. First, don’t waste your time here. Go to the servers in Hong Kong directly
  2. A local computer that can SSH to VPS (xshell is recommended)

Installation procedure

You need to configure the domestic image source before installation

cat < /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

Install kubectl

yum install -y kubectl

Enable kubectl command in shell to complete automatically

yum install bash-completion -y
echo "source > ~/.bashrc

Install minukube

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/
su - docker

Start the local kubernetes cluster and check the status of the cluster

minikube start

* minikube v1.9.2 on Centos 7.7.1908
* Automatically selected the docker driver
* Starting control plane node m01 in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.18.0 preload ...
    > preloaded-images-k8s-v2-v1.18.0-docker-overlay2-amd64.tar.lz4: 542.91 MiB
* Creating Kubernetes in docker container with (CPUs=2) (4 available), Memory=2200MB (7821MB available) ...
* Preparing Kubernetes v1.18.0 on Docker 19.03.2 ...
  - kubeadm.pod-network-cidr=10.244.0.0/16
* Enabling addons: default-storageclass, storage-provisioner
! Enabling 'default-storageclass' returned an error: running callbacks: [chmod: chmod deploy/addons/storageclass/storageclass.yaml.tmpl: permission denied]
* Done! kubectl is now configured to use "minikube"
minikube status

m01
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
kubectl cluster-info

Kubernetes master is running at https://172.17.0.2:8443
KubeDNS is running at https://172.17.0.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Open kubernetes dashboard service

minikube dashboard --url

* Enabling dashboard ...
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:33457/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

Turn on the Kube proxy port mapping so that it can be accessed remotely

kubectl proxy --port=33458 --address='0.0.0.0' --accept-hosts='^.*' &

Remember to go to alicloud’s security group to configure port 33458 for Internet access

Then you can access the dashborad of k8s in the browser

http://127.0.0.1:33458/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
k8s-dashboard

Clean up the local state of minikube

minikube delete

reference

https://juejin.im/post/5b8a4536e51d4538c545645c

https://kubernetes.io/zh/docs/tasks/tools/install-minikube/

https://github.com/kubernetes/minikube

https://minikube.sigs.k8s.io/docs/handbook/dashboard/