at master 1.5 kB view raw
1{ lib, ... }: 2{ 3 name = "flannel"; 4 5 meta.maintainers = with lib.maintainers; [ offline ]; 6 7 nodes = 8 let 9 flannelConfig = { 10 services.flannel = { 11 enable = true; 12 backend = { 13 Type = "udp"; 14 Port = 8285; 15 }; 16 network = "10.1.0.0/16"; 17 iface = "eth1"; 18 etcd.endpoints = [ "http://etcd:2379" ]; 19 }; 20 21 networking.firewall.allowedUDPPorts = [ 8285 ]; 22 }; 23 in 24 { 25 etcd = { 26 services.etcd = { 27 enable = true; 28 listenClientUrls = [ "http://0.0.0.0:2379" ]; # requires ip-address for binding 29 listenPeerUrls = [ "http://0.0.0.0:2380" ]; # requires ip-address for binding 30 advertiseClientUrls = [ "http://etcd:2379" ]; 31 initialAdvertisePeerUrls = [ "http://etcd:2379" ]; 32 initialCluster = [ "etcd=http://etcd:2379" ]; 33 }; 34 35 networking.firewall.allowedTCPPorts = [ 2379 ]; 36 }; 37 38 node1 = flannelConfig; 39 node2 = flannelConfig; 40 }; 41 42 testScript = '' 43 start_all() 44 45 node1.wait_for_unit("flannel.service") 46 node2.wait_for_unit("flannel.service") 47 48 node1.wait_until_succeeds("ip l show dev flannel0") 49 ip1 = node1.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") 50 node2.wait_until_succeeds("ip l show dev flannel0") 51 ip2 = node2.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") 52 53 node1.wait_until_succeeds(f"ping -c 1 {ip2}") 54 node2.wait_until_succeeds(f"ping -c 1 {ip1}") 55 ''; 56}