Git Product home page Git Product logo

networkd's Introduction

Networkd

codecov

layer 0 network daemon.

Dependency

  • ip (iproute-3.10.0-13.el7.x86_64)
  • arping (iputils-20121221-6.el7.x86_64)
  • iptables (iptables-1.4.21-13.el7.x86_64)
  • docker
  • etcd
  • lainlet

Float IP

  1. watch etcd/lainlet key: /lain/config/vips/*
  2. watch procs in /lain/config/vips/*
  3. config node vip

virtual ip config protocol

  • key: /lain/config/vips/{IP}

  • value:

    {
        "app": "APP1", # lain app name, required
        "proc": "PROC1", # lain app proc name, required
        "ports": [
            {
                "src": "PORT1", # source port (virtual ip/host port), required
                "proto": "tcp", # port protocol, optional, default: `tcp`, options: `tcp`, `udp`
                "dest": "APPPORT1" # destination port (lain app port), optional, default: `PORT1(current virtual ip port)`
            },
            {
                ...
            }
        ], # lain app ports, required
        "excluded_nodes": ["NODE1", "NODE2"] # optional, default: `[]`
    }

interface

TBD

PS: only support default interface now

example

vip: 192.168.10.254

  1. lock key
    • key: /lain/networkd/vips/192.168.10.254.lock
    • value:node1 # node hostname
  2. config key
    • key: /lain/config/vips/192.168.10.254

    • value: json # ip config

      {
          "app": "resource.elb.webrouter",
          "proc": "haproxy",
          "ports": [
              {
                  "src": "80",
                  "proto": "tcp"
              },
              {
                  "src": "443",
                  "proto": "tcp"
              },
              {
                  "src": "5555",
                  "proto": "udp",
                  "dest": "53"
              },
          ]
      }

Dns

Networkd contains a embedded dns server similar to dnsmasq. All resolvable domains from etcd are configured in /lain/config/domains.

  1. key
    • exact domain, e.g., /lain/config/domains/etcd.lain, /lain/config/domains/docker.lain.
    • wildcard domain begins with *., e.g., /lain/config/domains/*.lain, /lain/config/domains/*.lain.local.
  2. value
    • type `` to resolve to the specified IPs, e.g., {"ips":["10.131.0.72"],"type":""}.
    • type node to resolve to node IP, e.g., {"ips":[],"type":"node"}.
    • type webrouter to resolve to webrouter IPs, e.g., {"ips":[],"type":"webrouter"}.
  3. dump dns config
    • curl http://127.0.0.1:3000/v1/dns/config

Tinydns

dynamic dns server conf of tinydns app

Swarm

  1. dynamic dns host conf of swarm manager
    1. swarm.lain
  2. /lain/swarm/docker/swarm/leader

Deployd

  1. dynamic dns host conf of deployd
    1. deployd.lain
  2. /lain/deployd/leader

Webrouter

  1. dynamic webrouter.lain when no vip for webrouter

Resolv.conf

  1. Watch /etc/resolv.conf
  2. Ensure nameserver 127.0.0.1 in the first line.
  3. synchronize name servers from /etc/resolv.conf
  4. Remove rotate options

TODO

  1. Split lock & health goroutine
  2. Print iptables acl rules

License

Networkd is released under the MIT license.

networkd's People

Contributors

bibaijin avatar fossilet avatar liuxu623 avatar panli889 avatar silverglass avatar supermeng avatar xtao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

networkd's Issues

Why not fill all webrouter ips into tinydns

In our scene, we always use internal http service with lain.local domain, but networkd support one ip only. In fact webrouter is not stateful. We just fill all ips into tinydns is fine i think.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.