Minikube简介
官网:https://minikube.sigs.k8s.io/ minikube是运行kubernetes集群最简单、最快捷的途径。 对于测试kubernets和本地开发应用都非常有用。
准备工作
安装一台Centos7虚拟机,开启虚拟机的CPU虚拟化。
安装minikube
下载地址: https://storage.googleapis.com/minikube/releases/latest/minikube-1.3.1.rpm
代码语言:javascript复制
rpm -ivh minikube-1.3.1.rpm
安装virtualbox(5.2 )
添加virtualbox yum源
代码语言:javascript复制
[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
安装Virtualbox
代码语言:javascript复制
yum install VirtualBox-5.2 -y
rcvboxdrv setup
部署K8S集群(LINUX)
安装开发工具
代码语言:javascript复制
#必须安装以下工具,否则会出现virtualbox问题。
yum -y install gcc perl make kernel-devel
开始安装
必须能够访问外国网站,才能下载镜像。这是我的本地代理。
代码语言:javascript复制
export http_proxy=http://192.168.1.100:1087;
export https_proxy=http://192.168.1.100:1087;
minikube start --docker-env http_proxy=http://192.168.1.100:1087
--docker-env https_proxy=http://192.168.1.100:1087
--docker-env no_proxy=localhost,192.168.1.100,192.168.99.0/24
--log_dir=tmp --cpus 2 --memory 2048
#日志
? minikube v1.3.1 on Centos 7.6.1810
⚠️ Please don't run minikube as root or with 'sudo' privileges. It isn't necessary with virtualbox driver.
? Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
? Found network options:
▪ http_proxy=http://192.168.1.100:1087
⚠️ You appear to be using a proxy, but your NO_PROXY environment does not include the minikube IP (192.168.99.100). Please see https://minikube.sigs.k8s.io/docs/reference/networking/proxy/ for more details
▪ https_proxy=http://192.168.1.100:1087
? Preparing Kubernetes v1.15.2 on Docker 18.09.8 ...
▪ env http_proxy=http://192.168.1.100:1087
▪ env https_proxy=http://192.168.1.100:1087
▪ env no_proxy=localhost,192.168.1.100,192.168.99.0/24
? 拉取镜像 ...
? 正在启动 Kubernetes ...
⌛ Waiting for: apiserver proxy etcd scheduler controller dns
? Done! kubectl is now configured to use "minikube"
? For best results, install kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/
安装Dashboard
必须安装此工具,否则无法测试。
代码语言:javascript复制
yum install xdg-utils
开始安装
代码语言:javascript复制
minikube dashboard
minikube dashboard --url
#日志
? Verifying dashboard health ...
? Launching proxy ...
? Verifying proxy health ...
http://127.0.0.1:39099/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/
#上面可以通过`Ctrl c`取消
kubectl proxy --address='0.0.0.0' --port=39099 --accept-hosts='^*$'
Starting to serve on [::]:39099
访问测试
安装kubectl
代码语言:javascript复制
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:15:22Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready master 8m59s v1.15.2
Minikube常用指令
minikube version,查看minikube的版本 minikube start,启动minikube minikube ssh,ssh到虚拟机中 minikube logs,显示minikube的log minikube dashboard,启动minikube dashboard minikube ip,显示虚拟机地址 minikube stop,停止虚拟机 minikube delete,删除虚拟机
FAQ
1.Please install the gcc make perl packages from your distribution. 需要安装gcc make perl工具 2.Please install the Linux kernel header files. 需要安装kernel-devel工具 3.failed to open browser: exit status 3. 经过测试没有影响