命令行如下:
1
|
sudo vi /etc/yum.repos.d/kubernets.repo
|
再其中添加如下:
1
2
3
4
5
|
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
|
安装可用软件包
1
|
yum -y install kubectl.x86_64
|
启动命令如下所示 start.sh
1
2
3
4
5
6
7
|
[root@k-116-n2 ~]# cat <<EOF >/etc/docker/daemon.json
> {
> "registry-mirrors": [
> "https://docker.nju.edu.cn/"
> ]
> }
> EOF
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
[minikube@k-116-n2 wsl2-minikube]$ cat start.sh
echo -n "Starting Kubernetes..."
minikube version
minikube config set WantUpdateNotification false
minikube delete && minikube start --memory=8096 --cpus=6 \
--insecure-registry "10.7.20.12:5000" \
--nodes 3 \
--driver=docker \
--network-plugin=cni \
--extra-config=kubeadm.pod-network-cidr=192.168.0.0/16 \
--service-cluster-ip-range=10.96.0.0/16 \
--kubernetes-version=v1.26.3 \
--base-image=docker.io/kicbase/stable:v0.0.39 \
--registry-mirror=https://docker.nju.edu.cn \
--cpus=2 \
--memory=4096mb \
--container-runtime=containerd
sleep 2
n=0
until [ $n -ge 10 ]
do
minikube addons enable dashboard && break
minikube addons enable metrics-server && break
n=$[$n+1]
sleep 1
done
sleep 1
n=0
until [ $n -ge 10 ]
do
kubectl apply -f ./kubernetes-dashboard.yaml &>/dev/null && break
n=$[$n+1]
sleep 1
done
echo "Kubernetes Started"
|
检查一下
本文档中 minikube 开启了 BGP 功能。
linux 优化:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# 优化SSH链接
sed -i 's/^#UseDNS no/UseDNS no/g' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication no/GSSAPIAuthentication no/g' /etc/ssh/sshd_config
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
# 关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# 网络相关的配置
/etc/NetworkManager/system-connections/ens192.nmconnection
# 安装一些常用工具
dnf install wget curl net-tools vim -y
|