centos7安装k8s 1.24.3版本 Error getting node“ err=“node “master01“ not found

2023-11-17

简介

kubernetes 1.24.0以上版本已经移除了docker cri,因此在使用的docker来的安装k8s时,你需要自己安装cri-docker

名词解释

  • cri:容器运行时,这个东东是用来在pod中控制容器的

服务器最低配置要求

  • cpu:2核心
  • 内存:2G

服务器上设置

  • 关闭swap
  • 关闭firewalld
  • 禁用selinux
  • 启用br_netfilter模块
  • 6443端口

必要服务

  • docker 每个节点必须
  • iptables 每个节点必须
  • cri-docker 每个节点必须:注意:启动服务时需要指定–pod-infra-container-image选项,否则可能导致初始化失败
  • kubelet 每个节点必须
  • kubeadm 每个节点必须
  • kubectl 按需安装,用来的与集群交互

服务器初始化

以下为ansible的剧本,cri-docker.service设置部分没写,自己搞搞

---
- hosts: localhost
  remote_user: root
  tasks:
   - name: 关闭firewalld并且取消开机启动
     systemd:
      enabled: FALSE
      state: stopped
      name: firewalld.service

   - name: 永久关闭selinux
     lineinfile:
      dest: /etc/selinux/config
      regexp: "^SELINUX="
      line: "SELINUX=disabled"

   - name: 临时关闭selinux
     shell: "setenforce 0"
     failed_when: FALSE

   - name: 关闭swap
     shell: "swapoff -a && sed -i 's/^[^#]*swap/#&/g' /etc/fstab"

   - name: 安装yum-utils
     yum: name=yum-utils state=present

   - name: 添加docker-ce repo文件
     shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

   - name: 安装docker
     shell: yum install docker-ce -y

   - name: 创建/root/cri目录
     file:
       state: directory
       path: /root/cri

   - name: 拷贝cri-docker rpm包
     copy:
      src: /root/cri/cri-dockerd-0.2.5-3.el7.x86_64.rpm
      dest: /root/cri/cri-dockerd-0.2.5-3.el7.x86_64.rpm

   - name: 安装cri-docker
     shell: rpm -ivh /root/cri/cri-dockerd-0.2.5-3.el7.x86_64.rpm 
  
   - name: 创建k8s.config文件
     shell:
      cmd: |
       cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
       overlay
       br_netfilter
       EOF

   - name: 安装overlay模块
     shell: sudo modprobe overlay

   - name: 安装br_netfilter模块
     shell: sudo modprobe br_netfilter

   - name: 设置所需的 sysctl参数,参数在重新启动后保持不变
     shell:
      cmd: |
        cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
        net.bridge.bridge-nf-call-iptables  = 1
        net.bridge.bridge-nf-call-ip6tables = 1
        net.ipv4.ip_forward                 = 1
        EOF

   - name: 应用 sysctl 参数而不重新启动
     shell: sudo sysctl --system
   - name: 创建k8s.config文件 
     shell:
      cmd: |
       cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
       overlay
       br_netfilter
       EOF

   - name: 安装overlay模块
     shell: sudo modprobe overlay

   - name: 安装br_netfilter模块
     shell: sudo modprobe br_netfilter

   - name: 设置所需的 sysctl参数,参数在重新启动后保持不变
     shell:
      cmd: |
        cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
        net.bridge.bridge-nf-call-iptables  = 1
        net.bridge.bridge-nf-call-ip6tables = 1
        net.ipv4.ip_forward                 = 1
        EOF

   - name: 应用 sysctl 参数而不重新启动
     shell: sudo sysctl --system

cri-docker rpm包下载地址

https://github.com/Mirantis/cri-dockerd/releases/tag/v0.2.5

kubeadm 初始化文件init.yaml

此文件可命令kubeadm config print init-defaults生成,生产以后按自己实际情况修改文件,不要抄!

apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
  - system:bootstrappers:kubeadm:default-node-token
  token: abcdef.0123456789abcdef
  ttl: 24h0m0s
  usages:
  - signing
  - authentication
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: 192.168.100.101  #改成你自己的IP地址
  bindPort: 6443
nodeRegistration:
  criSocket: unix:///run/cri-dockerd.sock #改成这个套接字
  imagePullPolicy: IfNotPresent
  name: master01  #改成你自己的主机名
  taints: null
---
apiServer:
  timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns: {}
