WIP: Restructuring to new scheme

This commit is contained in:
Jonas Juselius
2019-10-16 10:32:19 +02:00
parent e4765df729
commit 361dbcea72
30 changed files with 8 additions and 40 deletions

2
clusters/kube0/build.nix Normal file
View File

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

36
clusters/kube0/certs.nix Normal file
View File

@@ -0,0 +1,36 @@
{ pkgs, ...}:
let
pki = pkgs.callPackage ../lib/pki.nix {};
in
{
initca = pki.initca;
ca = pki.ca;
apiserver = pki.apiserver ''
"10.253.18.100",
"10.0.0.1",
"127.0.0.1",
"kubernetes",
"kubernetes.default.svc",
"etcd0",
"fs0-2",
"k0-0"
'';
kube-proxy = pki.kube-proxy;
admin = pki.admin;
etcd = pki.etcd ''
"etcd0",
"etcd1",
"etcd2",
"10.253.18.100",
"10.253.18.101",
"10.253.18.102",
"127.0.0.1"
'';
k0-0 = pki.worker { name = "k0-0"; ip = "10.253.18.100"; };
k0-1 = pki.worker { name = "k0-1"; ip = "10.253.18.101"; };
k0-2 = pki.worker { name = "k0-2"; ip = "10.253.18.102"; };
k0-3 = pki.worker { name = "k0-3"; ip = "10.253.18.103"; };
k0-4 = pki.worker { name = "k0-4"; ip = "10.253.18.107"; };
k0-5 = pki.worker { name = "k0-5"; ip = "10.253.18.108"; };
}

View File

@@ -0,0 +1,89 @@
with import <nixpkgs> {};
let
certs = pkgs.callPackage ./certs.nix {};
pki = pkgs.callPackage ../lib/pki.nix {};
cluster = callPackage ../lib/k8s.nix {
masterAddress = "10.253.18.100";
etcdNodes = [ "etcd0" "etcd1" "etcd2" ];
clusterHosts = ''
10.253.18.100 k0-0 etcd0 kubernetes
10.253.18.101 k0-1 etcd1
10.253.18.102 k0-2 etcd2
10.253.18.103 k0-3
10.253.18.107 k0-4
10.253.18.108 k0-5
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
10.253.18.100 itp-registry
10.253.18.100 nuget.itpartner.no
10.253.18.109 k1-0
'';
certs = {
ca = certs.ca;
apiserver = pki.toSet certs.apiserver;
kube-proxy = pki.toSet certs.kube-proxy;
admin = pki.toSet certs.admin;
etcd = pki.toSet certs.etcd;
k0-0 = pki.toSet certs.k0-0;
k0-1 = pki.toSet certs.k0-1;
k0-2 = pki.toSet certs.k0-2;
k0-3 = pki.toSet certs.k0-3;
k0-4 = pki.toSet certs.k0-4;
k0-5 = pki.toSet certs.k0-5;
};
};
in
{
k0-0 = { ... }:
let
apiserver = pki.toSet certs.apiserver;
in {
require = [ (cluster.apiserver "10.253.18.100" "k0-0" "etcd0") ];
boot.kernelModules = [
"dm_snapshot"
"dm_mirror"
"dm_thin_pool"
];
# services.dnsmasq.enable = true;
fileSystems."/data" = {
device = "fs0-0:gv0";
fsType = "glusterfs";
};
fileSystems."/var/lib/docker-registry" = {
device = "fs0-0:docker-registry";
fsType = "nfs4";
};
services.dockerRegistry = {
enable = true;
listenAddress = "0.0.0.0";
enableDelete = true;
enableGarbageCollect = true;
extraConfig = {
REGISTRY_HTTP_TLS_CERTIFICATE = "${apiserver.cert}";
REGISTRY_HTTP_TLS_KEY = "${apiserver.key}";
};
};
environment.systemPackages = [ pkgs.lvm2 ];
networking.extraHosts = ''
10.253.18.100 itp-registry itp-registry.local
10.253.18.100 helm-registry helm-registry.local
10.253.18.100 nuget.local
10.253.18.100 dashboard.k0.local
10.253.18.100 gitlab.k0.local
10.253.18.100 baywash.k0.local
'';
systemd.services.gitlab-upgrade = {
description = "Upgrade gitlab by zapping pod";
startAt = "Sun 09:00:00";
script = "kubectl delete pods -n gitlab --all";
path = [ pkgs.kubectl ];
};
};
k0-1 = cluster.server "10.253.18.101" "k0-1" "etcd1";
k0-2 = cluster.server "10.253.18.102" "k0-2" "etcd2";
k0-3 = cluster.worker "10.253.18.103" "k0-3";
k0-4 = cluster.worker "10.253.18.107" "k0-4";
k0-5 = cluster.worker "10.253.18.108" "k0-5";
}

25
clusters/kube0/k0-0.nix Normal file
View File

@@ -0,0 +1,25 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "floppy" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/46951acf-de3e-44c3-8d9d-4aa97e691630";
fsType = "ext4";
};
fileSystems."/vol/brick0" =
{ device = "/dev/gfs_vg/brick0";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 1;
}

21
clusters/kube0/k0-1.nix Normal file
View File

@@ -0,0 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "floppy" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/169fb935-f9f5-4689-a15f-7c4ef68553d0";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 1;
}

21
clusters/kube0/k0-2.nix Normal file
View File

@@ -0,0 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "floppy" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/362221fe-f5a8-4abe-be5f-6f9bb4fc1d74";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 1;
}

21
clusters/kube0/k0-3.nix Normal file
View File

@@ -0,0 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "floppy" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/6b3a3c7b-b8dc-4274-a189-21fbe4d8a488";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 1;
}

21
clusters/kube0/k0-4.nix Normal file
View File

@@ -0,0 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "floppy" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/241cdf57-a2b5-482d-a522-01725badc859";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 1;
}

21
clusters/kube0/k0-5.nix Normal file
View File

@@ -0,0 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "floppy" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/67441b95-19f2-484d-b57b-3f4b2a55f3cc";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 1;
}