threefoldtecharchive / 0-templates

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

Implement web_gateway template #172

Closed serboctor closed 5 years ago

serboctor commented 5 years ago

We need a higher-level template to manage etcd_cluster, traefik and coredns. It will be responsible for creating all three services, feeding traefik and coredns info about the etcd connections info since they won't have access to the etcd_cluster services. Coredns and traefik templates will need to be modified to save etcd password and endpoints in their schema instead of etcd service name.

web_gatewat Schema:

@0x8f4e6505afa01c30;

struct Schema {
    nics @0 :List(Nic); # Configuration of the attached nics to the traefik, coredns and etcd containers
    nrEtcds @1 :Int32; # number of etcd instance in the cluster
    etcdPassword @2 :Text; # etcd root user password
    clusterToken @3 :Text; # cluster token
    farmerIyoOrg @4 :Text; # farmer for nodes to create etcd instances on
    traefikNode @5 :Node; # node to deploy traefik on
    corednsNode @6 :Node; # node to deploy coredns on

    struct Node {
        id @1 :Text; # node id
        url @2 :Text; # node zrobot url
    }

    struct Nic {
        type @0 :NicType;
        id @1 :Text;
        config @2 :NicConfig;
        name @3 :Text;
        ztClient @4 :Text;
        hwaddr @5 :Text;
    }

    struct NicConfig {
        dhcp @0 :Bool;
        cidr @1 :Text;
        gateway @2 :Text;
        dns @3 :List(Text);
    }

    enum NicType {
        default @0;
        zerotier @1;
        vlan @2;
        vxlan @3;
        bridge @4;
    }
}

Actions:

zaibon commented 5 years ago

clusterToken @3 :Text; # cluster token I think this field can be generated and know only by the service itself. no need to expose it

siddiquagig commented 5 years ago

Verified

In [1]: from jumpscale import j

In [2]: robot = j.clients.zrobot.robots['webgt']

In [5]: args = {
    ...:     'nics': [{'name': 'ten', 'type': 'zerotier', 'ztClient':'zt', 'id': 'abfd31bd476c3c18'}],
    ...:     'farmerIyoOrg': 'kristof-farm',
    ...:     'nrEtcds': 2,
    ...:     'traefikNode': 'ac1f6b27224c',
    ...:     'corednsNode': 'ac1f6b457488'
    ...:     }
    ...:
    ...:

In [6]: wg = robot.services.create('github.com/threefoldtech/0-templates/web_gateway/0.0.1', 'wg', data=args)
    ...:

In [8]: wg.schedule_action('install').wait(die=True)
Out[8]: install

In [11]: wg.schedule_action('start')
Out[11]: start

In [12]: wg.schedule_action('stop')
Out[12]: stop

In [13]: wg.schedule_action('uninstall')
Out[13]: uninstall
0-templates:
commit 3754868bed74b768d1e559a2e3e1cd052fd3b717
Merge: b881f6f cb5acab
Author: Christophe de Carvalho Pereira Martins <christophe.dcpm@gmail.com>
Date:   Mon Aug 6 12:57:37 2018 +0200

    Merge branch 'development'