etcd:
  local:
    dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: 1.24.3
networking:
  dnsDomain: cluster.local
  serviceSubnet: 10.96.0.0/12
scheduler: {}

拉取必要镜像

kubeadm config images list命令可以查看1.24.3版本需要的镜像文件
国内仓库:registry.aliyuncs.com/google_containers
注意:etcd在registry.aliyuncs.com/google_containers仓库中可能找不到,可以上dockerhub上找找

[root@master01 ~]# kubeadm config images list
k8s.gcr.io/kube-apiserver:v1.24.3
k8s.gcr.io/kube-controller-manager:v1.24.3
k8s.gcr.io/kube-scheduler:v1.24.3
k8s.gcr.io/kube-proxy:v1.24.3
k8s.gcr.io/pause:3.7
k8s.gcr.io/etcd:3.5.3-0
k8s.gcr.io/coredns/coredns:v1.8.6

拉取指定仓库的镜像

kubeadm config images pull --image-repository="registry.aliyuncs.com/google_containers" --cri-socket="unix:///run/cri-dockerd.sock"

注意事项

安装好cri-docker 以后,直接kubeadm init --config init.yaml 会提示超时,查看kubelet日志会提示找不到节点
这时,你需要配置cri-docker.service文件,ExecStart=/usr/bin/cri-dockerd项后面指定你的指定你的pause版本,
例如:–pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.7
错误如下

Error getting node" err="node \"master01\" not found

解决方法

[root@master01 ansible]# cat /usr/lib/systemd/system/cri-docker.service 
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket

[Service]
Type=notify
ExecStart=/usr/bin/cri-dockerd --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.7 --container-runtime-endpoint fd://
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
Delegate=yes
KillMode=process

[Install]
WantedBy=multi-user.target

完成后重启cri-service服务

[root@master01 ~]# systemctl daemon-reload && systemctl restart cri-docker.service

此时在此运算kubeadm init 就能成功初始化集群

reset集群

与以往不同的是需要指定一下cri-socket

[root@master01 ~]# kubeadm reset --cri-socket="unix:///run/cri-dockerd.sock" --v=5

tmux

拉取镜像时需要很长时间,避免长时间不操作导致远程断开,你可以在tmux中执行,非常好用的小工具,建议安装
文档

部署CNI

可选CNI方案有如下几种

$ kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

centos7安装k8s 1.24.3版本 Error getting node“ err=“node “master01“ not found 的相关文章

