From 345ebf60061ae625d528b52ae9ceb682731fcd35 Mon Sep 17 00:00:00 2001 From: Johan Thomsen Date: Thu, 15 Feb 2018 10:48:38 +0100 Subject: [PATCH] Make kuberouter module always override its CNI-config at startup, and delete it after stopping, to housekeep the system - ref #14 --- nixos/modules/dbc/services/networking/kube-router.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/dbc/services/networking/kube-router.nix b/nixos/modules/dbc/services/networking/kube-router.nix index a5fc002dc8ddb..53896c5abbe86 100644 --- a/nixos/modules/dbc/services/networking/kube-router.nix +++ b/nixos/modules/dbc/services/networking/kube-router.nix @@ -11,10 +11,8 @@ let preStart = mkIf (cfg.cniConfig != null) '' - if [[ ! -f ${cfg.mutableCniPath}/${cniConfigFileName} ]]; then mkdir -p ${cfg.mutableCniPath} cp ${cniFile} ${cfg.mutableCniPath}/${cniConfigFileName} - fi ''; start = '' @@ -33,6 +31,9 @@ let --peer-router-ips=${concatMapStringsSep "," (router: router.ip) cfg.peerRouters} \ --peer-router-passwords=${concatMapStringsSep "," (router: router.password) cfg.peerRouters} \ ''; + + postStop = "rm -fr ${cfg.mutableCniPath}"; + in { options = { @@ -173,6 +174,7 @@ in after = ["kubernetes.target"]; requires = ["kubernetes.target"]; inherit preStart; + inherit postStop; script = start; serviceConfig = { Type = "simple";