1 { config, lib, options, pkgs, ... }:
6 top = config.services.kubernetes;
7 otop = options.services.kubernetes;
12 (mkRenamedOptionModule [ "services" "kubernetes" "proxy" "address" ] ["services" "kubernetes" "proxy" "bindAddress"])
16 options.services.kubernetes.proxy = with lib.types; {
18 bindAddress = mkOption {
19 description = lib.mdDoc "Kubernetes proxy listening address.";
24 enable = mkEnableOption (lib.mdDoc "Kubernetes proxy");
26 extraOpts = mkOption {
27 description = lib.mdDoc "Kubernetes proxy extra command line options.";
29 type = separatedString " ";
32 featureGates = mkOption {
33 description = lib.mdDoc "List set of feature gates";
34 default = top.featureGates;
35 defaultText = literalExpression "config.${otop.featureGates}";
40 description = lib.mdDoc "Kubernetes proxy hostname override.";
41 default = config.networking.hostName;
42 defaultText = literalExpression "config.networking.hostName";
46 kubeconfig = top.lib.mkKubeConfigOptions "Kubernetes proxy";
48 verbosity = mkOption {
49 description = lib.mdDoc ''
50 Optional glog verbosity level for logging statements. See
51 <https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md>
60 config = mkIf cfg.enable {
61 systemd.services.kube-proxy = {
62 description = "Kubernetes Proxy Service";
63 wantedBy = [ "kubernetes.target" ];
64 after = [ "kube-apiserver.service" ];
65 path = with pkgs; [ iptables conntrack-tools ];
67 Slice = "kubernetes.slice";
68 ExecStart = ''${top.package}/bin/kube-proxy \
69 --bind-address=${cfg.bindAddress} \
70 ${optionalString (top.clusterCidr!=null)
71 "--cluster-cidr=${top.clusterCidr}"} \
72 ${optionalString (cfg.featureGates != [])
73 "--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.featureGates}"} \
74 --hostname-override=${cfg.hostname} \
75 --kubeconfig=${top.lib.mkKubeConfig "kube-proxy" cfg.kubeconfig} \
76 ${optionalString (cfg.verbosity != null) "--v=${toString cfg.verbosity}"} \
79 WorkingDirectory = top.dataDir;
80 Restart = "on-failure";
84 StartLimitIntervalSec = 0;
88 services.kubernetes.proxy.hostname = with config.networking; mkDefault hostName;
90 services.kubernetes.pki.certs = {
91 kubeProxyClient = top.lib.mkCert {
92 name = "kube-proxy-client";
93 CN = "system:kube-proxy";
94 action = "systemctl restart kube-proxy.service";
98 services.kubernetes.proxy.kubeconfig.server = mkDefault top.apiserverAddress;
101 meta.buildDocsInSandbox = false;