Add fs0 cluster to new deployment infra

This commit is contained in:
Jonas Juselius
2019-02-23 16:11:21 +01:00
parent 20e584d767
commit 7b59038e50
4 changed files with 32 additions and 14 deletions

2
fs0/build.nix Normal file
View File

@@ -0,0 +1,2 @@
with import <nixpkgs> {};
pkgs.callPackage ./certs.nix {}

11
fs0/certs.nix Normal file
View File

@@ -0,0 +1,11 @@
{ pkgs, ...}:
let
pki = pkgs.callPackage ../lib/pki.nix {};
in
{
initca = pki.initca;
ca = pki.ca;
fs0-0 = pki.trust "fs0-0" ''"10.253.18.106", "127.0.0.1"'';
fs0-1 = pki.trust "fs0-1" ''"10.1.2.164", "127.0.0.1"'';
}

View File

@@ -1,20 +1,21 @@
with import <nixpkgs> {};
let
pki = pkgs.callPackage ./lib/pki.nix {};
pki = pkgs.callPackage ../lib/pki.nix {};
certs = pkgs.callPackage ./certs.nix {};
clusterHosts = ''
10.253.18.106 fs0-0 fs0-0.local
10.1.2.164 fs0-1 fs0-1.local
10.253.18.100 fs0-2 fs0-2.local
'';
nixosConfig = node: ip:
nixosConfig = node:
let
cert = pki.trust node ''"${node}", "${ip}", "127.0.0.1"'';
cert = pki.toSet certs.${node};
in
{
imports = [
(./nixos/hardware-configuration + "/${node}.nix")
./nixos/configuration.nix
(../nixos/hardware-configuration + "/${node}.nix")
../nixos/configuration.nix
];
boot.kernelModules = [
"dm_snapshot"
@@ -42,7 +43,7 @@ in
{
fs0-0 = { ... }:
let
base = nixosConfig "fs0-0" "10.253.18.106";
base = nixosConfig "fs0-0";
in
{
deployment.targetHost = "10.253.18.106";
@@ -58,7 +59,7 @@ in
};
fs0-1 = { ... }:
let
base = nixosConfig "fs0-1" "10.1.2.164";
base = nixosConfig "fs0-1";
in
{
deployment.targetHost = "10.1.2.164";

View File

@@ -112,14 +112,18 @@
};
};
trust = name: hosts: gencert rec {
inherit name;
csr = gencsr {
inherit name hosts;
cn = name;
o = name;
trust = name: hosts:
let
hosts' = "\"${name}\", " + hosts;
in gencert rec {
inherit name;
csr = gencsr {
inherit name;
hosts = hosts';
cn = name;
o = name;
};
};
};
kube-proxy = gencert rec {
name = "kube-proxy";