Fix bug in etcd config: name was missing.

This commit is contained in:
Jonas Juselius
2017-07-12 10:50:26 +02:00
parent 153cb55b6d
commit 543bf90e84
3 changed files with 24 additions and 21 deletions

View File

@@ -6,8 +6,6 @@
boot.loader.grub.device = "/dev/sda"; boot.loader.grub.device = "/dev/sda";
boot.kernel.sysctl."vm.overcommit_memory"= 1; boot.kernel.sysctl."vm.overcommit_memory"= 1;
services.vmwareGuest.enable = true;
# Select internationalisation properties. # Select internationalisation properties.
i18n = { i18n = {
consoleFont = "Lat2-Terminus16"; consoleFont = "Lat2-Terminus16";
@@ -19,8 +17,10 @@
time.timeZone = "Europe/Oslo"; time.timeZone = "Europe/Oslo";
networking.search = [ "itpartner.intern" "itpartner.no" ]; networking.search = [ "itpartner.intern" "itpartner.no" ];
# Enable the OpenSSH daemon.
services.openssh.enable = true; services.openssh.enable = true;
services.nfs.server.enable = true;
services.vmwareGuest.enable = true;
# The NixOS release to be compatible with for stateful data such as databases. # The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "17.03"; system.stateVersion = "17.03";

View File

@@ -27,6 +27,7 @@ in
file file
bc bc
git git
python
nix-prefetch-git nix-prefetch-git
nix-home nix-home
]; ];

38
k8s.nix
View File

@@ -4,7 +4,7 @@ let
name = "kubernetes"; name = "kubernetes";
csr = csr { csr = csr {
cn = "kubernetes"; cn = "kubernetes";
hosts = ''"kubernetes", "k8s0-0", "10.253.18.100"''; hosts = ''"kubernetes", "k8s0-0", "etcd0", "10.253.18.100"'';
}; };
profile = "server"; profile = "server";
}; };
@@ -13,7 +13,7 @@ let
name = "etcd0"; name = "etcd0";
csr = csr { csr = csr {
cn = "etcd0"; cn = "etcd0";
hosts = ''"etcd0", "10.253.18.100"''; hosts = ''"etcd0", "k8s0-0", "10.253.18.100"'';
}; };
profile = "peer"; profile = "peer";
}; };
@@ -22,7 +22,7 @@ let
name = "etcd1"; name = "etcd1";
csr = csr { csr = csr {
cn = "etcd1"; cn = "etcd1";
hosts = ''"etcd1", "10.253.18.101"''; hosts = ''"etcd1", "k8s0-1", "10.253.18.101"'';
}; };
profile = "peer"; profile = "peer";
}; };
@@ -55,6 +55,7 @@ let
etcdConfig = etcd: { etcdConfig = etcd: {
services.etcd = { services.etcd = {
name = etcd.name;
enable = true; enable = true;
listenClientUrls = ["https://0.0.0.0:2379"]; listenClientUrls = ["https://0.0.0.0:2379"];
listenPeerUrls = ["https://0.0.0.0:2380"]; listenPeerUrls = ["https://0.0.0.0:2380"];
@@ -120,11 +121,12 @@ let
kubelet = { kubelet = {
tlsKeyFile = "${client_key}"; tlsKeyFile = "${client_key}";
tlsCertFile = "${client_cert}"; tlsCertFile = "${client_cert}";
extraOpts = "--client-ca-file=${ca_cert}";
networkPlugin = null; networkPlugin = null;
clusterDns = "kubernetes"; clusterDns = "10.253.18.100";
}; };
}; };
networking.firewall.allowedTCPPorts = [ 53 ];
networking.firewall.allowedUDPPorts = [ 53 ]; # VXLAN
}; };
kubeMaster = { kubeMaster = {
@@ -150,19 +152,27 @@ let
}; };
networking.firewall.allowedTCPPorts = [ 5000 8080 443 53 ]; networking.firewall.allowedTCPPorts = [ 5000 8080 443 53 ];
networking.firewall.allowedUDPPorts = [ 53 ];
systemd.services.flannel.after = [ "etcd.service" ]; systemd.services.flannel.after = [ "etcd.service" ];
}; };
baseConfig = node: { baseConfig = node: {
imports = [ (./hw + "/${node}.nix") ./base/configuration.nix ]; imports = [ (./hw + "/${node}.nix") ./base/configuration.nix ];
require = [ kubeConfig ];
networking.hostName = node; networking.hostName = node;
networking.extraHosts = '' networking.extraHosts = ''
10.253.18.100 etcd0 kubernetes 10.253.18.100 etcd0 kubernetes
10.253.18.101 etcd1 10.253.18.101 etcd1
''; '';
}; };
minion = host: ip: { config, lib, pkgs, ... }:
let
inherit host;
base = baseConfig host;
in
{
deployment.targetHost = ip;
require = [ base kubeConfig kubeNode ];
};
in in
{ {
k8s0-0 = { config, lib, pkgs, ... }: k8s0-0 = { config, lib, pkgs, ... }:
@@ -177,7 +187,7 @@ in
in in
{ {
deployment.targetHost = "10.253.18.100"; deployment.targetHost = "10.253.18.100";
require = [ base etcd kubeMaster kubeNode ]; require = [ base etcd kubeConfig kubeMaster kubeNode ];
}; };
k8s0-1 = { config, lib, pkgs, ... }: k8s0-1 = { config, lib, pkgs, ... }:
@@ -192,16 +202,8 @@ in
in in
{ {
deployment.targetHost = "10.253.18.101"; deployment.targetHost = "10.253.18.101";
require = [ base etcd kubeNode ]; require = [ base etcd kubeConfig kubeNode ];
}; };
k8s0-2 = { config, lib, pkgs, ... }: k8s0-2 = minion "k8s0-2" "10.253.18.102";
let
host = "k8s0-2";
base = baseConfig host;
in
{
deployment.targetHost = "10.253.18.102";
require = [ base kubeNode ];
};
} }