about summary refs log tree commit diff
path: root/nixos/modules/services/networking/flannel.nix
diff options
context:
space:
mode:
authorJohan Thomsen <jth@dbc.dk>2019-02-14 10:28:51 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2019-02-20 21:08:56 +0100
commit7028fac35baf085ba973754c3dfe573b0bc2823a (patch)
tree9e75397b6560f0d98f6220de54a9eaf30ead235c /nixos/modules/services/networking/flannel.nix
parent466beb02143f99815eef90ef8a69c91cd898a998 (diff)
nixos/kubernetes: use system.path to handle dependency on flannel subnet.env
The current postStart step on flannel causes flannel.service to
sometimes hang, even when it's commanded to stop.
Diffstat (limited to 'nixos/modules/services/networking/flannel.nix')
-rw-r--r--nixos/modules/services/networking/flannel.nix17
1 files changed, 9 insertions, 8 deletions
diff --git a/nixos/modules/services/networking/flannel.nix b/nixos/modules/services/networking/flannel.nix
index 6c43573851b25..ec702cdc6ff40 100644
--- a/nixos/modules/services/networking/flannel.nix
+++ b/nixos/modules/services/networking/flannel.nix
@@ -161,7 +161,10 @@ in {
         FLANNELD_KUBECONFIG_FILE = cfg.kubeconfig;
         NODE_NAME = cfg.nodeName;
       };
-      preStart = mkIf (cfg.storageBackend == "etcd") ''
+      preStart = ''
+        mkdir -p /run/flannel
+        touch /run/flannel/docker
+      '' + optionalString (cfg.storageBackend == "etcd") ''
         echo "setting network configuration"
         until ${pkgs.etcdctl.bin}/bin/etcdctl set /coreos.com/network/config '${builtins.toJSON networkConfig}'
         do
@@ -169,13 +172,11 @@ in {
           sleep 1
         done
       '';
-      postStart = ''
-        while [ ! -f /run/flannel/subnet.env ]
-        do
-          sleep 1
-        done
-      '';
-      serviceConfig.ExecStart = "${cfg.package}/bin/flannel";
+      serviceConfig = {
+        ExecStart = "${cfg.package}/bin/flannel";
+        Restart = "always";
+        RestartSec = "10s";
+      };
     };
 
     services.etcd.enable = mkDefault (cfg.storageBackend == "etcd" && cfg.etcd.endpoints == ["http://127.0.0.1:2379"]);