1 { config, lib, options, pkgs, ... }:
6 top = config.services.kubernetes;
7 otop = options.services.kubernetes;
12 options.services.kubernetes.scheduler = with lib.types; {
15 description = lib.mdDoc "Kubernetes scheduler listening address.";
16 default = "127.0.0.1";
20 enable = mkEnableOption (lib.mdDoc "Kubernetes scheduler");
22 extraOpts = mkOption {
23 description = lib.mdDoc "Kubernetes scheduler extra command line options.";
25 type = separatedString " ";
28 featureGates = mkOption {
29 description = lib.mdDoc "List set of feature gates";
30 default = top.featureGates;
31 defaultText = literalExpression "config.${otop.featureGates}";
35 kubeconfig = top.lib.mkKubeConfigOptions "Kubernetes scheduler";
37 leaderElect = mkOption {
38 description = lib.mdDoc "Whether to start leader election before executing main loop.";
44 description = lib.mdDoc "Kubernetes scheduler listening port.";
49 verbosity = mkOption {
50 description = lib.mdDoc ''
51 Optional glog verbosity level for logging statements. See
52 <https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md>
61 config = mkIf cfg.enable {
62 systemd.services.kube-scheduler = {
63 description = "Kubernetes Scheduler Service";
64 wantedBy = [ "kubernetes.target" ];
65 after = [ "kube-apiserver.service" ];
67 Slice = "kubernetes.slice";
68 ExecStart = ''${top.package}/bin/kube-scheduler \
69 --bind-address=${cfg.address} \
70 ${optionalString (cfg.featureGates != [])
71 "--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.featureGates}"} \
72 --kubeconfig=${top.lib.mkKubeConfig "kube-scheduler" cfg.kubeconfig} \
73 --leader-elect=${boolToString cfg.leaderElect} \
74 --secure-port=${toString cfg.port} \
75 ${optionalString (cfg.verbosity != null) "--v=${toString cfg.verbosity}"} \
78 WorkingDirectory = top.dataDir;
81 Restart = "on-failure";
85 StartLimitIntervalSec = 0;
89 services.kubernetes.pki.certs = {
90 schedulerClient = top.lib.mkCert {
91 name = "kube-scheduler-client";
92 CN = "system:kube-scheduler";
93 action = "systemctl restart kube-scheduler.service";
97 services.kubernetes.scheduler.kubeconfig.server = mkDefault top.apiserverAddress;
100 meta.buildDocsInSandbox = false;