gpt4 book ai didi

ubuntu - 安装 Flannel 后 Kubeadm join 不起作用

转载 作者:行者123 更新时间:2023-12-04 19:06:35 25 4
gpt4 key购买 nike

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












我们不允许在 Stack Overflow 上提出有关专业服务器或网络相关基础设施管理的问题。您可以编辑问题,使其成为 on-topic对于堆栈溢出。


去年关闭。







Improve this question




我正在学习如何从 here 在 ubuntu 服务器上安装 kubernetes 多节点集群的教程。 .我正在安装法兰绒而不是印花布。我可以看到法兰绒安装正确,但我无法从工作节点加入集群。这是我的文件:
托管来自 /etc/ansible/hosts 的文件:

[workernodes]
X.X.X.X(PUBLIC IP) node_name=worker2 node_internal_ip=10.132.0.16
X.X.X.X(PUBLIC IP) node_name=worker3 node_internal_ip=10.132.0.19
[masternodes]
X.X.X.X(PUBLIC IP) node_name=master node_internal_ip=10.132.0.15
这是我的 master-playbook.yml :
---
- hosts: masternodes
become: true
tasks:

- name: Remove swapfile from /etc/fstab
mount:
name: "{{ item }}"
fstype: swap
state: absent
with_items:
- swap
- none

- name: Disable swap
command: swapoff -a
when: ansible_swaptotal_mb > 0

- name: Letting iptables see bridged traffic
shell: |
sudo modprobe br_netfilter
lsmod | grep br_netfilter


- name: Install packages that allow apt to be used over HTTPS
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common

- name: Add an apt signing key for Docker
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present

- name: Add apt repository for stable version
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present

- name: Install docker and its dependecies
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- docker-ce
- docker-ce-cli
- containerd.io
notify:
- docker status

# Kubelet, kubeadm, kubec
- name: Add an apt signing key for Kubernetes
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present

- name: Adding apt repository for Kubernetes
apt_repository:
repo: deb https://apt.kubernetes.io/ kubernetes-xenial main
state: present
filename: kubernetes.list

- name: Install Kubernetes binaries
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- kubelet
- kubeadm
- kubectl

- name: Configure node ip
lineinfile:
path: /etc/default/kubelet
line: KUBELET_EXTRA_ARGS=--node-ip={{ node_internal_ip }}
create: yes

- name: Restart kubelet
service:
name: kubelet
daemon_reload: yes
state: restarted


- name: Initialize the Kubernetes cluster using kubeadm
command: kubeadm init --apiserver-advertise-address="{{ node_internal_ip }}" --node-name "{{ node_name }}" --pod-network-cidr="{{ pod_network_cidr }}"

- name: Setup kubeconfig for "{{ user_name }}" user
command: "{{ item }}"
with_items:
- mkdir -p /home/"{{ user_name }}"/.kube
- cp -i /etc/kubernetes/admin.conf /home/"{{ user_name }}"/.kube/config
- chown "{{ user_name }}":"{{ user_name }}" /home/"{{ user_name }}"/.kube/config

- name: Install Flannel pod network
become: false
shell: kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

- name: Generate join command
command: kubeadm token create --print-join-command
register: join_command

- name: Copy join command to local file
local_action: copy content="{{ join_command.stdout_lines[0] }}" dest="./join-command"

handlers:
- name: docker status
service: name=docker state=started
这是我的 worker-playbook.yml :
---
- hosts: workernodes
become: true
tasks:

- name: Remove swapfile from /etc/fstab
mount:
name: "{{ item }}"
fstype: swap
state: absent
with_items:
- swap
- none

- name: Disable swap
command: swapoff -a
when: ansible_swaptotal_mb > 0

- name: Letting iptables see bridged traffic
shell: |
sudo modprobe br_netfilter
lsmod | grep br_netfilter


- name: Install packages that allow apt to be used over HTTPS
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common

- name: Add an apt signing key for Docker
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present

- name: Add apt repository for stable version
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present

- name: Install docker and its dependecies
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- docker-ce
- docker-ce-cli
- containerd.io
notify:
- docker status

- name: Add an apt signing key for Kubernetes
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present

- name: Adding apt repository for Kubernetes
apt_repository:
repo: deb https://apt.kubernetes.io/ kubernetes-xenial main
state: present
filename: kubernetes.list

- name: Install Kubernetes binaries
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- kubelet
- kubeadm
- kubectl

- name: Configure node ip
lineinfile:
path: /etc/default/kubelet
line: KUBELET_EXTRA_ARGS=--node-ip={{ node_internal_ip }}
create: yes

- name: Restart kubelet
service:
name: kubelet
daemon_reload: yes
state: restarted

- name: Copy the join command to server location
copy: src=join-command dest=/tmp/join-command.sh mode=0777

- name: Join the node to cluster
shell: |
echo " --node-name {{ node_name }}" >> /tmp/join-command.sh
sh /tmp/join-command.sh

handlers:
- name: docker status
service: name=docker state=started
我正在使用 pod_network_cidr="10.132.0.0/20还。当我第一次运行 master-playbook 和 worker-playbook 时,worker-nodes 卡在了 join 部分。
这里是 kubectl get pods --all-namespaces日志:
kube-system   coredns-558bd4d5db-mlw6r                             1/1     Running   0          2m3s
kube-system coredns-558bd4d5db-r4ptb 1/1 Running 0 2m4s
kube-system etcd.master-0 1/1 Running 0 2m18s
kube-system kube-apiserver.master-0 1/1 Running 0 2m18s
kube-system kube-controller-manager.master-0 1/1 Running 0 2m21s
kube-system kube-flannel-ds-tvvdl 1/1 Running 0 2m4s
kube-system kube-proxy-pwb7h 1/1 Running 0 2m4s
kube-system kube-schedulerr-0 1/1 Running 0 2m18s
但是在尝试了 worker-node 中的 join 命令后,我收到了这个错误:
Failed to request cluster-info, will try again: Get "https://10.132.0.15:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s": net/http: re
quest canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
防火墙已正确打开,但我无法从工作节点 ping 到主节点。
请问各位大侠能帮忙吗?

最佳答案

根据 documentation您应该记住,您的 Pod 网络不得与任何主机网络重叠:如果有任何重叠,您可能会看到问题。此外,考虑到您使用的是 Flannel 而不是 Calico,请记住它们似乎在 .yaml 文件中指定了不同的 CIDR 范围 - 10.244.0.0/16 for Flannel192.168.0.0/16 for Calico并且 .yaml 文件中的 CIDR 范围应与您在设置期间指定的范围相匹配。

关于ubuntu - 安装 Flannel 后 Kubeadm join 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67967781/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com