安装K8S环境
配置hosts文件
vim /etc/hosts #本机ip 本机hostname 172.19.19.5 k8s-master
关闭防火墙
systemctl stop firewalld systemctl disable firewalld
禁用selinux
vi /etc/selinux/config SELINUX=disabled #查看selinux状态 /usr/sbin/sestatus -v
安装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
yum makecache --refresh sudo yum -y install docker-ce 发现报错:Problem: package docker-ce-3:19.03.12-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed 因为containerd 版本过低 dnf install container-selinux 通过yum -y install https://download.docker.com/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm 升级即可
docker 修改Cgroup Driver以及docker镜像拉取地址
cat /etc/docker/daemon.json { "registry-mirrors": ["https://e7l8pkuq.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"] }
开启Docker服务
sudo service docker start
安装kubectl
下载最新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"
添加执行权限
chmod +x ./kubectl
移动kubectl至bin路径
sudo mv ./kubectl /usr/local/bin/kubectl
确认安装的版本
kubectl version --client
安装minikube
下载minikube资源
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \ && chmod +x minikube
添加minikube进入系统命令
sudo mkdir -p /usr/local/bin/ sudo install minikube /usr/local/bin/
启动 minikube(本文使用的VM安装的centos 8因此设置driver=none)
minikube start --driver=none --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
确认minikube状态
minikube status
查看集群状态
kubectl cluster-info
安装 镜像仓库
vim restartRegistry.sh
docker stop registry docker rm registry docker run -d -p 5000:5000 --name=registry --restart=always \ --privileged=true \ --log-driver=none \ -v /root/registry/registrydata:/var/lib/registry \ registry:2
配置非安全访问的仓库IP:端口号
vim daemon.json #添加 {"insecure-registries":["172.19.19.5:5000"]}
重启docker服务
service docker restart
一键安装Maven
#!/bin/bash wget -P /usr/local/ https://repo.huaweicloud.com/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz tar -xvf /usr/local/apache-maven-3.8.1-bin.tar.gz -C /usr/local echo "export MAVEN_HOME=/usr/local/apache-maven-3.8.1" >> /etc/profile echo "export PATH=\$PATH:\$MAVEN_HOME/bin" >> /etc/profile source /etc/profile mvn -version