用Minikube 运行一个本地单节点 Kubernetes 集群

#关闭主机
shutdown now
1.开启虚拟机处理器的虚拟化引擎:虚拟化Intel VT-x/EPT 或 AMDV/RVI(V))
2.内存调整为4G
3.CPU调整为1个双核

# 启动主机,安装Minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

### 安装virtualbox(无必要,使用--driver=dokcer来执行minikube start)
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
cp virtualbox.repo /etc/yum.repos.d/
yum -y install VirtualBox-6.0
# 查看有哪些自启动的服务,关闭不必要的自启动服务
systemctl list-unit-files --state enabled
systemctl disable libvirtd.service
# 杀掉不需要的程序进程
ps -ef |grep virtua[l]|awk '{print system("kill -9 " $2)}' # 高手使用,不推荐
ps -ef |grep virtua[l]|awk '{print $2}'|xargs kill -9      # 推荐

### 安装 docker-machine,并设置docker不检查硬件虚拟化(无必要)
base=https://github.com/docker/machine/releases/download/v0.16.0 &&
  curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
  sudo mv /tmp/docker-machine /usr/local/bin/docker-machine &&
  chmod +x /usr/local/bin/docker-machine
docker-machine create default --virtualbox-no-vtx-check

# 安装Kubernetes客户端(kubectl)
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/
# 给kubectl添加命令补全功能
source <(kubectl completion bash) ## 注意:"<("这里的重定向之后不能有空格,必须紧接着写小括号。

# 给minikube程序创建独立的用户,并加入docker用户组
adduser minikube
passwd minikube
usermod -aG docker minikube && newgrp docker

# 使用docker驱动启动minikube搭建k8s集群  ------时间较久,需耐心等待
minikube start --driver=docker

# 查看集群信息
kubectl cluster-info
kubectl describe node [node_name]
kubectl get node
[minikube@localhost ~]$ minikube start --driver=docker
* minikube v1.23.2 on Centos 7.4.1708
* Using the docker driver based on user configuration
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.22.2 preload ...
    > preloaded-images-k8s-v13-v1...: 511.69 MiB / 511.69 MiB  100.00% 1.15 MiB
    > index.docker.io/kicbase/sta...: 355.40 MiB / 355.40 MiB  100.00% 229.95 K
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.27, but successfully downloaded docker.io/kicbase/stable:v0.0.27 as a fallback image
* Creating docker container (CPUs=2, Memory=2200MB) ...| E1021 09:54:47.864842   18132 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)
! 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/
* Preparing Kubernetes v1.22.2 on Docker 20.10.8 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: storage-provisioner, default-storageclass

! /usr/local/bin/kubectl is version 1.8.0, which may have incompatibilites with Kubernetes 1.22.2.
  - Want kubectl v1.22.2? Try 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值