diff options
author | Peter Hoeg <peter@hoeg.com> | 2017-04-13 19:32:10 +0800 |
---|---|---|
committer | Peter Hoeg <peter@hoeg.com> | 2017-04-13 19:32:10 +0800 |
commit | a3ee3b51d7236a9b039c6c7e8df9ea8a26c689ef (patch) | |
tree | 3aea839dfafd184a5e1face8db2939232c322632 /nixos | |
parent | bf4be8f1dd29612a4e706589ce2bde9be9742ce9 (diff) |
k8s: use slice and target for kubernetes
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/cluster/kubernetes.nix | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/nixos/modules/services/cluster/kubernetes.nix b/nixos/modules/services/cluster/kubernetes.nix index 25eaf70850c1..25a410d0dbec 100644 --- a/nixos/modules/services/cluster/kubernetes.nix +++ b/nixos/modules/services/cluster/kubernetes.nix @@ -597,7 +597,7 @@ in { (mkIf cfg.kubelet.enable { systemd.services.kubelet = { description = "Kubernetes Kubelet Service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "kubernetes.target" ]; after = [ "network.target" "docker.service" "kube-apiserver.service" ]; path = with pkgs; [ gitMinimal openssh docker utillinux iproute ethtool thin-provisioning-tools iptables ]; preStart = '' @@ -606,6 +606,7 @@ in { ${concatMapStringsSep "\n" (p: "ln -fs ${p.plugins}/* /opt/cni/bin") cfg.kubelet.cni.packages} ''; serviceConfig = { + Slice = "kubernetes.slice"; ExecStart = ''${cfg.package}/bin/kubelet \ --pod-manifest-path=${manifests} \ --kubeconfig=${kubeconfig} \ @@ -655,9 +656,10 @@ in { (mkIf cfg.apiserver.enable { systemd.services.kube-apiserver = { description = "Kubernetes Kubelet Service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "kubernetes.target" ]; after = [ "network.target" "docker.service" ]; serviceConfig = { + Slice = "kubernetes.slice"; ExecStart = ''${cfg.package}/bin/kube-apiserver \ --etcd-servers=${concatStringsSep "," cfg.etcd.servers} \ ${optionalString (cfg.etcd.caFile != null) @@ -713,9 +715,10 @@ in { (mkIf cfg.scheduler.enable { systemd.services.kube-scheduler = { description = "Kubernetes Scheduler Service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "kubernetes.target" ]; after = [ "kube-apiserver.service" ]; serviceConfig = { + Slice = "kubernetes.slice"; ExecStart = ''${cfg.package}/bin/kube-scheduler \ --address=${cfg.scheduler.address} \ --port=${toString cfg.scheduler.port} \ @@ -735,11 +738,12 @@ in { (mkIf cfg.controllerManager.enable { systemd.services.kube-controller-manager = { description = "Kubernetes Controller Manager Service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "kubernetes.target" ]; after = [ "kube-apiserver.service" ]; serviceConfig = { RestartSec = "30s"; Restart = "on-failure"; + Slice = "kubernetes.slice"; ExecStart = ''${cfg.package}/bin/kube-controller-manager \ --address=${cfg.controllerManager.address} \ --port=${toString cfg.controllerManager.port} \ @@ -767,10 +771,11 @@ in { (mkIf cfg.proxy.enable { systemd.services.kube-proxy = { description = "Kubernetes Proxy Service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "kubernetes.target" ]; after = [ "kube-apiserver.service" ]; path = [pkgs.iptables]; serviceConfig = { + Slice = "kubernetes.slice"; ExecStart = ''${cfg.package}/bin/kube-proxy \ --kubeconfig=${kubeconfig} \ --bind-address=${cfg.proxy.address} \ @@ -786,9 +791,10 @@ in { (mkIf cfg.dns.enable { systemd.services.kube-dns = { description = "Kubernetes Dns Service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "kubernetes.target" ]; after = [ "kube-apiserver.service" ]; serviceConfig = { + Slice = "kubernetes.slice"; ExecStart = ''${cfg.package}/bin/kube-dns \ --kubecfg-file=${kubeconfig} \ --dns-port=${toString cfg.dns.port} \ @@ -836,6 +842,11 @@ in { cfg.proxy.enable || cfg.dns.enable ) { + systemd.targets.kubernetes = { + description = "Kubernetes"; + wantedBy = [ "multi-user.target" ]; + }; + systemd.tmpfiles.rules = [ "d /opt/cni/bin 0755 root root -" "d /var/run/kubernetes 0755 kubernetes kubernetes -" |