threefoldtecharchive / 0-templates

0-robot templates
Apache License 2.0
1 stars 1 forks source link

Unable to create containers with static ZeroTier IPs #309

Open abdulgig opened 5 years ago

abdulgig commented 5 years ago

In an event of a restart, the container seems to lose its ZeroTier IP, it always gets a fresh lease from the ZT network. We came across this issue when deploying web gateway.

https://docs.grid.tf/threefold/itenv_threefold_main/issues/17

The robot serviceID remains the same though.

Steps to reproduce,

    ...:                             'flist': FLIST,
    ...:                             'nics': [{'type': 'default'},{'type': 'zerotier','id': '93afae59631c10d0'},{'type': 'zerotier','id': 'c7c8172af1f387a6'}],
    ...:                             'mounts': [{'source': '/mnt/storagepools/35a2a34e-56c8-4d46-b6c5-341432e056d2/filesystems/cultest','target': '/opt'}],
    ...:                             'ports': ['7211:22' , '7221:2015'],
    ...:                             'env' : [{'name': 'REPO_URL', 'value': 'https://github.com/cultivo/www_cultivo_earth.git'},{'name': 'REPO_BRANCH', 'value': 'master'}]
    ...:                    }

cul_tst = robot.services.create('github.com/threefoldtech/0-templates/container/0.0.1', 'cultest', data=container_data)

robot.services.names
Out[62]:
{'_node_capacity': robot://kdsfarmnodehst/github.com/threefoldtech/0-templates/node_capacity/0.0.1?guid=864ee8e9-4011-4309-909b-ed327505eee3&name=_node_capacity,
 'cultest': robot://kdsfarmnodehst/github.com/threefoldtech/0-templates/container/0.0.1?guid=5fc1025e-d76a-469c-8c3c-24f03b6ab6da&name=cultest,
 'cultest2': robot://kdsfarmnodehst/github.com/threefoldtech/0-templates/container/0.0.1?guid=e4752dd5-2e3b-408f-bc28-e7f066fa79a5&name=cultest2}

IP on ZeroTier = 192.168.193.31

- Delete the container now so that the robot will recreate it,

ncl.client.container.terminate(23)

- The robot will create the container under the same service ID,

In [68]: robot.services.names
Out[68]:
{'_node_capacity': robot://kdsfarmnodehst/github.com/threefoldtech/0-templates/node_capacity/0.0.1?guid=864ee8e9-4011-4309-909b-ed327505eee3&name=_node_capacity,
 'cultest': robot://kdsfarmnodehst/github.com/threefoldtech/0-templates/container/0.0.1?guid=5fc1025e-d76a-469c-8c3c-24f03b6ab6da&name=cultest,
 'cultest2': robot://kdsfarmnodehst/github.com/threefoldtech/0-templates/container/0.0.1?guid=e4752dd5-2e3b-408f-bc28-e7f066fa79a5&name=cultest2}

IP on ZeroTier = 192.168.193.187