Minikube 安裝

需求

安裝kubernetes - Minikube本地環境node

安裝步驟

在安裝前須要配置國內的鏡像源linux

cat <<EOF > /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

安裝kubectl

yum install -y kubectl

shell 中開啓 kubectl 命令自動補全git

yum install bash-completion -y
echo "source <(kubectl completion bash)" >> ~/.bashrc

安裝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

啓動本地 Kubernetes 集羣、 檢查集羣的狀態

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'.

開啓Kubernetes dashboard服務

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/

開啓kube-proxy端口映射,使其能夠遠程訪問

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

這裏須要記得去阿里雲的安全組配置33458端口外網能夠訪問github

而後就能夠在瀏覽器訪問k8s的dashborad了docker

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

k8s-dashboard

清理 minikube 的本地狀態api

minikube delete

參考文獻

http://www.javashuo.com/article/p-kdnhiuaf-db.html瀏覽器

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

https://github.com/kubernetes/minikubebash

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

相關文章
相關標籤/搜索