kubernetes v1.28.2 container版本部署

举报
yd_266387056 发表于 2023/12/20 21:58:25 2023/12/20
【摘要】 root@k8s-master01:~# vim /etc/hosts10.0.0.11 kubeapi.gao.com kubeapi10.0.0.11 k8s-master01.gao.com k8s-master0110.0.0.12 k8s-master02.gao.com k8s-master0210.0.0.13 k8s-master03.gao.com k8s-master03...

root@k8s-master01:~# vim /etc/hosts
10.0.0.11 kubeapi.gao.com kubeapi
10.0.0.11 k8s-master01.gao.com k8s-master01
10.0.0.12 k8s-master02.gao.com k8s-master02
10.0.0.13 k8s-master03.gao.com k8s-master03
10.0.0.21 k8s-node01.gao.com k8s-node01
10.0.0.22 k8s-node02.gao.com k8s-node02
10.0.0.23 k8s-node03.gao.com k8s-node03

root@k8s-master01:modprobe br_netfilter

root@k8s-master01:echo "1" > /proc/sys/net/ipv4/ip_forward;echo "1">/proc/sys/net/bridge/bridge-nf-call-iptables

root@k8s-master01:sysctl -p

root@k8s-master01:swapoff -a

root@k8s-master01:~# vim /etc/fstab 

#/swap.img      none    swap    sw      0       0

root@k8s-master01:systemctl  --type swap

root@k8s-master01:ufw disable

root@k8s-master01:ufw status

root@k8s-master01:apt -y install chrony

root@k8s-master01:systemctl start chrony

root@k8s-master01:vim /etc/chrony/chrony.conf
server ntp.aliyun.com iburst

 
root@k8s-master01:curl -LO https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.8/cri-dockerd_0.3.8.3-0.ubuntu-jammy_amd64.deb

root@k8s-master01:apt -y install apt-transport-https ca-certificates curl software-properties-common

root@k8s-master01:sudo apt-get update

root@k8s-master01:apt -y install apt-transport-https ca-certificates curl software-properties-common

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

root@k8s-master01:add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

root@k8s-master01:apt update

root@k8s-master01:apt-get install  containerd.io

root@k8s-master01:mkdir /etc/containerd

root@k8s-master01:containerd config default > /etc/containerd/config.toml

root@k8s-master01:vim /etc/containerd/config.toml
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry.magedu.com"]
          endpoint = ["https://registry.magedu.com"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
          endpoint = ["https://docker.mirrors.ustc.edu.cn", "https://registry.docker-cn.com"]

    [plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry.k8s.io"]
      endpoint = ["https://registry.aliyuncs.com/google_containers"]

sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"

root@k8s-master01:systemctl daemon-reload 

root@k8s-master01:systemctl restart containerd

root@k8s-master01:vim /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: true

root@k8s-master01:apt update && apt -y install apt-transport-https curl

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

root@k8s-master01:cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
 
root@k8s-master01:apt update

root@k8s-master01:apt install -y kubelet kubeadm kubectl

root@k8s-master01:systemctl enable kubelet

root@k8s-master01:containerd config default

root@k8s-master01:kubeadm config images list

root@k8s-master01:containerd -v

root@k8s-master01:systemctl status containerd

root@k8s-master01:kubeadm init --control-plane-endpoint="kubeapi.gao.com" --kubernetes-version=v1.28.2 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --image-repository=registry.aliyuncs.com/google_containers --upload-certs --cri-socket unix:///run/containerd/containerd.sock

You can now join any number of the control-plane node running the following command on each as root:
#其他master节点执行此命令加入集群
  kubeadm join kubeapi.gao.com:6443 --token bdx15c.kgt7so8awbtc234s \
    --discovery-token-ca-cert-hash sha256:891cdb46f640292f089c80f077b59db7f145225cd2850f853edd68668d11a642 \
    --control-plane --certificate-key 4e5e43e3148c79fa287beacc9beddce694371f7dc6d86bfd53ef9e627570f2e4

Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use
"kubeadm init phase upload-certs --upload-certs" to reload certs afterward.

Then you can join any number of worker nodes by running the following on each as root:
#word节点执行此命令加入集群
kubeadm join kubeapi.gao.com:6443 --token bdx15c.kgt7so8awbtc234s \
    --discovery-token-ca-cert-hash sha256:891cdb46f640292f089c80f077b59db7f145225cd2850f853edd68668d11a642 


root@k8s-master01:mkdir .kube

root@k8s-master01:cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

root@k8s-master01:kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

root@k8s-master01:kubectl get nodes
NAME           STATUS   ROLES           AGE   VERSION
k8s-master01   Ready    control-plane   24h   v1.28.2
k8s-master02   Ready    control-plane   24h   v1.28.2
k8s-master03   Ready    control-plane   24h   v1.28.2
k8s-node01     Ready    <none>          24h   v1.28.2
k8s-node02     Ready    <none>          24h   v1.28.2
k8s-node03     Ready    <none>          24h   v1.28.2

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。