AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1011197
Accepted
TJ Zimmerman
TJ Zimmerman
Asked: 2020-04-07 14:25:57 +0800 CST2020-04-07 14:25:57 +0800 CST 2020-04-07 14:25:57 +0800 CST

在 RHEL 7 上使用 Kubeadm 引导 Kubernetes 集群 - 防火墙问题

  • 772

我正在尝试在 RHEL 7.8 上引导 Kubernetes 集群,但我的防火墙出现了一些问题。

nftablesKubernetes不支持,iptables-legacy必须安装。虽然该iptables-legacy软件包存在于 Debian Buster 等发行版中,但它似乎不适用于 RHEL 7。但是,本文提到了安装iptables-services、禁用firewalld和启用iptables。文章中的相关材料是:

yum install iptables-services.x86_64 -y
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl mask firewalld.service
systemctl start iptables
systemctl enable iptables
systemctl unmask iptables
iptables -F
service iptables save

在此之后,如果我iptables --version在服务器上运行,我可以看到它1.4.2已安装。由于这比上面链接的 GitHub 问题所暗示的 1.8 旧,所以这个版本应该没问题。

在kubeadm join从我的工作节点运行之前,以下 Ansible 任务针对我的主节点运行以配置iptables:

- iptables:
    chain: INPUT
    destination_port: "{{ port }}"
    jump: ACCEPT
    protocol: tcp
  loop:
    - 6443
    - 2379:2380
    - 10250:10252
  loop_control:
    loop_var: port

- command: service iptables save

- systemd:
    name: iptables
    state: restarted

这对我的节点进行配置iptables:

- iptables:
    chain: INPUT
    destination_port: "{{ port }}"
    jump: ACCEPT
    protocol: tcp
  loop:
    - 10250
    - 30000:32767
  loop_control:
    loop_var: port

- command: service iptables save

- systemd:
    name: iptables
    state: restarted

在此之后,我可以确认该规则存在于内存中:

$> iptables -S | grep 6443
-A INPUT -p tcp -m tcp --dport 6443 -j ACCEPT

然后,当我kubeadm join从工作节点运行时,它无法连接:

I0406 22:07:19.205714    5715 token.go:73] [discovery] Created cluster-info discovery client, requesting info from "https://192.168.50.10:6443"
I0406 22:07:19.206720    5715 token.go:78] [discovery] Failed to request cluster info: [Get https://192.168.50.10:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s: dial tcp 192.168.50.10:6443: connect: no route to host]
I0406 22:07:19.206749    5715 token.go:191] [discovery] Failed to connect to API Server "192.168.50.10:6443": Get https://192.168.50.10:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s: dial tcp 192.168.50.10:6443: connect: no route to host
I0406 22:07:24.207648    5715 token.go:188] [discovery] Trying to connect to API Server "192.168.50.10:6443

但是,如果我systemctl stop iptables在主节点上,那么工作节点可以毫无问题地加入。向我表明主服务器上的防火墙配置错误?

redhat iptables kubernetes ansible kubeadm
  • 1 1 个回答
  • 484 Views

1 个回答

  • Voted
  1. Best Answer
    TJ Zimmerman
    2020-04-08T13:58:08+08:002020-04-08T13:58:08+08:00

    Ansible 模块默认iptables使用该append操作。这导致reject规则不在应有的位置。添加action: insert到我iptables在 Ansible 中的任务解决了这个问题。

    • 1

相关问题

  • 如何设置 Redhat 对 ActiveDirectory 的用户进行身份验证

  • 如何从 RHEL 5 迁移到 CentOS 5?

  • 我应该将 Rails 应用程序部署到哪个目录?

  • 如何移动 MySQL 的数据目录?

  • RHEL 5.3 上可用的 yum 存储库

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve