modulepackage
2.4.0+incompatible
Repository: https://github.com/laincloud/networkd.git
Documentation: pkg.go.dev
# README
Networkd
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
- watch etcd/lainlet key:
/lain/config/vips/*
- watch procs in
/lain/config/vips/*
- 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
- lock key
- key:
/lain/networkd/vips/192.168.10.254.lock
- value:
node1
# node hostname
- key:
- 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.
- 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
.
- exact domain, e.g.,
- 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"}
.
- type `` to resolve to the specified IPs, e.g.,
- dump dns config
curl http://127.0.0.1:3000/v1/dns/config
Tinydns
dynamic dns server conf of tinydns app
Swarm
- dynamic dns host conf of swarm manager
swarm.lain
/lain/swarm/docker/swarm/leader
Deployd
- dynamic dns host conf of deployd
deployd.lain
/lain/deployd/leader
Webrouter
- dynamic
webrouter.lain
when no vip for webrouter
Resolv.conf
- Watch /etc/resolv.conf
- Ensure
nameserver 127.0.0.1
in the first line. - synchronize name servers from /etc/resolv.conf
- Remove
rotate
options
TODO
- Split lock & health goroutine
- Print iptables acl rules
License
Networkd is released under the MIT license.
# Functions
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
eg: /lain/networkd/containers/webrouter/worker/1 has the vip list for webrouter instance 1.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
create locker.
delete locker.
No description provided by the author
locked && lock by me.
no lock.
locked && not lock by me.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TODO(xutao) support more interfaces.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author