etcd+calico集群的部署
etcd单机模式
设置环境变量
1
|
export HostIP= "192.168.12.50" |
执行如下命令,打开etcd的客户端连接端口4001和2379、etcd互联端口2380
如果是第一次执行此命令,docker会下载最新的etcd官方镜像
1
2
3
4
5
6
7
8
9
10
|
docker run -d - v /usr/share/ca-certificates/ : /etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \ --name etcd quay.io /coreos/etcd \ -name etcd0 \ -advertise-client-urls http: // ${HostIP}:2379,http: // ${HostIP}:4001 \ -listen-client-urls http: //0 .0.0.0:2379,http: //0 .0.0.0:4001 \ -initial-advertise-peer-urls http: // ${HostIP}:2380 \ -listen-peer-urls http: //0 .0.0.0:2380 \ -initial-cluster-token etcd-cluster-1 \ -initial-cluster etcd0=http: // ${HostIP}:2380 \ -initial-cluster-state new |
选择上面2个端口中的任意一个,检测一下节点情况:
1
|
curl -L http: //127 .0.0.1:2379 /v2/members |
多节点etcd集群
配置多节点etcd集群和单节点类似,最主要的区别是-initial-cluster参数,它表示了各个成员的互联地址(peer url):
节点01执行如下命令:
1
2
3
4
5
6
7
8
9
10
11
|
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 \ --restart=always \ --name etcd quay.io /coreos/etcd \ -name etcd01 \ -advertise-client-urls http: //192 .168.73.140:2379,http: //192 .168.73.140:4001 \ -listen-client-urls http: //0 .0.0.0:2379 \ -initial-advertise-peer-urls http: //192 .168.73.140:2380 \ -listen-peer-urls http: //0 .0.0.0:2380 \ -initial-cluster-token etcd-cluster \ -initial-cluster-state new |
节点02执行如下命令
1
2
3
4
5
6
7
8
9
10
11
|
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 \ --restart=always \ --name etcd quay.io /coreos/etcd \ -name etcd02 \ -advertise-client-urls http: //192 .168.73.137:2379,http: //192 .168.73.137:4001 \ -listen-client-urls http: //0 .0.0.0:2379 \ -initial-advertise-peer-urls http: //192 .168.73.137:2380 \ -listen-peer-urls http: //0 .0.0.0:2380 \ -initial-cluster-token etcd-cluster \ -initial-cluster-state new |
检查集群连接情况,分别在各个节点执行如下命令:
1
|
curl -L http: //127 .0.0.1:2379 /v2/members |
如果正常,将看到2个节点的信息,且在各个节点看到的结果都应该是一样的:
1
|
{ "members" :[{ "id" : "2bd5fcc327f74dd5" , "name" : "etcd01" , "peerURLs" :[ "http://192.168.73.140:2380" ], "clientURLs" :[ "http://192.168.73.140:2379" , "http://192.168.73.140:4001" ]},{ "id" : "c8a9cac165026b12" , "name" : "etcd02" , "peerURLs" :[ "http://192.168.73.137:2380" ], "clientURLs" :[ "http://192.168.73.137:2379" , "http://192.168.73.137:4001" ]}]} |
扩展etcd集群
在集群中的任何一台etcd节点上执行命令,将新节点注册到集群:
1
|
curl http: //127 .0.0.1:2379 /v2/members -XPOST -H "Content-Type: application/json" -d '{"peerURLs": ["http://192.168.73.172:2380"]}' |
在新节点上启动etcd容器,注意-initial-cluster-state参数为existing
1
2
3
4
5
6
7
8
9
10
11
|
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 \ --restart=always \ --name etcd quay.io /coreos/etcd \ -name etcd03 \ -advertise-client-urls http: //192 .168.73.150:2379,http: //192 .168.73.150:4001 \ -listen-client-urls http: //0 .0.0.0:2379 \ -initial-advertise-peer-urls http: //192 .168.73.150:2380 \ -listen-peer-urls http: //0 .0.0.0:2380 \ -initial-cluster-token etcd-cluster \ -initial-cluster "etcd01=http://192.168.73.140:2380,etcd02=http://192.168.73.137:2380,etcd03=http://192.168.73.150:2380" \ -initial-cluster-state existing |
任意节点执行健康检查:
1
2
3
4
|
[root@docker01 ~] # etcdctl cluster-health member 2bd5fcc327f74dd5 is healthy: got healthy result from http: //192 .168.73.140:2379 member c8a9cac165026b12 is healthy: got healthy result from http: //192 .168.73.137:2379 cluster is healthy |
calico部署
现在物理主机下载calicoctl,下载页面:
1
|
https: //github .com /projectcalico/calico-containers/releases |
并将下载的calicoctl复制到/usr/local/bin下面
在第一台etcd节点上执行如下命令:
1
2
3
4
5
6
7
8
9
|
[root@docker01 ~] # calicoctl node #如果是第一次执行该命令,会需要联网下载calico node镜像并启动 Running Docker container with the following command : docker run -d --restart=always --net=host --privileged --name=calico-node -e HOSTNAME=docker01 -e IP= -e IP6= -e CALICO_NETWORKING= true -e AS= -e NO_DEFAULT_POOLS= -e ETCD_AUTHORITY=127.0.0.1:2379 -e ETCD_SCHEME=http - v /var/log/calico : /var/log/calico - v /var/run/calico : /var/run/calico calico /node :v0.18.0 Calico node is running with id : 60b284221a94b418509f86d3c8d7073e11ab3c2a3ca17e4efd2568e97791ff33 Waiting for successful startup No IP provided. Using detected IP: 192.168.73.140 Calico node started successfully |
在第二台etcd节点上执行:
1
2
3
4
5
6
7
8
9
|
[root@Docker01 ~] # calicoctl node --如果是第一次执行该命令,会需要联网下载calico node镜像 Running Docker container with the following command : docker run -d --restart=always --net=host --privileged --name=calico-node -e HOSTNAME=docker01 -e IP= -e IP6= -e CALICO_NETWORKING= true -e AS= -e NO_DEFAULT_POOLS= -e ETCD_AUTHORITY=127.0.0.1:2379 -e ETCD_SCHEME=http - v /var/log/calico : /var/log/calico - v /var/run/calico : /var/run/calico calico /node :v0.18.0 Calico node is running with id : 72e7213852e529a3588249d85f904e38a92d671add3cdfe5493687aab129f5e2 Waiting for successful startup No IP provided. Using detected IP: 192.168.73.137 Calico node started successfully |
在任意一台calico节点上执行如下命令,配置地址资源池:
1
2
3
|
[root@Docker01 ~] # calicoctl pool remove 192.168.0.0/16 #删除默认资源池 [root@Docker01 ~] # calicoctl pool add 10.0.238.0/24 --nat-outgoing --ipip #添加新的IP资源池,支持跨子网的主机上的Docker间网络互通,需要添加--ipip参数;如果要Docker访问外网,需要添加--nat-outgoing参数 [root@docker01 ~] # calicoctl pool show #查看配置后的结果 |
在任意calico节点,检查Calico状态:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@docker01 ~] # calicoctl status calico-node container is running. Status: Up 3 hours Running felix version 1.4.0rc1 IPv4 BGP status IP: 192.168.73.140 AS Number: 64511 (inherited) +----------------+-------------------+-------+----------+-------------+ | Peer address | Peer type | State | Since | Info | +----------------+-------------------+-------+----------+-------------+ | 192.168.73.137 | node-to-node mesh | up | 09:18:51 | Established | +----------------+-------------------+-------+----------+-------------+ IPv6 BGP status No IPv6 address configured. |
配置docker容器网络
分别在2个节点上启动业务一个容器,不加载网络驱动,后面网络让Calico来配置:
1
2
|
[root@docker01 ~] # docker run --name test01 -itd --log-driver none --net none daocloud.io/library/centos:6.6 /bin/bash [root@docker02 ~] # docker run --name test02 -itd --log-driver none --net none daocloud.io/library/centos:6.6 /bin/bash |
在任意的calico节点创建Calico profile:
1
|
[root@docker01 ~] # calicoctl profile add starboss |
通过Calico手动为容器指定ip,注意此ip需要符合calico pool的ip配置:
1
2
3
4
|
[root@docker01 ~] # calicoctl container add test01 10.0.238.10 IP 10.0.238.10 added to test01 [root@docker02 ~] # calicoctl container add test02 10.0.238.11 IP 10.0.238.10 added to test02 |
在各个calico节点上,分别将需要互相访问的节点加入同一个profile:
1
2
3
4
|
[root@docker01 ~] # calicoctl container test01 profile set starboss Profile(s) set to starboss. [root@docker02 ~] # calicoctl container test02 profile set starboss Profile(s) set to starboss. |
在任意节点查看Calico节点的配置情况:
1
2
3
4
5
6
7
|
[root@docker01 ~] # calicoctl endpoint show --detailed +----------+-----------------+------------------------------------------------------------------+----------------------------------+-----------------+-------------------+----------+--------+ | Hostname | Orchestrator ID | Workload ID | Endpoint ID | Addresses | MAC | Profiles | State | +----------+-----------------+------------------------------------------------------------------+----------------------------------+-----------------+-------------------+----------+--------+ | docker01 | docker | 8f935b0441739f52334e9f16099a2b52e2c982e3aef3190e02dd7ce67e61a853 | 75b0e79a022211e6975c000c29308ed8 | 192.168.0.10 /32 | 1e:14:2d:bf:51:f5 | starboss | active | | docker02 | docker | 3d0a8f39753537592f3e38d7604b0b6312039f3bf57cf13d91e953e7e058263e | 8efb263e022211e6a180000c295008af | 192.168.0.11 /32 | ee:2b:c2:5e:b6:c5 | starboss | active | +----------+-----------------+------------------------------------------------------------------+----------------------------------+-----------------+-------------------+----------+--------+ |
测试,在一台物理主机中ping另外一台主机中的容器:
1
2
3
4
5
6
|
[root@docker01 ~] # docker exec test01 ping 192.168.0.11 PING 192.168.0.11 (192.168.0.11) 56(84) bytes of data. 64 bytes from 192.168.0.11: icmp_seq=1 ttl=62 time =0.557 ms 64 bytes from 192.168.0.11: icmp_seq=2 ttl=62 time =0.603 ms 64 bytes from 192.168.0.11: icmp_seq=3 ttl=62 time =0.656 ms
|
etcd+calico集群的部署的更多相关文章
- etcd集群安装部署
1. 集群架构 由于我们只有两个机房,所以选择的是以上图中所示的数据同步方案, 通过做镜像的方式保证两个集群的数据实时同步. 整体架构如上图所示, 整个全局元数据中心包括两套集群,廊坊集群和马驹桥集群 ...
- k8s集群部署之环境介绍与etcd数据库集群部署
角色 IP 组件 配置 master-1 192.168.10.11 kube-apiserver kube-controller-manager kube-scheduler etcd 2c 2g ...
- 高可用Kubernetes集群-5. 部署flannel网络
七.部署flannel网络 kubernetes支持基于vxlan方式的flannel与weave网络,基于BGP路由的Calico网络,本节采用flannel网络. Flannel网络采用etcd等 ...
- Kubernetes集群的部署方式及详细步骤
一.部署环境架构以及方式 第一种部署方式 1.针对于master节点 将API Server.etcd.controller-manager.scheduler各组件进行yum install.编译安 ...
- ProxySQL Cluster 高可用集群环境部署记录
ProxySQL在早期版本若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数据并不能共通,在主实例上配置后,仍需要在备用节点上进行配置,对管理来说非常不方便.但是Proxy ...
- kubernetes学习与实践篇(二) kubernetes1.5 的安装和集群环境部署
kubernetes 1.5 的安装和集群环境部署 文章转载自:http://www.cnblogs.com/tynia/p/k8s-cluster.html 简介: Docker:是一个开源的应用容 ...
- 使用Kubeadm创建k8s集群之部署规划(三十)
前言 上一篇我们讲述了使用Kubectl管理k8s集群,那么接下来,我们将使用kubeadm来启动k8s集群. 部署k8s集群存在一定的挑战,尤其是部署高可用的k8s集群更是颇为复杂(后续会讲).因此 ...
- K8S入门系列之集群二进制部署-->master篇(二)
组件版本和配置策略 组件版本 Kubernetes 1.16.2 Docker 19.03-ce Etcd 3.3.17 https://github.com/etcd-io/etcd/release ...
- K8S集群安装部署
K8S集群安装部署 参考地址:https://www.cnblogs.com/xkops/p/6169034.html 1. 确保系统已经安装epel-release源 # yum -y inst ...
随机推荐
- Source Insight 源代码查看工具
在开发的过程中,有时候我们需要研究源代码,查看源码是一个好的习惯,能帮我们学到很多的东西,比如JDK可以帮助我们理解很多设计模式在实际开发中的应用,又或者android开发者,源代码更是必不可少的,当 ...
- Install Tomcat 7 on CentOS, RHEL, or Fedora
linux下的 Tomcat 安装: http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos
- STL源码剖析——hashtable
二叉搜索树具有对数时间的搜索复杂度,但是这样的复杂度是再输入数据有足够的随机性的假设上哈希表在插入删除搜索操作上也具有常数时间的表现,而且这种表现是以统计为基础,不需要依赖输入元素的随机性 hasht ...
- iOS开源项目:JSONKit
一个Json解析库,其特点是代码简单,只有一个.h和.m文件. https://github.com/johnezang/JSONKit JSON(JavaScript Object Notation ...
- JavaScript获得页面区域大小的代码
var Client = { viewportWidth: function() { return self.innerWidth || (document.documentE ...
- java中构建同时兼容linux和windows程序时遇到的文件路径分割符问题解决方案
最近在做一个自动上传文件的客户端,因为 file.getAbsolutePath() 在Mac和linux下的分割符是“/”,而在windows操作系统下的分割符则是“\”,我们程序中固然可以通过调 ...
- object sender, LinkLabelLinkClickedEventArgs e 参数解释
开始是一个LinkLabel 控件,LinkLabel 绑定了Clicke事件 LinkLabel Delete = new LinkLabel(); Delete.Text = "删除&q ...
- source insight中{}自动缩进的调整
默认的自动缩进非常难看,解决方法如下: 菜单栏 -> Options -> document options ->点击右侧的 “Auto Indent...”按钮 将右侧" ...
- win7 配置IIS + php 环境
一:开启win7 的IIS功能:并开启 CGI 二:下载php5 for windows 解压 三:打开IIS --->>处理程序映射- 参考:http://php.net/manual/ ...
- hdu2444 The Accomodation of Students(推断二分匹配+最大匹配)
//推断是否为二分图:在无向图G中,假设存在奇数回路,则不是二分图.否则是二分图. //推断回路奇偶性:把相邻两点染成黑白两色.假设相邻两点出现颜色同样则存在奇数回路. 也就是非二分图. # incl ...