calico profile 测试
使用calico的ipam dirver创建网络
如果使用docker默认的ipam创建calico网络,则不支持访问策略控制。
- 创建pool
calicoctl pool add 100.100.1.0/24 –nat-outgoing
calicoctl pool add 100.100.2.0/24 –nat-outgoing
- 创建network
docker network create --driver calico --ipam-driver calico --subnet=100.100.1.0/24 vnet1
docker network create --driver calico --ipam-driver calico --subnet=100.100.2.0/24 vnet2
- 更新profile增加2个互相访问
calicoctl profile vnet1 rule add inbound allow from tag vnet2
calicoctl profile vnet2 rule add inbound allow from tag vnet1### 创建容器测试
使用vnet1/vnet2分别创建2个容器docker run –name vnet1 -d –net vnet1 acs-reg.sqa.alipay.net/min.peng/minios /sbin/init
docker run –name vnet2 -d –net vnet2 acs-reg.sqa.alipay.net/min.peng/minios /sbin/init### 说明可以直接使用默认的docker的ipam-driver 创建网段,但是那样就没法做策略了,且nat-outgoing和ipip的选项实际是全开的。
比如
docker network create --driver calico --opt nat-outgoing=true --opt ipip=false --subnet=10.20.0.0/22 vnet1
docker network create --driver calico --opt nat-outgoing=true --opt ipip=false --subnet=10.30.0.0/22 vnet2
- 使用了ipam-driver calico的话,内部的服务没法对外暴露端口。。但是nat-outgoing和ipip的配置是生效,
- 参考文档
- http://docs.projectcalico.org/v1.5/getting-started/docker/tutorials/basic