欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Minikube 安装

程序员文章站 2022-08-09 15:19:22
需求 安装kubernetes Minikube本地环境 准备条件 1. 一台VPS(本文使用 阿里云香港 centos7.7) 用国内的服务器折腾的好一会儿都被墙了,先不把时间浪费在这,直接上香港的服务器 2. 一台能SSH连接到VPS的本地电脑 (推荐连接工具xshell) 安装步骤 在安装前需 ......

需求

安装kubernetes - minikube本地环境

准备条件

  1. 一台vps(本文使用阿里云香港 - centos7.7)- 用国内的服务器折腾的好一会儿都被墙了,先不把时间浪费在这,直接上香港的服务器
  2. 一台能ssh连接到vps的本地电脑 (推荐连接工具xshell)

安装步骤

在安装前需要配置国内的镜像源

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 命令自动补全

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端口外网可以访问

然后就可以在浏览器访问k8s的dashborad了


Minikube 安装

清理 minikube 的本地状态

minikube delete

参考文献