calico实现docker容器内部的网络链接

 

 

 

calico官网

https://www.projectcalico.org//

calico介绍

http://www.sdnlab.com/17161.html

 

calico网络

环境

系统   centos 7.2

ip      10.0.0.51

IP      10.0.0.61

1.下载etcd

 wget https://github.com/coreos/etcd/releases/download/v3.0.4/etcd-v3.0.4-linux-amd64.tar.gz

tar xf etcd-v3.0.4-linux-amd64.tar.gz

cd etcd-v3.0.4-linux-amd64

cp etcd /usr/bin/etcd && cp etcdctl /usr/bin/etcdctl

2.链接etcd集群

calico1执行

etcd --name infra0   --initial-advertise-peer-urls http://10.0.0.51:2380   --listen-peer-urls http://10.0.0.51:2380   --listen-client-urls http://10.0.0.51:2379,http://127.0.0.1:2379   --advertise-client-urls http://10.0.0.51:2379   --initial-cluster-token etcd-cluster-1   --initial-cluster infra0=http://10.0.0.51:2380,infra1=http://10.0.0.61:2380   --initial-cluster-state new &

 

calico2执行

etcd --name infra0   --initial-advertise-peer-urls http://10.0.0.61:2380   --listen-peer-urls http://10.0.0.61:2380   --listen-client-urls http://10.0.0.61:2379,http://127.0.0.1:2379   --advertise-client-urls http://10.0.0.61:2379   --initial-cluster-token etcd-cluster-1   --initial-cluster infra0=http://10.0.0.61:2380,infra1=http://10.0.0.51:2380   --initial-cluster-state new &

3.查看

etcdctl  member list

 

docker配置

1.下载doker

yum install -y docker

2.修改docker的配置文件

calico1修改

vim /usr/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd  $INSECURE_REGISTRY --cluster-store=etcd://10.0.0.51:2379

calico2修改

vim  /usr/lib/systemd/system/docker.service

3.启动docker

systemctl  daemon-reload

systemctl  restart docker

三.calico

需要先下载calico/node    镜像

1.下载calico并授权

 wget http://www.projectcalico.org/latest/calicoctl

chmod +x calicoctl && mv calicoctl /usr/local/bin

2.执行calico命令

1.在本机执行

calicoctl node run

2.在另一台执行

 ETCD_ENDPOINTS=http://10.0.0.51:2379 calicoctl node run

 

3.查看

calicoctl  node status

4.创建网络池

 cat > calico_pool_minion5.conf <<EOF

apiVersion: v1
kind: ipPool
metadata:
  cidr: 10.1.0.0/16
spec:
  ipip:
    enabled: false
  nat-outgoing: true
  disabled: false
EOF
5.创建pod
 calicoctl create -f calico_pool_minion5.conf
6.创建网络
 docker network create -d calico --ipam-driver calico-ipam --subnet=10.1.0.0/16 net1
docker network ls

7.测试

 

posted @ 2017-11-12 19:16  巽逸  阅读(1057)  评论(0编辑  收藏  举报