实践展示openEuler部署Kubernetes 1.29.4版本集群

打印 上一主题 下一主题

主题 996|帖子 996|积分 2988

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本文分享自华为云社区《openEuler部署Kubernetes 1.29.4版本集群》,作者:江晚正愁余。
一、Kubernetes集群节点准备

1.1 主机操作系统说明

序号 操作系统及版本 备注
1 CentOS7u9或 OpenEuler2203
1.2 主机硬件设置说明

需求 CPU 内存 硬盘 脚色 主机名
值 8C 8G 1024GB master k8s-master01
值 8C 16G 1024GB worker(node) k8s-worker01
值 8C 16G 1024GB worker(node) k8s-worker02
1.3 主机设置

1.3.1 主机名设置

由于本次利用3台主机完成kubernetes集群部署,其中1台为master节点,名称为k8s-master01;其中2台为worker节点,名称分别为:k8s-worker01及k8s-worker02
  1. # master节点
  2. hostnamectl set-hostname k8s-master01
  3. #worker01节点
  4. hostnamectl set-hostname k8s-worker01
  5. #worker02节点
  6. hostnamectl set-hostname k8s-worker02
复制代码
1.3.2 IP地址,名称解析与互信
  1. #IP配置这里不再讲解
  2. #下面是名称解析配置
  3. [root@k8s-master01 ~]# cat /etc/hosts
  4. 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
  5. ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
  6. 192.168.0.11 k8s-master01
  7. 192.168.0.12 k8s-worker01
  8. 192.168.0.13 k8s-worker02
  9. #主机互信配置  
  10. [root@k8s-master01 ~]# ssh-keygen
  11. Generating public/private rsa key pair.
  12. Enter file in which to save the key (/root/.ssh/id_rsa):
  13. Enter passphrase (empty for no passphrase):
  14. Enter same passphrase again:
  15. Your identification has been saved in /root/.ssh/id_rsa
  16. Your public key has been saved in /root/.ssh/id_rsa.pub
  17. The key fingerprint is:
  18. SHA256:Rr6W4rdnY350fzMeszeWFR/jUJt0VOZ3yZECp5VJJQA root@k8s-master01
  19. The key's randomart image is:
  20. +---[RSA 3072]----+
  21. |         E.o+=++*|
  22. |            ++o*+|
  23. |        .  .  +oB|
  24. |       o     . *o|
  25. |        S     o =|
  26. |       . o  . ..o|
  27. |      . +  . . +o|
  28. |     . o. = .  *B|
  29. |      ...*.o  oo*|
  30. +----[SHA256]-----+
  31. [root@k8s-master01 ~]# for i in {11..13};do ssh-copy-id 192.168.0.${i};done
  32. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
  33. The authenticity of host '192.168.0.11 (192.168.0.11)' can't be established.
  34. ED25519 key fingerprint is SHA256:s2R582xDIla4wyNozHa/HEmRR7LOU4WAciEcAw57U/Q.
  35. This key is not known by any other names
  36. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  37. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  38. /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  39. Authorized users only. All activities may be monitored and reported.
  40. root@192.168.0.11's password:
  41. Number of key(s) added: 1
复制代码
1.3.4 防火墙设置

所有主机均需要操作。
关闭现有防火墙firewalld
  1. # systemctl disable firewalld
  2. # systemctl stop firewalld
复制代码
  1. systemctl disable --now firewalld
复制代码
查看firewalld状态
  1. # firewall-cmd --state
  2. not running
复制代码
参考运行下令:
  1. [root@k8s-master01 ~]# for i in {11..13};do ssh  192.168.0.${i} 'systemctl disable --now firewalld' ;done
  2. Authorized users only. All activities may be monitored and reported.
  3. Authorized users only. All activities may be monitored and reported.
  4. Authorized users only. All activities may be monitored and reported.
  5. [root@k8s-master01 ~]# for i in {11..13};do ssh  192.168.0.${i} 'firewall-cmd --state' ;done
  6. Authorized users only. All activities may be monitored and reported.
  7. not running
  8. Authorized users only. All activities may be monitored and reported.
  9. not running
  10. Authorized users only. All activities may be monitored and reported.
  11. not running
复制代码
1.3.5 SELINUX设置

所有主机均需要操作。修改SELinux设置需要重启操作系统。
  1. # sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
  2. # sestatus
复制代码
参考运行下令:
  1. [root@k8s-master01 ~]# for i in {11..13};do ssh  192.168.0.${i} 'sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config' ;done
  2. Authorized users only. All activities may be monitored and reported.
  3. Authorized users only. All activities may be monitored and reported.
  4. Authorized users only. All activities may be monitored and reported.
  5. [root@k8s-master01 ~]# for i in {11..13};do ssh  192.168.0.${i} 'sestatus' ;done
  6. Authorized users only. All activities may be monitored and reported.
  7. SELinux status:                 disabled
  8. Authorized users only. All activities may be monitored and reported.
  9. SELinux status:                 disabled
  10. Authorized users only. All activities may be monitored and reported.
  11. SELinux status:                 disabled
复制代码
1.3.6 时间同步设置

所有主机均需要操作。最小化安装系统需要安装ntpdate软件。
  1. # crontab -l
  2. 0 */1 * * * /usr/sbin/ntpdate time1.aliyun.com
  3. for i in {11..13};do ssh  192.168.0.${i} ' echo '0 */1 * * * /usr/sbin/ntpdate time1.aliyun.com' >> /etc/crontab' ;done
  4. #设置上海时区,东八区
  5. timedatectl set-timezone Asia/Shanghai
  6. for i in {11..13};do ssh  192.168.0.${i} ' timedatectl set-timezone Asia/Shanghai' ;done
复制代码
1.3.7 升级操作系统内核

centos系统需要升级内容,详细百度,OpenEuler2203不需要
1.3.8 设置内核路由转发及网桥过滤

所有主机均需要操作。
添加网桥过滤及内核转发设置文件
[code]sed -i 's/net.ipv4.ip_forward=0/net.ipv4.ip_forward=1/g' /etc/sysctl.conf# cat > /etc/sysctl.d/k8s.conf
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

不到断气不罢休

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表