9 top = config.services.kubernetes;
10 otop = options.services.kubernetes;
15 options.services.kubernetes.scheduler = with lib.types; {
17 address = lib.mkOption {
18 description = "Kubernetes scheduler listening address.";
19 default = "127.0.0.1";
23 enable = lib.mkEnableOption "Kubernetes scheduler";
25 extraOpts = lib.mkOption {
26 description = "Kubernetes scheduler extra command line options.";
28 type = separatedString " ";
31 featureGates = lib.mkOption {
32 description = "Attribute set of feature gates.";
33 default = top.featureGates;
34 defaultText = lib.literalExpression "config.${otop.featureGates}";
38 kubeconfig = top.lib.mkKubeConfigOptions "Kubernetes scheduler";
40 leaderElect = lib.mkOption {
41 description = "Whether to start leader election before executing main loop.";
47 description = "Kubernetes scheduler listening port.";
52 verbosity = lib.mkOption {
54 Optional glog verbosity level for logging statements. See
55 <https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md>
64 config = lib.mkIf cfg.enable {
65 systemd.services.kube-scheduler = {
66 description = "Kubernetes Scheduler Service";
67 wantedBy = [ "kubernetes.target" ];
68 after = [ "kube-apiserver.service" ];
70 Slice = "kubernetes.slice";
72 ${top.package}/bin/kube-scheduler \
73 --bind-address=${cfg.address} \
75 lib.optionalString (cfg.featureGates != { })
77 lib.concatStringsSep "," (
78 builtins.attrValues (lib.mapAttrs (n: v: "${n}=${lib.trivial.boolToString v}") cfg.featureGates)
82 --kubeconfig=${top.lib.mkKubeConfig "kube-scheduler" cfg.kubeconfig} \
83 --leader-elect=${lib.boolToString cfg.leaderElect} \
84 --secure-port=${toString cfg.port} \
85 ${lib.optionalString (cfg.verbosity != null) "--v=${toString cfg.verbosity}"} \
88 WorkingDirectory = top.dataDir;
91 Restart = "on-failure";
95 StartLimitIntervalSec = 0;
99 services.kubernetes.pki.certs = {
100 schedulerClient = top.lib.mkCert {
101 name = "kube-scheduler-client";
102 CN = "system:kube-scheduler";
103 action = "systemctl restart kube-scheduler.service";
107 services.kubernetes.scheduler.kubeconfig.server = lib.mkDefault top.apiserverAddress;
110 meta.buildDocsInSandbox = false;