当前位置:   article > 正文

K8S1.21集群搭建_unknown field "localapiendpoint.name", unknown fie

unknown field "localapiendpoint.name", unknown field "localapiendpoint.noder

ku1. 环境配置

(1)关闭防火墙

  1. sudo systemctl disable firewalld
  2. sudo systemctl stop firewalld

(2)关闭selinux

  1. sudo setenforce 0
  2. # 永久关闭 修改/etc/sysconfig/selinux文件设置
  3. sudo sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux
  4. sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

(3)禁用交换分区

  1. sudo swapoff -a
  2. # 永久禁用,打开/etc/fstab注释掉swap那一行。
  3. sudo sed -i 's/.*swap.*/#&/' /etc/fstab

(4)修改内核参数

对于master节点:

  1. sudo vim /etc/sysctl.d/k8s.conf
  2. net.ipv4.ip_forward = 1
  3. net.bridge.bridge-nf-call-ip6tables = 1
  4. net.bridge.bridge-nf-call-iptables = 1
  5. net.ipv6.conf.all.disable_ipv6 = 1
  6. net.ipv6.conf.default.disable_ipv6 = 1
  7. net.ipv6.conf.lo.disable_ipv6 = 1
  8. net.ipv6.conf.all.forwarding = 1
  9. vm.swappiness = 0
  10. sudo sysctl --system

对于node节点:

  1. sudo vim /etc/sysctl.d/k8s.conf
  2. net.bridge.bridge-nf-call-ip6tables = 1
  3. net.bridge.bridge-nf-call-iptables = 1
  4. sudo sysctl --system

验证是否生效,均返回 1 即正确:

  1. sysctl -n net.bridge.bridge-nf-call-iptables
  2. sysctl -n net.bridge.bridge-nf-call-ip6tables

2. master节点环境准备

(1)安装kubeadm,kubectl,kubelet和部署镜像

  1. #!/bin/sh
  2. cat <<EOF > /etc/yum.repos.d/kubernetes.repo
  3. [kubernetes]
  4. name=Kubernetes
  5. baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
  6. enabled=1
  7. gpgcheck=1
  8. repo_gpgcheck=1
  9. gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
  10. EOF
  11. #安装kubeadm、kubelet、kubectl,注意这里默认安装当前最新版本v1.14.1:
  12. yum install -y kubeadm-1.21.3-0 kubelet-1.21.3-0 kubectl-1.21.3-0
  13. #yum install -y kubeadm kubelet kubectl
  14. systemctl enable kubelet && systemctl start kubelet
  15. # pull all images that k8s needs
  16. ver=v1.21.3
  17. registry=registry.cn-hangzhou.aliyuncs.com/google_containers
  18. images=`kubeadm config images list --kubernetes-version=$ver |awk -F '/' '{print $2}'`
  19. for image in $images
  20. do
  21. if [ $image != coredns ];then
  22. docker pull ${registry}/$image
  23. if [ $? -eq 0 ];then
  24. docker tag ${registry}/$image k8s.gcr.io/$image
  25. docker rmi ${registry}/$image
  26. else
  27. echo "ERROR: 下载镜像报错,$image"
  28. fi
  29. else
  30. docker pull coredns/coredns:1.8.0
  31. docker tag coredns/coredns:1.8.0 k8s.gcr.io/coredns/coredns:v1.8.0
  32. docker rmi coredns/coredns:1.8.0
  33. fi
  34. done

https://www.wpsshop.cn/w/寸_铁/article/detail/937199

推荐阅读
相关标签
  

闽ICP备14008679号