minikube下载和安装以及对应的bug解决

在机子上需要先有docker

#1安装 kubectl:https://kubernetes.io/docs/tasks/tools/
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

kubectl version --client
# Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", #GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", #BuildDate:"2022-03-16T15:58:47Z", GoVersion:"go1.17.8", Compiler:"gc", #Platform:"linux/amd64"}
#2、安装 Minikube
#https://minikube.sigs.k8s.io/docs/start/
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
#3、执行
minikube start
#如果出现下面的报错则切换为普通用户,不能使用root用户,如果没有普通用户则创建一个
#X Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.
#4、切换到普通用户执行minikube start
如果出现Got permission denied报错,如下,那么则需要给user配置用户组

 Unable to pick a default driver. Here is what was considered, in preference order:
  - docker: Not healthy: "docker version --format {{.Server.Os}}-{{.Server.Version}}" exit status 1: Got permission denied while trying to conneccker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connectn denied
  
执行以下命令将当前用户加到docker用户组,使当前user有权限操作docker
sudo usermod -aG docker $USER && newgrp docker

如果执行该命令报错“不在 sudoers 文件中。此事将被报告”
那么需要切回到root用户,进入/etc/sudoers 文件修改

vi  /etc/sudoers
#在“root    ALL=(ALL)       ALL ”下加入下面这一行,chw为你当前的用户名
chw     ALL=(ALL)       ALL
#然后qw! 强制保存退出

再切回到普通用户,执行 minikube start,一般会成功,如果出现以下的报错,ctrl+c 退出,重新执行几次minikube start就可以了

* Creating docker container (CPUs=2, Memory=2200MB) ...\ E0317 17:33:25.072716   17381 network_create.go:85] failed to find free subnet for docker network minikube after 20 attempts: no free private network subnets found with given parameters (start: "192.168.9.0", step: 9, tries: 20)
! Unable to create dedicated network, this might result in cluster IP change after restart: un-retryable: no free private network subnets found with given parameters (start: "192.168.9.0", step: 9, tries: 20)

执行成功后使用docker 查看一下,容易已经启动了

[chw@hserver1 ~]$ minikube start
* Centos 7.9.2009 上的 minikube v1.25.2
* 根据现有的配置文件使用 docker 驱动程序
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Updating the running docker "minikube" container ...
! This container is having trouble accessing https://k8s.gcr.io
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* 正在 Docker 20.10.12 中准备 Kubernetes v1.23.3…
  - kubelet.housekeeping-interval=5m
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default


[chw@hserver1 ~]$ docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED              STATUS              PORTS                                                                                                                                  NAMES
5ea84ba6c515   kicbase/stable:v0.0.30   "/usr/local/bin/entr…"   About a minute ago   Up About a minute   127.0.0.1:49157->22/tcp, 127.0.0.1:49156->2376/tcp, 127.0.0.1:49155->5000/tcp, 127.0.0.1:49154->8443/tcp, 127.0.0.1:49153->32443/tcp   minikube


[chw@hserver1 ~]$ docker images
REPOSITORY                              TAG                IMAGE ID       CREATED         SIZE
kicbase/stable                          v0.0.30            1312ccd2422d   5 weeks ago     1.14GB

可视化界面

minikube dashboard --url
# 让其它 IP 可以访问
kubectl proxy --port=8888 --address='0.0.0.0' --accept-hosts='^.*'
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值