为什么迅雷不能连接资源(手机迅雷一直显示连接资源中)

最近公司业务适配国产化操作,我们计划采用华为开源的 openEuler 系统。又由于 k8s 在公司业务中占很大一块。所以我优先尝试使用 kubeadm 在 openEuler 上部署 k8s。在国内通过 kubeadm 部署 k8s 的难点在于资源的下载,k8s 很多官方资源仓库都被防火墙屏蔽了,这么文档就展示了如何使用国内镜像仓库通过 kubeadm 部署 k8s。

准备

老规矩,为了以防万一先关闭防火墙和 seLinux:

systemctlstop firewalldsystemctldisable firewalldsetenforce0

要想永久关闭 selinux,需要修改配置文件 /etc/selinux/config,设置 SELINUX=disabled。

另外需要注意的是如果想部署多节点需要提前把节点 hostname 和 ip 的映射写入 /etc/hosts。

加载内核模块 br_netfiltermodprobebr_netfilterecho1 > /proc/sys/net/bridge/bridge-nf-call-iptablesecho1 > /proc/sys/net/ipv4/ip_forward安装 kubelet kubeadm kubectl

安装之前先配置 kubernetes 的 yum 源,创建文件/etc/yum.repos.d/kubernetes.repo 写入下面内容:

[kubernetes]name=Kubernetesbaseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=0repo_gpgcheck=0

执行 dnf 命令安装:

dnfinstall -y kubelet kubeadm kubectl安装 containerd

从 containerd release 页面https://github.com/containerd/containerd/releases 下载最新 containerd 压缩包,

需要使用迅雷下载(网页直接下载,或者在 linux 使用 wget 都非常的慢),如果迅雷卡在正在连接资源多等一等,或者重复暂停,开始即可。

下载完成后,下载完成后通过 xftp 或者 winscp 或者 lrzsz 上传至部署节点,并解压至 /usr/local 目录:

tar Cxzvf /usr/localcontainerd-1.6.8-linux-amd64.tar.gz

创建一个 systemctl 的 service 文件/usr/lib/systemd/system/containerd.service,写入下面内容:

[Unit]Description=containerd container runtimeDocumentation=https://containerd.ioAfter=network.target local-fs.target[Service]uncomment to enable the experimental sbservice (sandboxed) version of containerd/cri integrationEnvironment="ENABLE_CRI_SANDBOXES=sandboxed"ExecStartPre=-/sbin/modprobe overlayExecStart=/usr/local/bin/containerdType=notifyDelegate=yesKillMode=processRestart=alwaysRestartSec=5Having non-zero Limit*s causes performance problems due to accounting overheadin the kernel. We recommend using cgroups to do container-local accounting.LimitNPROC=infinityLimitCORE=infinityLimitNOFILE=infinityComment TasksMax if your systemd version does not supports it.Only systemd 226 and above support this version.TasksMax=infinityOOMScoreAdjust=-999[Install]WantedBy=multi-user.target

创建 containerd 配置文件/etc/containerd/config.toml,并填入以下内容:

version=2[plugins."io.containerd.grpc.v1.cri"]sandbox_image="registry.aliyuncs.com/google_containers/pause:3.7"

这里重点就是设置 pause 容器的仓库地址,默认的 gcr 仓库在国内是无法访问的,然后执行命令:

systemctldaemon-reloadsystemctlenable --now containerd安装 runc

从 runc release 页面https://github.com/opencontainers/runc/releases 下载最新 runc,同样需要用迅雷下载

下载完成后执行解压命令:

install-m755runc.amd64 /usr/local/sbin/runc安装 cni-plugin

同样的使用迅雷从 github release 页面下载https://github.com/containernetworking/plugins/releases,下载完成后执行命令:

mkdir-p /opt/cni/bintarCxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.1.1.tgz初始化环境

在当前目录创建一个 kubeadm-init-config.yaml 文件,填入以下内容:

---apiVersion:kubeadm.k8s.io/v1beta3kind:InitConfigurationbootstrapTokens:-token:abcdef.0123456789abcdefttl:24h0m0slocalAPIEndpoint:advertiseAddress:192.168.26.132bindPort:6443nodeRegistration:criSocket:unix:///var/run/containerd/containerd.sockimagePullPolicy:IfNotPresenttaints:[]---apiVersion:kubeadm.k8s.io/v1beta3kind:ClusterConfigurationapiServer:timeoutForControlPlane:4m0scertificatesDir:/etc/kubernetes/pkiclusterName:kubernetescontrollerManager:{}dns:{}etcd:local:dataDir:/var/lib/etcdimageRepository:registry.aliyuncs.com/google_containerskubernetesVersion:1.24.3networking:dnsDomain:cluster.localserviceSubnet:10.96.0.0/12podSubnet:10.244.0.0/16scheduler:{}---apiVersion:kubelet.config.k8s.io/v1beta1kind:KubeletConfigurationfailSwapOn:falseaddress:0.0.0.0enableServer:truecgroupDriver:cgroupfs---apiVersion:kubeproxy.config.k8s.io/v1alpha1kind:KubeProxyConfigurationmode:ipvsipvs:strictARP:trueadvertiseAddress 根据实际情况调整,配置为本节点管理网网卡的 IP,在后面添加节点时,会通过这个 IP 添加kubernetesVersion 在我编写本文档时最新的 kubernetes 版本为 1.24.3imageRepository 这个时我们能在国内环境安装成功的关键,kubeadm 默认的容器镜像仓库在国外,我们是无法访问的

执行初始化命令:

kubeadminit--config kubeadm-init-config.yaml

初始化成功后会输出以下提示:

Your Kubernetes control-plane has initialized successfully! Tostartusingyour cluster, you needtorun thefollowingasa regularuser: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id-u):$(id-g) $HOME/.kube/config Alternatively,ifyouarethe rootuser, you can run:exportKUBECONFIG=/etc/kubernetes/admin.conf You shouldnowdeploy a pod networktothe cluster. Run"kubectl apply -f [podnetwork].yaml"withoneofthe options listedat: https://kubernetes.io/docs/concepts/cluster-administration/addons/Thenyou canjoinanynumberofworker nodesbyrunning thefollowingoneachasroot: kubeadmjoin192.168.26.132:6443--token abcdef.0123456789abcdef \--discovery-token-ca-cert-hash sha256:5ad131a9fc70400bf4f11d7cdbf0c0b9b43fe97604c0a4903fb85cabedca9ccf

根据提示执行下面命令

mkdir-p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudochown$(id -u):$(id -g) $HOME/.kube/config

然后使用 kubectl 验证:

kubectl get nodesNAMESTATUS ROLES AGE VERSIONnode1NotReady control-plane 2m49s v1.24.3

现在节点 STATUS 是 NotReady,这是因为没有安装网络插件

安装 flannel 网络插件kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml

安装完成后在使用 kubelet 命令验证:

kubectl get nodesNAMESTATUS ROLES AGE VERSIONnode1Ready control-plane 18m v1.24.3

这时候节点的 STATUS 变成 Ready 了

版权声明:
作者:xiaoqiang
链接:https://baike.yueyaerz.com/264664.html
来源:月牙知识网
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>