@@ -5,6 +5,37 @@ with lib;
55let
66 cfg = config.services.kubernetes;
77
8+ # YAML config; see:
9+ # https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/
10+ # https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/apis/kubeletconfig/v1beta1/types.go
11+ #
12+ # TODO: migrate the following flags to this config file
13+ #
14+ # --pod-manifest-path
15+ # --address
16+ # --port
17+ # --tls-cert-file
18+ # --tls-private-key-file
19+ # --client-ca-file
20+ # --authentication-token-webhook
21+ # --authentication-token-webhook-cache-ttl
22+ # --authorization-mode
23+ # --healthz-bind-address
24+ # --healthz-port
25+ # --allow-privileged
26+ # --cluster-dns
27+ # --cluster-domain
28+ # --hairpin-mode
29+ # --feature-gates
30+ kubeletConfig = pkgs.runCommand "kubelet-config.yaml" { } ''
31+ echo > $out ${pkgs.lib.escapeShellArg (builtins.toJSON {
32+ kind = "KubeletConfiguration";
33+ apiVersion = "kubelet.config.k8s.io/v1beta1";
34+ ${if cfg.kubelet.applyManifests then "staticPodPath" else null} =
35+ manifests;
36+ })}
37+ '';
38+
839 skipAttrs = attrs: map (filterAttrs (k: v: k != "enable"))
940 (filter (v: !(hasAttr "enable" v) || v.enable) attrs);
1041
@@ -339,9 +370,9 @@ in {
339370 type = types.str;
340371 };
341372
342− admissionControl = mkOption {
373+ enableAdmissionPlugins = mkOption {
343374 description = ''
344− Kubernetes admission control plugins to use. See
375+ Kubernetes admission control plugins to enable. See
345376 <link xlink:href="https://kubernetes.io/docs/admin/admission-controllers/"/>
346377 '';
347378 default = ["NamespaceLifecycle" "LimitRanger" "ServiceAccount" "ResourceQuota" "DefaultStorageClass" "DefaultTolerationSeconds" "NodeRestriction"];
@@ -353,6 +384,15 @@ in {
353384 type = types.listOf types.str;
354385 };
355386
387+ disableAdmissionPlugins = mkOption {
388+ description = ''
389+ Kubernetes admission control plugins to disable. See
390+ <link xlink:href="https://kubernetes.io/docs/admin/admission-controllers/"/>
391+ '';
392+ default = [];
393+ type = types.listOf types.str;
394+ };
395+
356396 serviceAccountKeyFile = mkOption {
357397 description = ''
358398 Kubernetes apiserver PEM-encoded x509 RSA private or public key file,
@@ -573,6 +613,7 @@ in {
573613 type = types.bool;
574614 };
575615
616+ # TODO: remove this deprecated flag
576617 cadvisorPort = mkOption {
577618 description = "Kubernetes kubelet local cadvisor port.";
578619 default = 4194;
@@ -783,12 +824,10 @@ in {
783824 serviceConfig = {
784825 Slice = "kubernetes.slice";
785826 ExecStart = ''${cfg.package}/bin/kubelet \
786− ${optionalString cfg.kubelet.applyManifests
787− "--pod-manifest-path=${manifests}"} \
788827 ${optionalString (taints != "")
789828 "--register-with-taints=${taints}"} \
790829 --kubeconfig=${mkKubeConfig "kubelet" cfg.kubelet.kubeconfig} \
791− --require-kubeconfig \
830+ --config=${kubeletConfig} \
792831 --address=${cfg.kubelet.address} \
793832 --port=${toString cfg.kubelet.port} \
794833 --register-node=${boolToString cfg.kubelet.registerNode} \
@@ -899,7 +938,8 @@ in {
899938 --service-cluster-ip-range=${cfg.apiserver.serviceClusterIpRange} \
900939 ${optionalString (cfg.apiserver.runtimeConfig != "")
901940 "--runtime-config=${cfg.apiserver.runtimeConfig}"} \
902− --admission_control=${concatStringsSep "," cfg.apiserver.admissionControl} \
941+ --enable-admission-plugins=${concatStringsSep "," cfg.apiserver.enableAdmissionPlugins} \
942+ --disable-admission-plugins=${concatStringsSep "," cfg.apiserver.disableAdmissionPlugins} \
903943 ${optionalString (cfg.apiserver.serviceAccountKeyFile!=null)
904944 "--service-account-key-file=${cfg.apiserver.serviceAccountKeyFile}"} \
905945 ${optionalString cfg.verbose "--v=6"} \