VM配置
VM环境搭建
vm下载地址
https://download3.vmware.com/software/wkst/file/VMware-workstation-full-16.1.0-17198959.exe
vm密钥
ZF3R0-FHED2-M80TY-8QYGC-NPKYF
记录ip及网关配置
Centos7配置
环境搭建
Centos7下载地址
http://ftp.sjtu.edu.cn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2207-02.iso
#配置centos网络文件
[root@centos7-2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 (不同机器可能具体文件不一样)
[root@centos7-2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" #改为static
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="1b6d4121-0707-4f37-a20a-847f86a9eec4"
DEVICE="ens33"
ONBOOT="yes" #改为yes
IPADDR="192.168.17.4" #IP地址配一个自己想要配的地址,但是必须是同VMnet8的子网IP在同一网段
GATEWAY="192.168.17.2" #网关,这个值与我们在第2步“NAT(设置S)...”设置的网关一样
NETMASK="255.255.255.0" #子网掩码,这个值与我们在第2步“NAT(设置S)...”设置的子网掩码一样
DNS1="192.168.17.2" #DNS的值也跟我们第2步“NAT(设置)...”设置的的网关一样
4.重启网络 systemctl restart network
5.测试。ping www.baidu.com
#关闭防火墙
systemctl stop firewalld
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#禁用防火墙
systemctl disable firewalld
Docker
Docker配置
官方脚本一键安装命令:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
#阿里云镜像加速
udo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://01sy6s7g.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
#设置开机自动启动命令
systemctl enable docker.service
docker-compose 国内下载源安装
# 国内docker-compose 下载
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
# 修改执行权限
sudo chmod +x /usr/local/bin/docker-compose
# 补全命令
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
minikube
配置
#下载&安装
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
#启动--vm-driver=none,如果你是本地vmware创建的虚拟机,或者物理机器,你应该进入到bios设置vtx为enabled,然后还需要安装virtualbox或者vmware,然后用--vm-driver='virtualbox'或者vmware来指定;指定版本
minikube start --driver=docker --force --kubernetes-version=v1.23.8 --image-mirror-country='cn' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers'
kubectl
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl
kubectl version
-------------------------
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.23.8/bin/linux/amd64/kubectl
chmod +x kubectl
mv kubectl /usr/local/bin