测试环境
AnolisOS-8.6-x86_64-minimal.iso
Virtual Box,2 vCPU, 4G RAM, 40 vDisk
系统配置
关闭Selinux,[默认是关闭]
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g’ /etc/selinux/config
cat /etc/selinux/config
关闭防火墙
systemctl disable --now firewalld
systemctl stop firewalld
systemctl status firewalld
开启NTP同步
systemctl enable chronyd
systemctl start chronyd
systemctl status chronyd
chronyc sources -v
timedatectl
date
修改主机名
hostnamectl set-hostname --static node
echo “192.168.1.48 node” >> /etc/hosts
cat /etc/hosts
安装工具
curl -LO https://github.com/containernetworking/plugins/releases/download/v1.4.1/cni-plugins-linux-amd64-v1.4.1.tgz
mkdir -p /opt/cni/bin
tar -xf cni-plugins-linux-amd64-v1.4.1.tgz -C /opt/cni/bin
yum install -y conntrack-tools cri-tools
安装cri-dockerd
curl -LO https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.14/cri-dockerd-0.3.14-3.el8.x86_64.rpm
rpm -ivh cri-dockerd-0.3.14-3.el8.x86_64.rpm
配置Docker和Kubernetes的软件包仓库
Docker 软件仓库
cat > /etc/yum.repos.d/docker-ce.repo << EOF
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
EOF
Kubernetes 软件仓库
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
#清除,更新缓存
yum clean all && yum makecache
安装kubectl
yum install -y kubectl
安装docker
yum -y install docker-ce
docker version
安装minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
rpm -Uvh minikube-latest.x86_64.rpm
minikube start --driver=none --image-mirror-country=‘cn’ --kubernetes-version=v1.27.12 --image-repository=‘registry.cn-hangzhou.aliyuncs.com/google_containers’
验证环境
kubectl get nodes
kubectl get pods --all-namespaces
开启控制台[可选]
minikube dashboard
http://127.0.0.1:35465/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
因为是本地Windows电脑装了Virtual Box, 在Virtual Box上装的龙蜥虚拟机,默认是无法从Windows上访问。如果需要在宿主机Windows系统里访问这个dashboard,配置代理:
kubectl proxy --port=8000 --address=‘192.168.1.48’ --accept-hosts='^.'*
在浏览器访问:
http://192.168.1.48:8000/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview?namespace=default
开启Addon 组件[可选]
minikube addons list
minikube addons enable kubevirt
移除环境
minikube delete