2017-05-03 01:20:32 +02:00
|
|
|
{ config, pkgs, certs, servers }:
|
2017-05-26 23:21:17 +02:00
|
|
|
|
2017-05-03 01:20:32 +02:00
|
|
|
let
|
|
|
|
etcd_key = "${certs}/etcd-key.pem";
|
|
|
|
etcd_cert = "${certs}/etcd.pem";
|
|
|
|
ca_pem = "${certs}/ca.pem";
|
|
|
|
etcd_client_cert = "${certs}/etcd-client.crt";
|
|
|
|
etcd_client_key = "${certs}/etcd-client-key.pem";
|
|
|
|
|
|
|
|
worker_key = "${certs}/worker-key.pem";
|
|
|
|
worker_cert = "${certs}/worker.pem";
|
|
|
|
|
|
|
|
rootCaFile = pkgs.writeScript "rootCaFile.pem" ''
|
|
|
|
${pkgs.lib.readFile "${certs}/ca.pem"}
|
|
|
|
|
|
|
|
${pkgs.lib.readFile ("${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt")}
|
|
|
|
'';
|
|
|
|
|
|
|
|
mkHosts =
|
|
|
|
pkgs.lib.concatMapStringsSep "\n" (v: "${v.ip} ${v.name}.nixos.xyz") (pkgs.lib.mapAttrsToList (n: v: {name = n; ip = v;}) servers);
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
programs.bash.enableCompletion = true;
|
|
|
|
environment.systemPackages = with pkgs; [ netcat bind etcd.bin ];
|
|
|
|
|
|
|
|
networking = {
|
2017-05-26 23:21:17 +02:00
|
|
|
firewall.allowedTCPPorts = [
|
|
|
|
10250 # kubelet
|
|
|
|
];
|
2017-05-03 01:20:32 +02:00
|
|
|
extraHosts = ''
|
|
|
|
# register "external" domains
|
|
|
|
${servers.master} etcd.kubernetes.nixos.xyz
|
|
|
|
${servers.master} kubernetes.nixos.xyz
|
|
|
|
${mkHosts}
|
|
|
|
'';
|
|
|
|
};
|
2017-05-26 23:21:17 +02:00
|
|
|
services.flannel.iface = "eth1";
|
2017-05-03 01:20:32 +02:00
|
|
|
environment.variables = {
|
|
|
|
ETCDCTL_CERT_FILE = "${etcd_client_cert}";
|
|
|
|
ETCDCTL_KEY_FILE = "${etcd_client_key}";
|
|
|
|
ETCDCTL_CA_FILE = "${rootCaFile}";
|
|
|
|
ETCDCTL_PEERS = "https://etcd.kubernetes.nixos.xyz:2379";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.kubernetes = {
|
|
|
|
kubelet = {
|
|
|
|
tlsKeyFile = worker_key;
|
|
|
|
tlsCertFile = worker_cert;
|
|
|
|
hostname = "${config.networking.hostName}.nixos.xyz";
|
2017-05-26 23:21:17 +02:00
|
|
|
nodeIp = config.networking.primaryIPAddress;
|
2017-05-03 01:20:32 +02:00
|
|
|
};
|
|
|
|
etcd = {
|
|
|
|
servers = ["https://etcd.kubernetes.nixos.xyz:2379"];
|
|
|
|
keyFile = etcd_client_key;
|
|
|
|
certFile = etcd_client_cert;
|
|
|
|
caFile = ca_pem;
|
|
|
|
};
|
|
|
|
kubeconfig = {
|
2017-05-26 23:21:17 +02:00
|
|
|
server = "https://kubernetes.nixos.xyz";
|
2017-05-03 01:20:32 +02:00
|
|
|
caFile = rootCaFile;
|
|
|
|
certFile = worker_cert;
|
|
|
|
keyFile = worker_key;
|
|
|
|
};
|
2017-05-26 23:21:17 +02:00
|
|
|
flannel.enable = true;
|
2017-05-03 01:20:32 +02:00
|
|
|
|
|
|
|
dns.port = 4453;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.dnsmasq.enable = true;
|
|
|
|
services.dnsmasq.servers = ["/${config.services.kubernetes.dns.domain}/127.0.0.1#4453"];
|
|
|
|
}
|