1.安装kubectl
kubectl是负责与k8s集群talk的工具,就像docker cli对话docker集群一样
地址:
https://kubernetes.io/docs/tasks/tools/install-kubectl/
Linux环境
步骤:
下载kubectl文件(因为涉及到翻墙的问题,此下载方式可能不成功)
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
可以查询一下kubectl文件最新版本号
https://storage.googleapis.com/kubernetes-release/release/stable.txt
比如v1.19.3,然后复制地址去迅雷下载kubectl文件,下载好的kubectl文件是一个二进制文件
https://storage.googleapis.com/kubernetes-release/release/v1.19.3/bin/linux/amd64/kubectl
然后通过ftp工具,将下载好的kubectl文件上传到 “/”目录下,再执行下面的操作。
授予权限
chmod +x ./kubectl
移动到自己指定的目录
sudo mv ./kubectl /usr/local/bin/kubectl
测试是否安装成功
[root@localhost ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:30:33Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"} The connection to the server localhost:8080 was refused - did you specify the right host or port?
2.安装Docker
安装依赖包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
设置阿里云镜像源
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装 Docker-CE
sudo yum install docker-ce
启动docker
开机自启
sudo systemctl enable docker
启动docker服务
sudo systemctl start docker
重启服务docker
systemctl daemon-reload systemctl restart docker.service
3.安装Minikube
依赖virtualbox,会在virtualbox里面安装虚拟机,虚拟机会安装好k8s单节点的集群。
下载
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
下载不了就用迅雷下载,再用ftp上传到服务器
如果是迅雷自己下载的文件,则执行下面命令
mv minikube-linux-amd64 minikube
chmod +x minikube
sudo mv minikube /usr/local/bin/
启动
minikube start
报异常:
[root@localhost ~]# minikube start
* Centos 7.8.2003 上的 minikube v1.14.2
* Automatically selected the docker driver
* The "docker" driver should not be used with root privileges.
* If you are running minikube within a VM, consider using --driver=none:
* https://minikube.sigs.k8s.io/docs/reference/drivers/none/
X Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.
如出现:The "docker" driver should not be used with root privileges.
不允许以root用户运行minikube,请创建一个新用户,然后与该用户一起运行,并确保将该用户添加到docker组。
创建用户
useradd taizhuyj passwd taizhuyj su taizhuyj
将新用户添加到docker组
sudo usermod -aG docker $USER && newgrp docker
执行命令出错
用户名 不在 sudoers文件中,此事将被报告
su root
visudo
root ALL=(ALL:ALL) ALL
linc ALL=(ALL:ALL) ALL // 添加此行保存
su taizhuyj
再执行即可
sudo usermod -aG docker $USER && newgrp docker
启动Minikube