Kubernetes 集群部署

Kubernetes 集群部署

环境准备:

k8s cri-dockerd pod-network service-network
Ubuntu2004:10.0.0.66( master ) 1.24.3 0.2.5.3-0.ubuntu 192.168.0.0/16(calico) 10.96.0.0/12
Ubuntu2004:10.0.0.76(node1)   k8s-node1.yum.org
Ubuntu2004:10.0.0.86(node2)   k8s-node2.yum.org
Ubuntu2004:10.0.0.96 (node3)  k8s-node2.yum.org

配置主机名

hostnamectl set-hostname k8s-master1.yum.org

hostnamectl set-hostname k8s-node1.yum.org

hostnamectl set-hostname k8s-node2.yum.org

hostnamectl set-hostname k8s-node3.yum.org

初始化设置

关闭 swp,防火强,时间同步

swapoff -a

ufw disable

修改 host 文件

root@master01:~# cat /etc/hosts

127.0.0.1 localhost

127.0.1.1 ubuntu2004

10.0.0.66 master01.hga.org mastetr01 kubeapi.yum.org kubeapi

10.0.0.76 node01.yum.org

10.0.0.86 node02.yum.org

10.0.0.96 node03.yum.org

安装 docker-ce

apt -y install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -

add-apt-repository "deb[arch=amd64]http://mirrors.aliyun.com/dockerce/linux/ubuntu

$(lsb_release -cs) stable"

apt -y instal docker-ce

添加 docke 代理

cat /usr/lib/systemd/system/docker.service

[Service]

Environment="HTTP_PROXY=socks5://10.0.0.1:1080"

Environment="HTTPS_PROXY=socks5://10.0.0.1:1080"

Environment="NO_PROXY=127.0.0.0/8,172.17.0.0/16"

systemctl daemon-reload && systemctl restart docker.service

安装 cri-dockerd

dpkg -i cri-dockerd_0.2.5.3-0.ubuntu-focal_amd64.deb

systemctl daemon-reload && systemctl restart cri-dockerd.service

安装 kubelet、kubeadm 和 kubectl

apt update && apt install -y apt-transport-https curl

curl -fsSL https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add

-

cat <<EOF >/etc/apt/sources.list.d/kubernetes.list

deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main

EOF

apt update && apt install -y kubelet kubeadm kubectl && systemctl enable kubelet

整合 kubelet 和 cri-dockerd

修改 service 文件

修改

vim /usr/lib/systemd/system/cri-docker.service

注释 #ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd://

添加

ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd:// --network[1]

plugin=cni --cni-bin-dir=/opt/cni/bin --cni-cache-dir=/var/lib/cni/cache --cni[1]

conf-dir=/etc/cni/net.d

systemctl daemon-reload && systemctl restart cri-docker.service

配置 kubelet

cat /etc/sysconfig/kubelet

KUBELET_KUBEADM_ARGS="--container-runtime=remote --container-runtime[1]

endpoint=/run/cri-dockerd.sock"

master 初始化

kubeadm init --control-plane-endpoint kubeapi.lxp.org --kubernetes-version=v1.24.3

--pod-network-cidr=192.168.0.0/16 --service-cidr=10.96.0.0/12 --token-ttl=0 --cri[1]

socket unix:///run/cri-dockerd.sock

mkdir -p $HOME/.kube

cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

安装 calico

curl https://projectcalico.docs.tigera.io/manifests/calico.yaml -O

kubectl apply -f calico.yaml

node 节点加入

​
cat /etc/sysconfig/kubelet

KUBELET_KUBEADM_ARGS="--container-runtime=remote --container-runtime[1]

endpoint=/run/cri-dockerd.sock"

​

检验集群

root@master01:~# kubectl get nodes

NAME STATUS ROLES AGE VERSION

master01.yum.org Ready control-plane 4h49m v1.24.3

node01.yum.org Ready <none> 98m v1.24.3

node02.yum.org Ready <none> 101m v1.24.3

node03.yum.org Ready <none> 96m v1.24.3

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值