2014-11-23 00:27:04 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2014-12-11 22:32:37 +00:00
|
|
|
cfg = config.services.kubernetes;
|
2014-11-23 00:27:04 +00:00
|
|
|
|
2018-03-31 00:16:32 +01:00
|
|
|
# YAML config; see:
|
|
|
|
# https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/
|
|
|
|
# https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/apis/kubeletconfig/v1beta1/types.go
|
|
|
|
#
|
|
|
|
# TODO: migrate the following flags to this config file
|
|
|
|
#
|
|
|
|
# --pod-manifest-path
|
|
|
|
# --address
|
|
|
|
# --port
|
|
|
|
# --tls-cert-file
|
|
|
|
# --tls-private-key-file
|
|
|
|
# --client-ca-file
|
|
|
|
# --authentication-token-webhook
|
|
|
|
# --authentication-token-webhook-cache-ttl
|
|
|
|
# --authorization-mode
|
|
|
|
# --healthz-bind-address
|
|
|
|
# --healthz-port
|
|
|
|
# --allow-privileged
|
|
|
|
# --cluster-dns
|
|
|
|
# --cluster-domain
|
|
|
|
# --hairpin-mode
|
|
|
|
# --feature-gates
|
|
|
|
kubeletConfig = pkgs.runCommand "kubelet-config.yaml" { } ''
|
|
|
|
echo > $out ${pkgs.lib.escapeShellArg (builtins.toJSON {
|
|
|
|
kind = "KubeletConfiguration";
|
|
|
|
apiVersion = "kubelet.config.k8s.io/v1beta1";
|
|
|
|
${if cfg.kubelet.applyManifests then "staticPodPath" else null} =
|
|
|
|
manifests;
|
|
|
|
})}
|
|
|
|
'';
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
skipAttrs = attrs: map (filterAttrs (k: v: k != "enable"))
|
|
|
|
(filter (v: !(hasAttr "enable" v) || v.enable) attrs);
|
|
|
|
|
|
|
|
infraContainer = pkgs.dockerTools.buildImage {
|
|
|
|
name = "pause";
|
|
|
|
tag = "latest";
|
|
|
|
contents = cfg.package.pause;
|
|
|
|
config.Cmd = "/bin/pause";
|
|
|
|
};
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
mkKubeConfig = name: cfg: pkgs.writeText "${name}-kubeconfig" (builtins.toJSON {
|
2016-11-16 15:29:35 +00:00
|
|
|
apiVersion = "v1";
|
|
|
|
kind = "Config";
|
|
|
|
clusters = [{
|
|
|
|
name = "local";
|
2017-05-30 10:26:32 +01:00
|
|
|
cluster.certificate-authority = cfg.caFile;
|
|
|
|
cluster.server = cfg.server;
|
2016-11-16 15:29:35 +00:00
|
|
|
}];
|
|
|
|
users = [{
|
|
|
|
name = "kubelet";
|
|
|
|
user = {
|
2017-05-30 10:26:32 +01:00
|
|
|
client-certificate = cfg.certFile;
|
|
|
|
client-key = cfg.keyFile;
|
2016-11-16 15:29:35 +00:00
|
|
|
};
|
|
|
|
}];
|
|
|
|
contexts = [{
|
|
|
|
context = {
|
|
|
|
cluster = "local";
|
|
|
|
user = "kubelet";
|
|
|
|
};
|
|
|
|
current-context = "kubelet-context";
|
|
|
|
}];
|
|
|
|
});
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
mkKubeConfigOptions = prefix: {
|
|
|
|
server = mkOption {
|
|
|
|
description = "${prefix} kube-apiserver server address.";
|
|
|
|
default = "http://${cfg.apiserver.address}:${toString cfg.apiserver.port}";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
caFile = mkOption {
|
|
|
|
description = "${prefix} certificate authrority file used to connect to kube-apiserver.";
|
|
|
|
type = types.nullOr types.path;
|
2017-05-30 10:57:52 +01:00
|
|
|
default = cfg.caFile;
|
2017-05-30 10:26:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
certFile = mkOption {
|
|
|
|
description = "${prefix} client certificate file used to connect to kube-apiserver.";
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
keyFile = mkOption {
|
|
|
|
description = "${prefix} client key file used to connect to kube-apiserver.";
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
kubeConfigDefaults = {
|
|
|
|
server = mkDefault cfg.kubeconfig.server;
|
|
|
|
caFile = mkDefault cfg.kubeconfig.caFile;
|
|
|
|
certFile = mkDefault cfg.kubeconfig.certFile;
|
|
|
|
keyFile = mkDefault cfg.kubeconfig.keyFile;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
cniConfig = pkgs.buildEnv {
|
|
|
|
name = "kubernetes-cni-config";
|
2016-12-12 00:27:14 +00:00
|
|
|
paths = imap (i: entry:
|
2017-04-13 12:31:43 +01:00
|
|
|
pkgs.writeTextDir "${toString (10+i)}-${entry.type}.conf" (builtins.toJSON entry)
|
2016-11-16 15:29:35 +00:00
|
|
|
) cfg.kubelet.cni.config;
|
|
|
|
};
|
|
|
|
|
|
|
|
manifests = pkgs.buildEnv {
|
|
|
|
name = "kubernetes-manifests";
|
|
|
|
paths = mapAttrsToList (name: manifest:
|
|
|
|
pkgs.writeTextDir "${name}.json" (builtins.toJSON manifest)
|
|
|
|
) cfg.kubelet.manifests;
|
|
|
|
};
|
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
addons = pkgs.runCommand "kubernetes-addons" { } ''
|
|
|
|
mkdir -p $out
|
|
|
|
# since we are mounting the addons to the addon manager, they need to be copied
|
|
|
|
${concatMapStringsSep ";" (a: "cp -v ${a}/* $out/") (mapAttrsToList (name: addon:
|
|
|
|
pkgs.writeTextDir "${name}.json" (builtins.toJSON addon)
|
|
|
|
) (cfg.addonManager.addons))}
|
|
|
|
'';
|
|
|
|
|
|
|
|
taintOptions = { name, ... }: {
|
|
|
|
options = {
|
|
|
|
key = mkOption {
|
|
|
|
description = "Key of taint.";
|
|
|
|
default = name;
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
value = mkOption {
|
|
|
|
description = "Value of taint.";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
effect = mkOption {
|
|
|
|
description = "Effect of taint.";
|
|
|
|
example = "NoSchedule";
|
2017-05-24 18:05:54 +01:00
|
|
|
type = types.enum ["NoSchedule" "PreferNoSchedule" "NoExecute"];
|
2017-04-26 21:44:38 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
taints = concatMapStringsSep "," (v: "${v.key}=${v.value}:${v.effect}") (mapAttrsToList (n: v: v) cfg.kubelet.taints);
|
|
|
|
|
2017-05-26 22:21:17 +01:00
|
|
|
# needed for flannel to pass options to docker
|
|
|
|
mkDockerOpts = pkgs.runCommand "mk-docker-opts" {
|
|
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
|
|
} ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp ${pkgs.kubernetes.src}/cluster/centos/node/bin/mk-docker-opts.sh $out/mk-docker-opts.sh
|
|
|
|
|
|
|
|
# bashInteractive needed for `compgen`
|
|
|
|
makeWrapper ${pkgs.bashInteractive}/bin/bash $out/mk-docker-opts --add-flags "$out/mk-docker-opts.sh"
|
|
|
|
'';
|
2014-11-23 00:27:04 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2014-12-11 22:32:37 +00:00
|
|
|
options.services.kubernetes = {
|
2016-11-16 15:29:35 +00:00
|
|
|
roles = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes role that this machine should take.
|
|
|
|
|
|
|
|
Master role will enable etcd, apiserver, scheduler and controller manager
|
|
|
|
services. Node role will enable etcd, docker, kubelet and proxy services.
|
|
|
|
'';
|
|
|
|
default = [];
|
|
|
|
type = types.listOf (types.enum ["master" "node"]);
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
package = mkOption {
|
|
|
|
description = "Kubernetes package to use.";
|
|
|
|
type = types.package;
|
2016-11-16 15:29:35 +00:00
|
|
|
default = pkgs.kubernetes;
|
2017-03-07 13:01:50 +00:00
|
|
|
defaultText = "pkgs.kubernetes";
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
verbose = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Kubernetes enable verbose mode for debugging.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
etcd = {
|
|
|
|
servers = mkOption {
|
|
|
|
description = "List of etcd servers. By default etcd is started, except if this option is changed.";
|
|
|
|
default = ["http://127.0.0.1:2379"];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
keyFile = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Etcd key file.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
certFile = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Etcd cert file.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
caFile = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Etcd ca file.";
|
2017-05-30 10:57:52 +01:00
|
|
|
default = cfg.caFile;
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
kubeconfig = mkKubeConfigOptions "Default kubeconfig";
|
2014-11-23 00:27:04 +00:00
|
|
|
|
2017-05-30 10:57:52 +01:00
|
|
|
caFile = mkOption {
|
|
|
|
description = "Default kubernetes certificate authority";
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
dataDir = mkOption {
|
|
|
|
description = "Kubernetes root directory for managing kubelet files.";
|
|
|
|
default = "/var/lib/kubernetes";
|
|
|
|
type = types.path;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:14:00 +01:00
|
|
|
featureGates = mkOption {
|
|
|
|
description = "List set of feature gates";
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
apiserver = {
|
|
|
|
enable = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to enable Kubernetes apiserver.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:14:00 +01:00
|
|
|
featureGates = mkOption {
|
|
|
|
description = "List set of feature gates";
|
|
|
|
default = cfg.featureGates;
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
address = mkOption {
|
|
|
|
description = "Kubernetes apiserver listening address.";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
publicAddress = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver public listening address used for read only and
|
|
|
|
secure port.
|
|
|
|
'';
|
|
|
|
default = cfg.apiserver.address;
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
advertiseAddress = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver IP address on which to advertise the apiserver
|
|
|
|
to members of the cluster. This address must be reachable by the rest
|
|
|
|
of the cluster.
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
};
|
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
storageBackend = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver storage backend.
|
|
|
|
'';
|
2017-05-24 18:05:54 +01:00
|
|
|
default = "etcd3";
|
2017-04-26 21:44:38 +01:00
|
|
|
type = types.enum ["etcd2" "etcd3"];
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
port = mkOption {
|
2015-09-15 06:17:06 +01:00
|
|
|
description = "Kubernetes apiserver listening port.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = 8080;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
securePort = mkOption {
|
|
|
|
description = "Kubernetes apiserver secure port.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = 443;
|
2014-11-23 00:27:04 +00:00
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
tlsCertFile = mkOption {
|
|
|
|
description = "Kubernetes apiserver certificate file.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
tlsKeyFile = mkOption {
|
2014-11-23 00:27:04 +00:00
|
|
|
description = "Kubernetes apiserver private key file.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
2015-08-19 22:52:19 +01:00
|
|
|
clientCaFile = mkOption {
|
|
|
|
description = "Kubernetes apiserver CA file for client auth.";
|
2017-05-30 10:57:52 +01:00
|
|
|
default = cfg.caFile;
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.nullOr types.path;
|
2015-08-19 22:52:19 +01:00
|
|
|
};
|
|
|
|
|
2016-12-12 00:27:14 +00:00
|
|
|
tokenAuthFile = mkOption {
|
2014-11-23 00:27:04 +00:00
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver token authentication file. See
|
2018-05-24 13:16:08 +01:00
|
|
|
<link xlink:href="https://kubernetes.io/docs/reference/access-authn-authz/authentication"/>
|
2014-11-23 00:27:04 +00:00
|
|
|
'';
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
2016-12-12 00:27:14 +00:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
basicAuthFile = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver basic authentication file. See
|
2018-05-24 13:16:08 +01:00
|
|
|
<link xlink:href="https://kubernetes.io/docs/reference/access-authn-authz/authentication"/>
|
2016-12-12 00:27:14 +00:00
|
|
|
'';
|
|
|
|
default = pkgs.writeText "users" ''
|
|
|
|
kubernetes,admin,0
|
|
|
|
'';
|
|
|
|
type = types.nullOr types.path;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
authorizationMode = mkOption {
|
|
|
|
description = ''
|
2016-12-12 00:27:14 +00:00
|
|
|
Kubernetes apiserver authorization mode (AlwaysAllow/AlwaysDeny/ABAC/RBAC). See
|
2018-05-24 13:16:08 +01:00
|
|
|
<link xlink:href="https://kubernetes.io/docs/reference/access-authn-authz/authorization/"/>
|
2014-11-23 00:27:04 +00:00
|
|
|
'';
|
2018-02-04 20:23:36 +00:00
|
|
|
default = ["RBAC" "Node"];
|
|
|
|
type = types.listOf (types.enum ["AlwaysAllow" "AlwaysDeny" "ABAC" "RBAC" "Node"]);
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
authorizationPolicy = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver authorization policy file. See
|
2018-05-24 13:16:08 +01:00
|
|
|
<link xlink:href="https://kubernetes.io/docs/reference/access-authn-authz/authorization/"/>
|
2014-11-23 00:27:04 +00:00
|
|
|
'';
|
2017-05-30 12:11:39 +01:00
|
|
|
default = [];
|
2014-11-23 00:27:04 +00:00
|
|
|
type = types.listOf types.attrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
allowPrivileged = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to allow privileged containers on Kubernetes.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = true;
|
2014-11-23 00:27:04 +00:00
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2017-05-26 22:21:17 +01:00
|
|
|
serviceClusterIpRange = mkOption {
|
|
|
|
description = ''
|
|
|
|
A CIDR notation IP range from which to assign service cluster IPs.
|
|
|
|
This must not overlap with any IP ranges assigned to nodes for pods.
|
|
|
|
'';
|
2017-05-30 13:54:29 +01:00
|
|
|
default = "10.0.0.0/24";
|
2014-11-23 00:27:04 +00:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
2015-08-19 22:52:19 +01:00
|
|
|
runtimeConfig = mkOption {
|
2015-08-29 17:20:24 +01:00
|
|
|
description = ''
|
|
|
|
Api runtime configuration. See
|
2018-05-24 13:16:08 +01:00
|
|
|
<link xlink:href="https://kubernetes.io/docs/tasks/administer-cluster/cluster-management/"/>
|
2015-08-29 17:20:24 +01:00
|
|
|
'';
|
2017-09-01 11:20:10 +01:00
|
|
|
default = "authentication.k8s.io/v1beta1=true";
|
2015-08-19 22:52:19 +01:00
|
|
|
example = "api/all=false,api/v1=true";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
2018-03-31 00:16:32 +01:00
|
|
|
enableAdmissionPlugins = mkOption {
|
2015-08-29 17:20:24 +01:00
|
|
|
description = ''
|
2018-03-31 00:16:32 +01:00
|
|
|
Kubernetes admission control plugins to enable. See
|
2018-03-25 06:04:25 +01:00
|
|
|
<link xlink:href="https://kubernetes.io/docs/admin/admission-controllers/"/>
|
2015-08-29 17:20:24 +01:00
|
|
|
'';
|
2018-02-04 20:23:36 +00:00
|
|
|
default = ["NamespaceLifecycle" "LimitRanger" "ServiceAccount" "ResourceQuota" "DefaultStorageClass" "DefaultTolerationSeconds" "NodeRestriction"];
|
2015-08-29 17:20:24 +01:00
|
|
|
example = [
|
|
|
|
"NamespaceLifecycle" "NamespaceExists" "LimitRanger"
|
|
|
|
"SecurityContextDeny" "ServiceAccount" "ResourceQuota"
|
2017-05-30 13:55:02 +01:00
|
|
|
"PodSecurityPolicy" "NodeRestriction" "DefaultStorageClass"
|
2015-08-29 17:20:24 +01:00
|
|
|
];
|
2015-08-19 22:52:19 +01:00
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2018-03-31 00:16:32 +01:00
|
|
|
disableAdmissionPlugins = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes admission control plugins to disable. See
|
|
|
|
<link xlink:href="https://kubernetes.io/docs/admin/admission-controllers/"/>
|
|
|
|
'';
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
serviceAccountKeyFile = mkOption {
|
2015-08-29 17:20:24 +01:00
|
|
|
description = ''
|
|
|
|
Kubernetes apiserver PEM-encoded x509 RSA private or public key file,
|
2016-11-16 15:29:35 +00:00
|
|
|
used to verify ServiceAccount tokens. By default tls private key file
|
|
|
|
is used.
|
2015-08-29 17:20:24 +01:00
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
kubeletClientCaFile = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Path to a cert file for connecting to kubelet.";
|
2017-05-30 10:57:52 +01:00
|
|
|
default = cfg.caFile;
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
kubeletClientCertFile = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Client certificate to use for connections to kubelet.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
kubeletClientKeyFile = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Key to use for connections to kubelet.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
kubeletHttps = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to use https for connections to kubelet.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
extraOpts = mkOption {
|
|
|
|
description = "Kubernetes apiserver extra command line options.";
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
scheduler = {
|
|
|
|
enable = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to enable Kubernetes scheduler.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:14:00 +01:00
|
|
|
featureGates = mkOption {
|
|
|
|
description = "List set of feature gates";
|
|
|
|
default = cfg.featureGates;
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
address = mkOption {
|
|
|
|
description = "Kubernetes scheduler listening address.";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2015-09-15 06:17:06 +01:00
|
|
|
description = "Kubernetes scheduler listening port.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = 10251;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
leaderElect = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to start leader election before executing main loop.";
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.bool;
|
2017-05-30 13:55:22 +01:00
|
|
|
default = true;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
kubeconfig = mkKubeConfigOptions "Kubernetes scheduler";
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
extraOpts = mkOption {
|
|
|
|
description = "Kubernetes scheduler extra command line options.";
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
controllerManager = {
|
|
|
|
enable = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to enable Kubernetes controller manager.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:14:00 +01:00
|
|
|
featureGates = mkOption {
|
|
|
|
description = "List set of feature gates";
|
|
|
|
default = cfg.featureGates;
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
address = mkOption {
|
|
|
|
description = "Kubernetes controller manager listening address.";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2015-09-15 06:17:06 +01:00
|
|
|
description = "Kubernetes controller manager listening port.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = 10252;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
leaderElect = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to start leader election before executing main loop.";
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.bool;
|
2017-05-30 13:55:22 +01:00
|
|
|
default = true;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
serviceAccountKeyFile = mkOption {
|
2015-08-29 17:20:24 +01:00
|
|
|
description = ''
|
|
|
|
Kubernetes controller manager PEM-encoded private RSA key file used to
|
|
|
|
sign service account tokens
|
|
|
|
'';
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
rootCaFile = mkOption {
|
|
|
|
description = ''
|
|
|
|
Kubernetes controller manager certificate authority file included in
|
|
|
|
service account's token secret.
|
|
|
|
'';
|
2017-05-30 10:57:52 +01:00
|
|
|
default = cfg.caFile;
|
2015-08-29 17:20:24 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
kubeconfig = mkKubeConfigOptions "Kubernetes controller manager";
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
extraOpts = mkOption {
|
2015-08-29 17:20:24 +01:00
|
|
|
description = "Kubernetes controller manager extra command line options.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
kubelet = {
|
|
|
|
enable = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to enable Kubernetes kubelet.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:14:00 +01:00
|
|
|
featureGates = mkOption {
|
|
|
|
description = "List set of feature gates";
|
|
|
|
default = cfg.featureGates;
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:22:12 +01:00
|
|
|
seedDockerImages = mkOption {
|
|
|
|
description = "List of docker images to preload on system";
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.package;
|
|
|
|
};
|
|
|
|
|
2015-07-07 10:34:33 +01:00
|
|
|
registerNode = mkOption {
|
|
|
|
description = "Whether to auto register kubelet with API server.";
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
address = mkOption {
|
|
|
|
description = "Kubernetes kubelet info server listening address.";
|
|
|
|
default = "0.0.0.0";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2015-09-15 06:17:06 +01:00
|
|
|
description = "Kubernetes kubelet info server listening port.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = 10250;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
tlsCertFile = mkOption {
|
|
|
|
description = "File containing x509 Certificate for HTTPS.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
tlsKeyFile = mkOption {
|
|
|
|
description = "File containing x509 private key matching tlsCertFile.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:20:10 +01:00
|
|
|
clientCaFile = mkOption {
|
|
|
|
description = "Kubernetes apiserver CA file for client authentication.";
|
|
|
|
default = cfg.caFile;
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
2015-08-19 22:52:19 +01:00
|
|
|
healthz = {
|
|
|
|
bind = mkOption {
|
|
|
|
description = "Kubernetes kubelet healthz listening address.";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
description = "Kubernetes kubelet healthz port.";
|
|
|
|
default = 10248;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
hostname = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Kubernetes kubelet hostname override.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = config.networking.hostName;
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
allowPrivileged = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to allow Kubernetes containers to request privileged mode.";
|
2016-11-16 15:29:35 +00:00
|
|
|
default = true;
|
2014-11-23 00:27:04 +00:00
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2018-03-31 00:16:32 +01:00
|
|
|
# TODO: remove this deprecated flag
|
2015-03-18 13:26:40 +00:00
|
|
|
cadvisorPort = mkOption {
|
|
|
|
description = "Kubernetes kubelet local cadvisor port.";
|
2015-07-07 10:34:33 +01:00
|
|
|
default = 4194;
|
2015-03-18 13:26:40 +00:00
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
clusterDns = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Use alternative DNS.";
|
2017-09-09 00:58:35 +01:00
|
|
|
default = "10.1.0.1";
|
2015-03-18 13:26:40 +00:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
clusterDomain = mkOption {
|
|
|
|
description = "Use alternative domain.";
|
2017-09-01 11:31:56 +01:00
|
|
|
default = config.services.kubernetes.addons.dns.clusterDomain;
|
2015-03-18 13:26:40 +00:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
networkPlugin = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Network plugin to use by Kubernetes.";
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.nullOr (types.enum ["cni" "kubenet"]);
|
|
|
|
default = "kubenet";
|
|
|
|
};
|
|
|
|
|
|
|
|
cni = {
|
|
|
|
packages = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "List of network plugin packages to install.";
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Kubernetes CNI configuration.";
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.listOf types.attrs;
|
|
|
|
default = [];
|
|
|
|
example = literalExample ''
|
|
|
|
[{
|
|
|
|
"cniVersion": "0.2.0",
|
|
|
|
"name": "mynet",
|
|
|
|
"type": "bridge",
|
|
|
|
"bridge": "cni0",
|
|
|
|
"isGateway": true,
|
|
|
|
"ipMasq": true,
|
|
|
|
"ipam": {
|
|
|
|
"type": "host-local",
|
|
|
|
"subnet": "10.22.0.0/16",
|
|
|
|
"routes": [
|
|
|
|
{ "dst": "0.0.0.0/0" }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
} {
|
|
|
|
"cniVersion": "0.2.0",
|
|
|
|
"type": "loopback"
|
|
|
|
}]
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
manifests = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "List of manifests to bootstrap with kubelet (only pods can be created as manifest entry)";
|
2016-11-16 15:29:35 +00:00
|
|
|
type = types.attrsOf types.attrs;
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
applyManifests = mkOption {
|
2017-05-24 18:05:54 +01:00
|
|
|
description = "Whether to apply manifests (this is true for master node).";
|
2017-04-26 21:44:38 +01:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
unschedulable = mkOption {
|
|
|
|
description = "Whether to set node taint to unschedulable=true as it is the case of node that has only master role.";
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
taints = mkOption {
|
2017-05-24 18:05:54 +01:00
|
|
|
description = "Node taints (https://kubernetes.io/docs/concepts/configuration/assign-pod-node/).";
|
2017-04-26 21:44:38 +01:00
|
|
|
default = {};
|
|
|
|
type = types.attrsOf (types.submodule [ taintOptions ]);
|
|
|
|
};
|
|
|
|
|
2017-05-26 22:21:17 +01:00
|
|
|
nodeIp = mkOption {
|
|
|
|
description = "IP address of the node. If set, kubelet will use this IP address for the node.";
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
};
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
kubeconfig = mkKubeConfigOptions "Kubelet";
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
extraOpts = mkOption {
|
|
|
|
description = "Kubernetes kubelet extra command line options.";
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
proxy = {
|
|
|
|
enable = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Whether to enable Kubernetes proxy.";
|
2014-11-23 00:27:04 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2017-09-01 11:14:00 +01:00
|
|
|
featureGates = mkOption {
|
|
|
|
description = "List set of feature gates";
|
|
|
|
default = cfg.featureGates;
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
address = mkOption {
|
|
|
|
description = "Kubernetes proxy listening address.";
|
|
|
|
default = "0.0.0.0";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
2017-05-30 10:26:32 +01:00
|
|
|
kubeconfig = mkKubeConfigOptions "Kubernetes proxy";
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
extraOpts = mkOption {
|
|
|
|
description = "Kubernetes proxy extra command line options.";
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
2015-06-08 12:15:26 +01:00
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
addonManager = {
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Whether to enable Kubernetes addon manager.";
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
addons = mkOption {
|
|
|
|
description = "Kubernetes addons (any kind of Kubernetes resource can be an addon).";
|
|
|
|
default = { };
|
2017-09-01 11:31:56 +01:00
|
|
|
type = types.attrsOf (types.either types.attrs (types.listOf types.attrs));
|
2017-04-26 21:44:38 +01:00
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
"my-service" = {
|
|
|
|
"apiVersion" = "v1";
|
|
|
|
"kind" = "Service";
|
|
|
|
"metadata" = {
|
|
|
|
"name" = "my-service";
|
|
|
|
"namespace" = "default";
|
|
|
|
};
|
|
|
|
"spec" = { ... };
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// import <nixpkgs/nixos/modules/services/cluster/kubernetes/dashboard.nix> { cfg = config.services.kubernetes; };
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-04-21 14:25:05 +01:00
|
|
|
path = mkOption {
|
2017-04-26 21:44:38 +01:00
|
|
|
description = "Packages added to the services' PATH environment variable. Both the bin and sbin subdirectories of each package are added.";
|
2017-04-21 14:25:05 +01:00
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
2015-06-08 12:15:26 +01:00
|
|
|
};
|
2017-04-21 14:25:05 +01:00
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
clusterCidr = mkOption {
|
|
|
|
description = "Kubernetes controller manager and proxy CIDR Range for Pods in cluster.";
|
2017-05-30 13:54:29 +01:00
|
|
|
default = "10.1.0.0/16";
|
2017-04-26 21:44:38 +01:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
2017-05-26 22:21:17 +01:00
|
|
|
flannel.enable = mkOption {
|
|
|
|
description = "Whether to enable flannel networking";
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkMerge [
|
2016-11-16 15:29:35 +00:00
|
|
|
(mkIf cfg.kubelet.enable {
|
2017-09-01 11:22:12 +01:00
|
|
|
services.kubernetes.kubelet.seedDockerImages = [infraContainer];
|
|
|
|
|
|
|
|
systemd.services.kubelet-bootstrap = {
|
|
|
|
description = "Boostrap Kubelet";
|
|
|
|
wantedBy = ["kubernetes.target"];
|
|
|
|
after = ["docker.service" "network.target"];
|
|
|
|
path = with pkgs; [ docker ];
|
|
|
|
script = ''
|
|
|
|
${concatMapStrings (img: ''
|
|
|
|
echo "Seeding docker image: ${img}"
|
|
|
|
docker load <${img}
|
|
|
|
'') cfg.kubelet.seedDockerImages}
|
|
|
|
|
|
|
|
rm /opt/cni/bin/* || true
|
|
|
|
${concatMapStrings (package: ''
|
|
|
|
echo "Linking cni package: ${package}"
|
2018-03-17 05:35:35 +00:00
|
|
|
ln -fs ${package}/bin/* /opt/cni/bin
|
2017-09-01 11:22:12 +01:00
|
|
|
'') cfg.kubelet.cni.packages}
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
Slice = "kubernetes.slice";
|
|
|
|
Type = "oneshot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
systemd.services.kubelet = {
|
|
|
|
description = "Kubernetes Kubelet Service";
|
2017-04-13 12:32:10 +01:00
|
|
|
wantedBy = [ "kubernetes.target" ];
|
2017-09-01 11:22:12 +01:00
|
|
|
after = [ "network.target" "docker.service" "kube-apiserver.service" "kubelet-bootstrap.service" ];
|
2017-06-04 21:41:19 +01:00
|
|
|
path = with pkgs; [ gitMinimal openssh docker utillinux iproute ethtool thin-provisioning-tools iptables socat ] ++ cfg.path;
|
2016-11-16 15:29:35 +00:00
|
|
|
serviceConfig = {
|
2017-04-13 12:32:10 +01:00
|
|
|
Slice = "kubernetes.slice";
|
2016-11-16 15:29:35 +00:00
|
|
|
ExecStart = ''${cfg.package}/bin/kubelet \
|
2017-04-26 21:44:38 +01:00
|
|
|
${optionalString (taints != "")
|
|
|
|
"--register-with-taints=${taints}"} \
|
2017-05-30 10:26:32 +01:00
|
|
|
--kubeconfig=${mkKubeConfig "kubelet" cfg.kubelet.kubeconfig} \
|
2018-03-31 00:16:32 +01:00
|
|
|
--config=${kubeletConfig} \
|
2016-11-16 15:29:35 +00:00
|
|
|
--address=${cfg.kubelet.address} \
|
|
|
|
--port=${toString cfg.kubelet.port} \
|
2017-04-11 17:08:51 +01:00
|
|
|
--register-node=${boolToString cfg.kubelet.registerNode} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString (cfg.kubelet.tlsCertFile != null)
|
|
|
|
"--tls-cert-file=${cfg.kubelet.tlsCertFile}"} \
|
|
|
|
${optionalString (cfg.kubelet.tlsKeyFile != null)
|
|
|
|
"--tls-private-key-file=${cfg.kubelet.tlsKeyFile}"} \
|
2017-09-01 11:20:10 +01:00
|
|
|
${optionalString (cfg.kubelet.clientCaFile != null)
|
|
|
|
"--client-ca-file=${cfg.kubelet.clientCaFile}"} \
|
|
|
|
--authentication-token-webhook \
|
|
|
|
--authentication-token-webhook-cache-ttl="10s" \
|
|
|
|
--authorization-mode=Webhook \
|
2016-11-16 15:29:35 +00:00
|
|
|
--healthz-bind-address=${cfg.kubelet.healthz.bind} \
|
|
|
|
--healthz-port=${toString cfg.kubelet.healthz.port} \
|
|
|
|
--hostname-override=${cfg.kubelet.hostname} \
|
2017-04-11 17:08:51 +01:00
|
|
|
--allow-privileged=${boolToString cfg.kubelet.allowPrivileged} \
|
2016-11-16 15:29:35 +00:00
|
|
|
--root-dir=${cfg.dataDir} \
|
|
|
|
--cadvisor_port=${toString cfg.kubelet.cadvisorPort} \
|
|
|
|
${optionalString (cfg.kubelet.clusterDns != "")
|
|
|
|
"--cluster-dns=${cfg.kubelet.clusterDns}"} \
|
|
|
|
${optionalString (cfg.kubelet.clusterDomain != "")
|
|
|
|
"--cluster-domain=${cfg.kubelet.clusterDomain}"} \
|
|
|
|
--pod-infra-container-image=pause \
|
|
|
|
${optionalString (cfg.kubelet.networkPlugin != null)
|
|
|
|
"--network-plugin=${cfg.kubelet.networkPlugin}"} \
|
|
|
|
--cni-conf-dir=${cniConfig} \
|
|
|
|
--hairpin-mode=hairpin-veth \
|
2017-05-26 22:21:17 +01:00
|
|
|
${optionalString (cfg.kubelet.nodeIp != null)
|
|
|
|
"--node-ip=${cfg.kubelet.nodeIp}"} \
|
2017-09-01 11:14:00 +01:00
|
|
|
${optionalString (cfg.kubelet.featureGates != [])
|
|
|
|
"--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.kubelet.featureGates}"} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString cfg.verbose "--v=6 --log_flush_frequency=1s"} \
|
|
|
|
${cfg.kubelet.extraOpts}
|
|
|
|
'';
|
|
|
|
WorkingDirectory = cfg.dataDir;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
# Allways include cni plugins
|
2018-03-17 05:35:35 +00:00
|
|
|
services.kubernetes.kubelet.cni.packages = [pkgs.cni-plugins];
|
2017-05-26 22:21:17 +01:00
|
|
|
|
|
|
|
boot.kernelModules = ["br_netfilter"];
|
2017-05-30 10:26:32 +01:00
|
|
|
|
|
|
|
services.kubernetes.kubelet.kubeconfig = kubeConfigDefaults;
|
2017-04-26 21:44:38 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf (cfg.kubelet.applyManifests && cfg.kubelet.enable) {
|
2016-11-16 15:29:35 +00:00
|
|
|
environment.etc = mapAttrs' (name: manifest:
|
|
|
|
nameValuePair "kubernetes/manifests/${name}.json" {
|
|
|
|
text = builtins.toJSON manifest;
|
|
|
|
mode = "0755";
|
|
|
|
}
|
|
|
|
) cfg.kubelet.manifests;
|
2017-04-26 21:44:38 +01:00
|
|
|
})
|
2016-11-16 15:29:35 +00:00
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
(mkIf (cfg.kubelet.unschedulable && cfg.kubelet.enable) {
|
|
|
|
services.kubernetes.kubelet.taints.unschedulable = {
|
|
|
|
value = "true";
|
|
|
|
effect = "NoSchedule";
|
|
|
|
};
|
2016-11-16 15:29:35 +00:00
|
|
|
})
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
(mkIf cfg.apiserver.enable {
|
2015-06-08 12:15:26 +01:00
|
|
|
systemd.services.kube-apiserver = {
|
2016-11-16 15:29:35 +00:00
|
|
|
description = "Kubernetes Kubelet Service";
|
2017-04-13 12:32:10 +01:00
|
|
|
wantedBy = [ "kubernetes.target" ];
|
2016-11-16 15:29:35 +00:00
|
|
|
after = [ "network.target" "docker.service" ];
|
2014-11-23 00:27:04 +00:00
|
|
|
serviceConfig = {
|
2017-04-13 12:32:10 +01:00
|
|
|
Slice = "kubernetes.slice";
|
2016-11-16 15:29:35 +00:00
|
|
|
ExecStart = ''${cfg.package}/bin/kube-apiserver \
|
|
|
|
--etcd-servers=${concatStringsSep "," cfg.etcd.servers} \
|
|
|
|
${optionalString (cfg.etcd.caFile != null)
|
|
|
|
"--etcd-cafile=${cfg.etcd.caFile}"} \
|
|
|
|
${optionalString (cfg.etcd.certFile != null)
|
|
|
|
"--etcd-certfile=${cfg.etcd.certFile}"} \
|
|
|
|
${optionalString (cfg.etcd.keyFile != null)
|
|
|
|
"--etcd-keyfile=${cfg.etcd.keyFile}"} \
|
2015-06-08 12:10:32 +01:00
|
|
|
--insecure-port=${toString cfg.apiserver.port} \
|
2016-11-16 15:29:35 +00:00
|
|
|
--bind-address=0.0.0.0 \
|
|
|
|
${optionalString (cfg.apiserver.advertiseAddress != null)
|
|
|
|
"--advertise-address=${cfg.apiserver.advertiseAddress}"} \
|
2017-04-11 17:08:51 +01:00
|
|
|
--allow-privileged=${boolToString cfg.apiserver.allowPrivileged}\
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString (cfg.apiserver.tlsCertFile != null)
|
2015-06-08 12:10:32 +01:00
|
|
|
"--tls-cert-file=${cfg.apiserver.tlsCertFile}"} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString (cfg.apiserver.tlsKeyFile != null)
|
|
|
|
"--tls-private-key-file=${cfg.apiserver.tlsKeyFile}"} \
|
2016-12-12 00:27:14 +00:00
|
|
|
${optionalString (cfg.apiserver.tokenAuthFile != null)
|
|
|
|
"--token-auth-file=${cfg.apiserver.tokenAuthFile}"} \
|
|
|
|
${optionalString (cfg.apiserver.basicAuthFile != null)
|
|
|
|
"--basic-auth-file=${cfg.apiserver.basicAuthFile}"} \
|
|
|
|
--kubelet-https=${if cfg.apiserver.kubeletHttps then "true" else "false"} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString (cfg.apiserver.kubeletClientCaFile != null)
|
|
|
|
"--kubelet-certificate-authority=${cfg.apiserver.kubeletClientCaFile}"} \
|
|
|
|
${optionalString (cfg.apiserver.kubeletClientCertFile != null)
|
|
|
|
"--kubelet-client-certificate=${cfg.apiserver.kubeletClientCertFile}"} \
|
|
|
|
${optionalString (cfg.apiserver.kubeletClientKeyFile != null)
|
|
|
|
"--kubelet-client-key=${cfg.apiserver.kubeletClientKeyFile}"} \
|
|
|
|
${optionalString (cfg.apiserver.clientCaFile != null)
|
2015-08-19 22:52:19 +01:00
|
|
|
"--client-ca-file=${cfg.apiserver.clientCaFile}"} \
|
2016-12-12 00:27:14 +00:00
|
|
|
--authorization-mode=${concatStringsSep "," cfg.apiserver.authorizationMode} \
|
|
|
|
${optionalString (elem "ABAC" cfg.apiserver.authorizationMode)
|
|
|
|
"--authorization-policy-file=${
|
2017-04-26 21:44:38 +01:00
|
|
|
pkgs.writeText "kube-auth-policy.jsonl"
|
2016-12-12 00:27:14 +00:00
|
|
|
(concatMapStringsSep "\n" (l: builtins.toJSON l) cfg.apiserver.authorizationPolicy)
|
|
|
|
}"
|
|
|
|
} \
|
2015-06-08 12:10:32 +01:00
|
|
|
--secure-port=${toString cfg.apiserver.securePort} \
|
2017-05-26 22:21:17 +01:00
|
|
|
--service-cluster-ip-range=${cfg.apiserver.serviceClusterIpRange} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString (cfg.apiserver.runtimeConfig != "")
|
2015-08-19 22:52:19 +01:00
|
|
|
"--runtime-config=${cfg.apiserver.runtimeConfig}"} \
|
2018-03-31 00:16:32 +01:00
|
|
|
--enable-admission-plugins=${concatStringsSep "," cfg.apiserver.enableAdmissionPlugins} \
|
|
|
|
--disable-admission-plugins=${concatStringsSep "," cfg.apiserver.disableAdmissionPlugins} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString (cfg.apiserver.serviceAccountKeyFile!=null)
|
|
|
|
"--service-account-key-file=${cfg.apiserver.serviceAccountKeyFile}"} \
|
|
|
|
${optionalString cfg.verbose "--v=6"} \
|
|
|
|
${optionalString cfg.verbose "--log-flush-frequency=1s"} \
|
2017-04-26 21:44:38 +01:00
|
|
|
--storage-backend=${cfg.apiserver.storageBackend} \
|
2017-09-01 11:14:00 +01:00
|
|
|
${optionalString (cfg.kubelet.featureGates != [])
|
|
|
|
"--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.kubelet.featureGates}"} \
|
2014-11-23 00:27:04 +00:00
|
|
|
${cfg.apiserver.extraOpts}
|
|
|
|
'';
|
2016-11-16 15:29:35 +00:00
|
|
|
WorkingDirectory = cfg.dataDir;
|
2014-11-23 00:27:04 +00:00
|
|
|
User = "kubernetes";
|
2016-11-16 15:29:35 +00:00
|
|
|
Group = "kubernetes";
|
|
|
|
AmbientCapabilities = "cap_net_bind_service";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = 5;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.scheduler.enable {
|
2015-06-08 12:15:26 +01:00
|
|
|
systemd.services.kube-scheduler = {
|
2014-11-23 00:27:04 +00:00
|
|
|
description = "Kubernetes Scheduler Service";
|
2017-04-13 12:32:10 +01:00
|
|
|
wantedBy = [ "kubernetes.target" ];
|
2016-11-16 15:29:35 +00:00
|
|
|
after = [ "kube-apiserver.service" ];
|
2014-11-23 00:27:04 +00:00
|
|
|
serviceConfig = {
|
2017-04-13 12:32:10 +01:00
|
|
|
Slice = "kubernetes.slice";
|
2014-11-23 00:27:04 +00:00
|
|
|
ExecStart = ''${cfg.package}/bin/kube-scheduler \
|
2015-03-18 13:26:40 +00:00
|
|
|
--address=${cfg.scheduler.address} \
|
|
|
|
--port=${toString cfg.scheduler.port} \
|
2017-04-11 17:08:51 +01:00
|
|
|
--leader-elect=${boolToString cfg.scheduler.leaderElect} \
|
2017-05-30 10:26:32 +01:00
|
|
|
--kubeconfig=${mkKubeConfig "kube-scheduler" cfg.scheduler.kubeconfig} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString cfg.verbose "--v=6"} \
|
|
|
|
${optionalString cfg.verbose "--log-flush-frequency=1s"} \
|
2017-09-01 11:14:00 +01:00
|
|
|
${optionalString (cfg.scheduler.featureGates != [])
|
|
|
|
"--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.scheduler.featureGates}"} \
|
2014-11-23 00:27:04 +00:00
|
|
|
${cfg.scheduler.extraOpts}
|
|
|
|
'';
|
2016-11-16 15:29:35 +00:00
|
|
|
WorkingDirectory = cfg.dataDir;
|
2014-11-23 00:27:04 +00:00
|
|
|
User = "kubernetes";
|
2016-11-16 15:29:35 +00:00
|
|
|
Group = "kubernetes";
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
};
|
2017-05-30 10:26:32 +01:00
|
|
|
|
|
|
|
services.kubernetes.scheduler.kubeconfig = kubeConfigDefaults;
|
2014-11-23 00:27:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.controllerManager.enable {
|
2015-06-08 12:15:26 +01:00
|
|
|
systemd.services.kube-controller-manager = {
|
2014-11-23 00:27:04 +00:00
|
|
|
description = "Kubernetes Controller Manager Service";
|
2017-04-13 12:32:10 +01:00
|
|
|
wantedBy = [ "kubernetes.target" ];
|
2016-11-16 15:29:35 +00:00
|
|
|
after = [ "kube-apiserver.service" ];
|
2014-11-23 00:27:04 +00:00
|
|
|
serviceConfig = {
|
2016-12-14 12:47:29 +00:00
|
|
|
RestartSec = "30s";
|
|
|
|
Restart = "on-failure";
|
2017-04-13 12:32:10 +01:00
|
|
|
Slice = "kubernetes.slice";
|
2014-11-23 00:27:04 +00:00
|
|
|
ExecStart = ''${cfg.package}/bin/kube-controller-manager \
|
2015-03-18 13:26:40 +00:00
|
|
|
--address=${cfg.controllerManager.address} \
|
|
|
|
--port=${toString cfg.controllerManager.port} \
|
2017-05-30 10:26:32 +01:00
|
|
|
--kubeconfig=${mkKubeConfig "kube-controller-manager" cfg.controllerManager.kubeconfig} \
|
2017-04-11 17:08:51 +01:00
|
|
|
--leader-elect=${boolToString cfg.controllerManager.leaderElect} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${if (cfg.controllerManager.serviceAccountKeyFile!=null)
|
|
|
|
then "--service-account-private-key-file=${cfg.controllerManager.serviceAccountKeyFile}"
|
|
|
|
else "--service-account-private-key-file=/var/run/kubernetes/apiserver.key"} \
|
2016-12-12 00:27:14 +00:00
|
|
|
${if (cfg.controllerManager.rootCaFile!=null)
|
|
|
|
then "--root-ca-file=${cfg.controllerManager.rootCaFile}"
|
|
|
|
else "--root-ca-file=/var/run/kubernetes/apiserver.crt"} \
|
2017-04-26 21:44:38 +01:00
|
|
|
${optionalString (cfg.clusterCidr!=null)
|
|
|
|
"--cluster-cidr=${cfg.clusterCidr}"} \
|
2016-11-16 15:29:35 +00:00
|
|
|
--allocate-node-cidrs=true \
|
2017-09-01 11:14:00 +01:00
|
|
|
${optionalString (cfg.controllerManager.featureGates != [])
|
|
|
|
"--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.controllerManager.featureGates}"} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString cfg.verbose "--v=6"} \
|
|
|
|
${optionalString cfg.verbose "--log-flush-frequency=1s"} \
|
2014-11-23 00:27:04 +00:00
|
|
|
${cfg.controllerManager.extraOpts}
|
|
|
|
'';
|
2016-11-16 15:29:35 +00:00
|
|
|
WorkingDirectory = cfg.dataDir;
|
2014-11-23 00:27:04 +00:00
|
|
|
User = "kubernetes";
|
2016-11-16 15:29:35 +00:00
|
|
|
Group = "kubernetes";
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
2017-04-21 14:25:05 +01:00
|
|
|
path = cfg.path;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
2017-05-30 10:26:32 +01:00
|
|
|
|
|
|
|
services.kubernetes.controllerManager.kubeconfig = kubeConfigDefaults;
|
2014-11-23 00:27:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.proxy.enable {
|
2015-06-08 12:15:26 +01:00
|
|
|
systemd.services.kube-proxy = {
|
2014-11-23 00:27:04 +00:00
|
|
|
description = "Kubernetes Proxy Service";
|
2017-04-13 12:32:10 +01:00
|
|
|
wantedBy = [ "kubernetes.target" ];
|
2016-11-16 15:29:35 +00:00
|
|
|
after = [ "kube-apiserver.service" ];
|
2017-04-26 21:44:38 +01:00
|
|
|
path = [pkgs.iptables pkgs.conntrack_tools];
|
2014-11-23 00:27:04 +00:00
|
|
|
serviceConfig = {
|
2017-04-13 12:32:10 +01:00
|
|
|
Slice = "kubernetes.slice";
|
2014-11-23 00:27:04 +00:00
|
|
|
ExecStart = ''${cfg.package}/bin/kube-proxy \
|
2017-05-30 10:26:32 +01:00
|
|
|
--kubeconfig=${mkKubeConfig "kube-proxy" cfg.proxy.kubeconfig} \
|
2015-06-08 12:10:32 +01:00
|
|
|
--bind-address=${cfg.proxy.address} \
|
2017-09-01 11:14:00 +01:00
|
|
|
${optionalString (cfg.proxy.featureGates != [])
|
|
|
|
"--feature-gates=${concatMapStringsSep "," (feature: "${feature}=true") cfg.proxy.featureGates}"} \
|
2016-11-16 15:29:35 +00:00
|
|
|
${optionalString cfg.verbose "--v=6"} \
|
|
|
|
${optionalString cfg.verbose "--log-flush-frequency=1s"} \
|
2017-04-26 21:44:38 +01:00
|
|
|
${optionalString (cfg.clusterCidr!=null)
|
|
|
|
"--cluster-cidr=${cfg.clusterCidr}"} \
|
2017-02-12 15:06:59 +00:00
|
|
|
${cfg.proxy.extraOpts}
|
2014-11-23 00:27:04 +00:00
|
|
|
'';
|
2016-11-16 15:29:35 +00:00
|
|
|
WorkingDirectory = cfg.dataDir;
|
2014-11-23 00:27:04 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-05-26 22:21:17 +01:00
|
|
|
# kube-proxy needs iptables
|
|
|
|
networking.firewall.enable = mkDefault true;
|
2017-05-30 10:26:32 +01:00
|
|
|
|
|
|
|
services.kubernetes.proxy.kubeconfig = kubeConfigDefaults;
|
2016-11-16 15:29:35 +00:00
|
|
|
})
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
(mkIf (any (el: el == "master") cfg.roles) {
|
2016-11-16 15:29:35 +00:00
|
|
|
virtualisation.docker.enable = mkDefault true;
|
|
|
|
services.kubernetes.kubelet.enable = mkDefault true;
|
|
|
|
services.kubernetes.kubelet.allowPrivileged = mkDefault true;
|
2017-04-26 21:44:38 +01:00
|
|
|
services.kubernetes.kubelet.applyManifests = mkDefault true;
|
2014-12-11 22:32:37 +00:00
|
|
|
services.kubernetes.apiserver.enable = mkDefault true;
|
|
|
|
services.kubernetes.scheduler.enable = mkDefault true;
|
|
|
|
services.kubernetes.controllerManager.enable = mkDefault true;
|
2016-11-16 15:29:35 +00:00
|
|
|
services.etcd.enable = mkDefault (cfg.etcd.servers == ["http://127.0.0.1:2379"]);
|
2017-09-01 11:31:56 +01:00
|
|
|
services.kubernetes.addonManager.enable = mkDefault true;
|
2017-09-09 00:58:35 +01:00
|
|
|
services.kubernetes.proxy.enable = mkDefault true;
|
2014-11-23 00:27:04 +00:00
|
|
|
})
|
|
|
|
|
2017-05-26 22:21:17 +01:00
|
|
|
# if this node is only a master make it unschedulable by default
|
2017-04-26 21:44:38 +01:00
|
|
|
(mkIf (all (el: el == "master") cfg.roles) {
|
|
|
|
services.kubernetes.kubelet.unschedulable = mkDefault true;
|
|
|
|
})
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
(mkIf (any (el: el == "node") cfg.roles) {
|
2017-05-26 22:21:17 +01:00
|
|
|
virtualisation.docker = {
|
|
|
|
enable = mkDefault true;
|
|
|
|
|
|
|
|
# kubernetes needs access to logs
|
|
|
|
logDriver = mkDefault "json-file";
|
|
|
|
|
|
|
|
# iptables must be disabled for kubernetes
|
|
|
|
extraOptions = "--iptables=false --ip-masq=false";
|
|
|
|
};
|
|
|
|
|
2014-12-11 22:32:37 +00:00
|
|
|
services.kubernetes.kubelet.enable = mkDefault true;
|
|
|
|
services.kubernetes.proxy.enable = mkDefault true;
|
2014-11-23 00:27:04 +00:00
|
|
|
})
|
|
|
|
|
2017-04-26 21:44:38 +01:00
|
|
|
(mkIf cfg.addonManager.enable {
|
|
|
|
environment.etc."kubernetes/addons".source = "${addons}/";
|
|
|
|
|
2017-09-01 11:31:56 +01:00
|
|
|
systemd.services.kube-addon-manager = {
|
|
|
|
description = "Kubernetes addon manager";
|
2017-04-26 21:44:38 +01:00
|
|
|
wantedBy = [ "kubernetes.target" ];
|
|
|
|
after = [ "kube-apiserver.service" ];
|
2017-09-01 11:31:56 +01:00
|
|
|
environment.ADDON_PATH = "/etc/kubernetes/addons/";
|
2017-04-26 21:44:38 +01:00
|
|
|
serviceConfig = {
|
|
|
|
Slice = "kubernetes.slice";
|
2017-09-01 11:31:56 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/kube-addons";
|
2017-04-26 21:44:38 +01:00
|
|
|
WorkingDirectory = cfg.dataDir;
|
|
|
|
User = "kubernetes";
|
|
|
|
Group = "kubernetes";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
(mkIf (
|
|
|
|
cfg.apiserver.enable ||
|
|
|
|
cfg.scheduler.enable ||
|
|
|
|
cfg.controllerManager.enable ||
|
|
|
|
cfg.kubelet.enable ||
|
2017-09-01 11:31:56 +01:00
|
|
|
cfg.proxy.enable
|
2014-11-23 00:27:04 +00:00
|
|
|
) {
|
2017-04-13 12:32:10 +01:00
|
|
|
systemd.targets.kubernetes = {
|
|
|
|
description = "Kubernetes";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
2016-11-16 15:29:35 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /opt/cni/bin 0755 root root -"
|
|
|
|
"d /var/run/kubernetes 0755 kubernetes kubernetes -"
|
|
|
|
"d /var/lib/kubernetes 0755 kubernetes kubernetes -"
|
|
|
|
];
|
2014-12-02 11:59:14 +00:00
|
|
|
|
2014-11-23 00:27:04 +00:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
users.extraUsers = singleton {
|
|
|
|
name = "kubernetes";
|
|
|
|
uid = config.ids.uids.kubernetes;
|
|
|
|
description = "Kubernetes user";
|
|
|
|
extraGroups = [ "docker" ];
|
|
|
|
group = "kubernetes";
|
|
|
|
home = cfg.dataDir;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
users.extraGroups.kubernetes.gid = config.ids.gids.kubernetes;
|
2017-09-01 11:31:56 +01:00
|
|
|
|
|
|
|
# dns addon is enabled by default
|
|
|
|
services.kubernetes.addons.dns.enable = mkDefault true;
|
2014-11-23 00:27:04 +00:00
|
|
|
})
|
2017-05-26 22:21:17 +01:00
|
|
|
|
|
|
|
(mkIf cfg.flannel.enable {
|
|
|
|
services.flannel = {
|
|
|
|
enable = mkDefault true;
|
|
|
|
network = mkDefault cfg.clusterCidr;
|
|
|
|
etcd = mkDefault {
|
|
|
|
endpoints = cfg.etcd.servers;
|
|
|
|
inherit (cfg.etcd) caFile certFile keyFile;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.kubernetes.kubelet = {
|
|
|
|
networkPlugin = mkDefault "cni";
|
|
|
|
cni.config = mkDefault [{
|
|
|
|
name = "mynet";
|
|
|
|
type = "flannel";
|
|
|
|
delegate = {
|
|
|
|
isDefaultGateway = true;
|
|
|
|
bridge = "docker0";
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."mk-docker-opts" = {
|
|
|
|
description = "Pre-Docker Actions";
|
|
|
|
wantedBy = [ "flannel.service" ];
|
|
|
|
before = [ "docker.service" ];
|
|
|
|
after = [ "flannel.service" ];
|
|
|
|
path = [ pkgs.gawk pkgs.gnugrep ];
|
|
|
|
script = ''
|
|
|
|
mkdir -p /run/flannel
|
|
|
|
${mkDockerOpts}/mk-docker-opts -d /run/flannel/docker
|
|
|
|
'';
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
};
|
|
|
|
systemd.services.docker.serviceConfig.EnvironmentFile = "/run/flannel/docker";
|
|
|
|
|
|
|
|
# read environment variables generated by mk-docker-opts
|
|
|
|
virtualisation.docker.extraOptions = "$DOCKER_OPTS";
|
|
|
|
|
|
|
|
networking.firewall.allowedUDPPorts = [
|
|
|
|
8285 # flannel udp
|
|
|
|
8472 # flannel vxlan
|
|
|
|
];
|
|
|
|
})
|
2014-11-23 00:27:04 +00:00
|
|
|
];
|
|
|
|
}
|