minikube安装与运行

参考:

https://yq.aliyun.com/articles/221687

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

首先准备一台centos7虚拟机(至少2核,2G内存,20G存储)。

先决条件

检查虚拟化是否开启(输出非空):

egrep --color 'vmx|svm' /proc/cpuinfo

安装 kubectl

先配置yum源,再安装kubectl。

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl

 

安装minibuke:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube
sudo cp minikube /usr/local/bin && rm minikube

安装docker:

yum install docker

 

 运行minikube

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

输出信息:

xxx

===================
WARNING: IT IS RECOMMENDED NOT TO RUN THE NONE DRIVER ON PERSONAL WORKSTATIONS
	The 'none' driver will run an insecure kubernetes apiserver as root that may leave the host vulnerable to CSRF attacks

When using the none driver, the kubectl config and credentials generated will be root owned and will appear in the root home directory.
You will need to move the files to the appropriate location and then set the correct permissions.  An example of this is below:

	sudo mv /root/.kube $HOME/.kube # this will write over any previous configuration
	sudo chown -R $USER $HOME/.kube
	sudo chgrp -R $USER $HOME/.kube
	
	sudo mv /root/.minikube $HOME/.minikube # this will write over any previous configuration
	sudo chown -R $USER $HOME/.minikube
	sudo chgrp -R $USER $HOME/.minikube 

This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
Loading cached images from config file.

 

启动

缺省Minikube使用VirtualBox驱动来创建Kubernetes本地环境

minikube start --registry-mirror=https://registry.docker-cn.com

--vm-driver:默认virtualbox

none:none 驱动会运行一个不安全的API Server,会导致安全隐患,不建议在个人工作环境安装。

KVM2: 推荐linux使用

virtualbox:推荐Windows使用

 

启动后,使用kubectl进行交互。例如,启动服务:

kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
kubectl get pod

暴露服务:

kubectl expose deployment hello-minikube --type=NodePort

在浏览器中打开该服务(需要在虚拟机中进行,而不是远程命令行):

minikube service hello-minikube

停止本地群集:

minikube stop

删除本地群集:

minikube delete

打开Kubernetes控制台(需要在虚拟机中进行,而不是远程命令行)

minikube dashboard

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值