nixos/kubernetes: improvements

- Added option 'cni.configDir' to allow for having CNI config outside of nix-store
  Existing behavior (writing verbatim CNI conf-files to nix-store) is still available.

- Removed unused option 'apiserver.publicAddress' and changed 'apiserver.address' to 'bindAddress'
  This conforms better to k8s docs and removes existing --bind-address hardcoding to 0.0.0.0

- Fixed c/p mistake in apiserver systemd unit description

- Updated 18.09 release notes to reflect changes to existing options
  And fixed some typos from previous PR

- Make docker images for Kubernetes Dashboard and kube-dns configurable
This commit is contained in:
Johan Thomsen
2018-06-12 22:47:32 +02:00
parent da8920622a
commit 8d7ea96a13
5 changed files with 105 additions and 63 deletions
@@ -73,7 +73,9 @@ let
mkKubeConfigOptions = prefix: {
server = mkOption {
description = "${prefix} kube-apiserver server address.";
default = "http://${cfg.apiserver.address}:${toString cfg.apiserver.port}";
default = "http://${if cfg.apiserver.advertiseAddress != null
then cfg.apiserver.advertiseAddress
else "127.0.0.1"}:${toString cfg.apiserver.port}";
type = types.str;
};
@@ -103,12 +105,18 @@ let
keyFile = mkDefault cfg.kubeconfig.keyFile;
};
cniConfig = pkgs.buildEnv {
name = "kubernetes-cni-config";
paths = imap (i: entry:
pkgs.writeTextDir "${toString (10+i)}-${entry.type}.conf" (builtins.toJSON entry)
) cfg.kubelet.cni.config;
};
cniConfig =
if cfg.kubelet.cni.config != [] && !(isNull cfg.kubelet.cni.configDir) then
throw "Verbatim CNI-config and CNI configDir cannot both be set."
else if !(isNull cfg.kubelet.cni.configDir) then
cfg.kubelet.cni.configDir
else
(pkgs.buildEnv {
name = "kubernetes-cni-config";
paths = imap (i: entry:
pkgs.writeTextDir "${toString (10+i)}-${entry.type}.conf" (builtins.toJSON entry)
) cfg.kubelet.cni.config;
});
manifests = pkgs.buildEnv {
name = "kubernetes-manifests";
@@ -244,18 +252,13 @@ in {
type = types.listOf types.str;
};
address = mkOption {
description = "Kubernetes apiserver listening address.";
default = "127.0.0.1";
type = types.str;
};
publicAddress = mkOption {
bindAddress = mkOption {
description = ''
Kubernetes apiserver public listening address used for read only and
secure port.
The IP address on which to listen for the --secure-port port.
The associated interface(s) must be reachable by the rest
of the cluster, and by CLI/web clients.
'';
default = cfg.apiserver.address;
default = "0.0.0.0";
type = types.str;
};
@@ -670,6 +673,12 @@ in {
}]
'';
};
configDir = mkOption {
description = "Path to Kubernetes CNI configuration directory.";
type = types.nullOr types.path;
default = null;
};
};
manifests = mkOption {
@@ -892,7 +901,7 @@ in {
(mkIf cfg.apiserver.enable {
systemd.services.kube-apiserver = {
description = "Kubernetes Kubelet Service";
description = "Kubernetes APIServer Service";
wantedBy = [ "kubernetes.target" ];
after = [ "network.target" "docker.service" ];
serviceConfig = {
@@ -906,7 +915,7 @@ in {
${optionalString (cfg.etcd.keyFile != null)
"--etcd-keyfile=${cfg.etcd.keyFile}"} \
--insecure-port=${toString cfg.apiserver.port} \
--bind-address=${toString cfg.apiserver.address} \
--bind-address=${cfg.apiserver.bindAddress} \
${optionalString (cfg.apiserver.advertiseAddress != null)
"--advertise-address=${cfg.apiserver.advertiseAddress}"} \
--allow-privileged=${boolToString cfg.apiserver.allowPrivileged}\