随机推荐

  • VScode的PHP远程调试模式Xdebug

    目录 第一步 安装VScode中相应插件 remote ssh的原理 ssh插件 PHP相关插件 第二步 安装对应PHP版本的xdebug 查看PHP具体配置信息的phpinfo页面 1 首先 打开php编辑器 新建一个php文件 例如 i
  • CentOS7下rsync实现服务器之间实时同步

    rsync简介 rsync是类unix系统下的数据镜像备份工具 使用快速增量备份工具Remote Sync可以远程同步 支持本地复制 或者与其他SSH rsync主机同步 文章主讲实际操作 不再进行详细叙述 想要了解更多可以查看百度百科 一
  • QT 编译报错“QWidget: Must construct a QApplication before a QWidget”

    一 错误原因 1 在构造QApplication之前创建了部件 某个类或者其子类中采用了静态的qWidget或者其子类 由于静态或者全局对象在 main 之前就产生了 所以 早于main 里的QApplication对象 2 混用 debu
  • Python实现敏感词过滤

    在我们生活中的一些场合经常会有一些不该出现的敏感词 我们通常会使用 去屏蔽它 例如 尼玛 gt 一些骂人的敏感词和一些政治敏感词都不应该出现在一些公共场合中 这个时候我们就需要一定的手段去屏蔽这些敏感词 下面我来介绍一些简单版本的敏感词屏蔽
  • 【面试真题】今日头条大数据面试100题,收藏备用

    1 简述WordCount 的实现过程 2 简述MapReduce与 Spark 的区别与联系 3 Spark 在客户端与集群运行的区别 4 相同的 SQL 在 HiveSql 与 SparkSQL 的实现中 为什么 Spark 比 Had
  • Android MVC、MVP、MVVM、MVI架构对比及示例

    随着Android应用开发技术的不断成熟 应用功能越来越丰富 迭代速度要求的越来越高 应用的开发架构也在不断演进 优化 从MVC MVP到MVVM 到如今的MVI 谷歌官方也在不断推广 优化适合Android平台的开发架构 并推出了一系列的
  • centos7部署openwhisk

    实验环境 Openwhisk 192 168 1 36 make lean部署 Fn project 192 168 1 35 Openwhisk核心提炼 环境准备 nodejs12 curl sL https rpm nodesource
  • RateLimiter 的底层实现是啥?

    点击上方 Java基基 选择 设为星标 做积极的人 而不是积极废人 源码精品专栏 原创 Java 2020 超神之路 很肝 中文详细注释的开源项目 RPC 框架 Dubbo 源码解析 网络应用框架 Netty 源码解析 消息中间件 Rock
  • 本地docker搭建jupyter运行环境

    1 容器操作 1 拉取镜像 docker pull ubuntu 2 创建容器 创建容器时要先考虑好自己要开设几个端口 要提前指定好映射关系 docker run dit name LocalDocker p 3303 8888 p 330
  • proteus设计教程-DS1302时钟芯片驱动程序

    时钟芯片DS1302电路图如下 晶振X1的频率为32 768khz 读写时间只需要调用void read time void write time 两个函数进行操作 直接读取出来的数据是BCD码的形式 需要进行转换 最后提供的两个函数to
  • TypeError: 'float' object is not callable报错及解决方案

    今天进行scikit learn的特征选择实验时 一段非常短的代码不知为何总是报错 代码如下 Filename FeatureV1 py from sklearn feature selection import VarianceThres
  • form表单上传数据的三种方式(ajax传递 / FormData文件 / serialize序列化传递 )

    Form表单数据上传 前言 一 HTML结构 下方所有上传方式 都依托这个结构 二 通过post请求的形式 直接传递对应的参数数据 三 formData上传数据 文本 文件 视频 图片等 四 form表单数据序列化 serialize将传递
  • du命令_set命令选项

    文章目录 set 选项 du set 选项 set e 当脚本中任何一个命令执行返回的状态码不为0时就退出整个脚本 默认脚本运行中某行报错会继续往下执行 set u 当脚本在执行过程中尝试使用未定义过的变量时 报错并退出运行整个脚本 默认会
  • 框架理解(Unity(C#))

    文章目录 前言 一 什么是框架 二 怎么做框架 这里讲的是Unity C 1 沟通后端的url集合 理解为数据集 命名空间 接口也理解为数据集 3 做协程或方法 理解为具体方法的实现集 3 用委托的方法去做 理解为预备方法集 总结 为什么做
  • Meetup 回顾|Data Infra 研究社第十期(含资料发布)

    Data Infra 第 10 期的活动于上周六 4月1日 圆满落幕 此次直播活动的两大主题分别是 漫谈时序数据库的设计 和 云原生数仓产品 Greptime 联合创始人 冯家纯 Databend 优化器负责人 雷宇分别为本次活动分享了他们
  • 轻松将C语言/C++程序打包成安装包,和大家分享你的成果(包学包会)

    轻松将C语言 C 程序打包成安装包 首先 老样子 将我们要用到的程序给大家展示一下 并放在我的资源里https download csdn net download qq 51523386 14040313 不收积分 这波细心不带给个赞 嘿
  • 工作3年,被辞退了,这份测试人防优化指南你一定要知道...

    作为一个普通的测试人员 在现在竞争激烈的职场 我们应该怎么做才能防止被优化 被公司及时代淘汰 应该不断的增强自身能力 让我们不是那么容易被取代 只能通过不停的学习 增强自身技术能力 加深对所做行业的理解 那我们应该从哪些方面来增强呢 1 熟
  • Vue G6 自定义组件 可视化树形图搭建,紧凑型,可直接复用

    话不多说 直接上图 效果图如上 代码如下 template
  • sql注入语句万能密码_sql注入——万能密码

    通过两个ctf题来做讲解 第一个很简单 第二个多了些限制 http lab1 xseclab com sqli2 3265b4852c13383560327d1c31550b60 index php http ctf5 shiyanbar
  • centos7安装k8s 1.24.3版本 Error getting node“ err=“node “master01“ not found

    简介 kubernetes 1 24 0以上版本已经移除了docker cri 因此在使用的docker来的安装k8s时 你需要自己安装cri docker 名词解释 cri 容器运行时 这个东东是用来在pod中控制容器的 服务器最低配置要