(十一)flannel 概述

​ flannel 是 CoreOS 开发的容器网络解决方案。flannel 为每个 host 分配一个 subnet,容器从此 subnet 中分配 IP,这些 IP 可以在 host 间路由,容器间无需 NAT 和 port mapping 就可以跨主机通信。

​ 每个 subnet 都是从一个更大的 IP 池中划分的,flannel 会在每个主机上运行一个叫 flanneld 的 agent,其职责就是从池子 中分配 subnet。为了在各个主机间共享信息,flannel 用 etcd(与 consul 类似的 key-value 分布式数据库)存放网络配置、已分配的 subnet、host 的 IP 等信息。

​ 数据包如何在主机间转发是由 backend 实现的。flannel 提供了多种 backend,最常用的有 vxlan 和 host-gw,我们将在本章讨论这两种 backend。其他 backend 请参考 https://github.com/coreos/flannel。接下来我们就开始实践 flannel。

(1)实验环境描述

本章实验环境如图所示:

flannel<etcd>flannel

etcd 部署在 10.0.0.20,host1 和 host2 上运行 flanneld,首先安装配置 etcd。

(2)安装配置 etcd

在 10.0.0.20上运行如下脚本:

ETCD_VER=v2.3.7

DOWNLOAD_URL=https://github.com/coreos/etcd/releases/download

curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz

mkdir -p /tmp/test-etcd && tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/test-etcd --strip-components=1
cp /tmp/test-etcd/etcd* /usr/local/bin/

该脚本从 github 上下载 etcd 的可执行文件并保存到 /usr/local/bin/,启动 etcd 并打开 2379 监听端口。

etcd -listen-client-urls http://10.0.0.20:2379 -advertise-client-urls http://10.0.0.20:2379

测试 etcd 是否可用:

root@ubuntu-01:/tmp/test-etcd# etcdctl --endpoints=10.0.0.20:2379 set foo "bar"
bar
root@ubuntu-01:/tmp/test-etcd# etcdctl --endpoints=10.0.0.20:2379 get foo
bar
root@ubuntu-01:/tmp/test-etcd# 

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/cuiyongchao007/p/14110152.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!