more setting up
This commit is contained in:
parent
23e1bbe88a
commit
dfd604f73c
7 changed files with 141 additions and 73 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
{ ... }:
|
{ lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) readFile head;
|
inherit (builtins) readFile;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_class = "clan.service";
|
_class = "clan.service";
|
||||||
|
|
||||||
manifest = {
|
manifest = {
|
||||||
name = "amarth/k3s";
|
name = "amarth/k3s";
|
||||||
description = "amarth/k3s";
|
description = "K3s service in order to set up a cluster";
|
||||||
categories = [ "System" "Network" ];
|
categories = [ "System" "Network" "Containers" "Virtualisation" ];
|
||||||
readme = readFile ./README.md;
|
readme = readFile ./README.md;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -27,8 +27,8 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
perInstance = { settings, ... }: {
|
perInstance = instanceArgs: {
|
||||||
nixosModule = ./server.nix;
|
nixosModule = lib.modules.importApply ./roles/server.nix instanceArgs;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -36,10 +36,12 @@ in
|
||||||
# Agent configuration
|
# Agent configuration
|
||||||
#==============================================================================================================
|
#==============================================================================================================
|
||||||
roles.agent = {
|
roles.agent = {
|
||||||
interface = { lib, ... }: { };
|
interface = { lib, ... }: {
|
||||||
|
options = {};
|
||||||
|
};
|
||||||
|
|
||||||
perInstance = { settings, instanceName, roles, ... }: {
|
perInstance = instanceArgs: {
|
||||||
nixosModule = ./agent.nix;
|
nixosModule = lib.modules.importApply ./roles/agent.nix instanceArgs;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
{ config, lib, pkgs, roles, ... }:
|
{ config, lib, pkgs, roles, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) head pathExists readFile;
|
inherit (builtins) head pathExists readFile;
|
||||||
|
|
||||||
controller = head (lib.attrNames roles.controller.machines or {});
|
controller = head (lib.attrNames roles.controller.machines or {});
|
||||||
|
|
||||||
# Read the controller's ip address
|
# Read the controller's ip address
|
||||||
ipAddressPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s-ip/ip_v4";
|
ipAddressPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s/ip_v4";
|
||||||
ipAddress = if pathExists ipAddressPath then readFile ipAddressPath else null;
|
ipAddress = if pathExists ipAddressPath then readFile ipAddressPath else null;
|
||||||
|
|
||||||
# Read the controller's token
|
# Read the controller's token
|
||||||
tokenPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s-token/token";
|
tokenPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s/token";
|
||||||
token = if pathExists ipAddressPath then readFile ipAddressPath else null;
|
token = if pathExists tokenPath then readFile tokenPath else null;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
|
|
@ -35,4 +35,4 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -2,30 +2,26 @@
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
clan.core.vars.generators = {
|
clan.core.vars.generators = {
|
||||||
k3s-ip = {
|
k3s = {
|
||||||
share = false;
|
share = false;
|
||||||
files.ip_v6 = {
|
files = {
|
||||||
deploy = false;
|
ip_v6 = {
|
||||||
secret = false;
|
deploy = false;
|
||||||
};
|
secret = false;
|
||||||
files.ip_v4 = {
|
};
|
||||||
deploy = false;
|
ip_v4 = {
|
||||||
secret = false;
|
deploy = false;
|
||||||
};
|
secret = false;
|
||||||
script = ''
|
};
|
||||||
echo "::1" > "$out/ip_v6"
|
token = {
|
||||||
echo "127.0.0.1" > "$out/ip_v4"
|
deploy = false;
|
||||||
'';
|
secret = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
k3s-token = {
|
|
||||||
share = false;
|
|
||||||
files.token = {
|
|
||||||
deploy = false;
|
|
||||||
secret = true;
|
|
||||||
};
|
};
|
||||||
runtimeInputs = with pkgs; [ pwgen ];
|
runtimeInputs = with pkgs; [ pwgen ];
|
||||||
script = ''
|
script = ''
|
||||||
|
echo "::1" > "$out/ip_v6"
|
||||||
|
echo "127.0.0.1" > "$out/ip_v4"
|
||||||
pwgen 50 1 > "$out/token"
|
pwgen 50 1 > "$out/token"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
@ -47,9 +43,9 @@
|
||||||
k3s = {
|
k3s = {
|
||||||
enable = true;
|
enable = true;
|
||||||
role = "server";
|
role = "server";
|
||||||
token = config.clan.core.vars.generators.k3s-token.token.value;
|
token = config.clan.core.vars.generators.k3s.token.value;
|
||||||
clusterInit = true;
|
clusterInit = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,44 +1,44 @@
|
||||||
{ ... }:
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (builtins) readFile;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
_class = "clan.service";
|
_class = "clan.service";
|
||||||
|
|
||||||
manifest.name = "zitadel";
|
manifest = {
|
||||||
|
name = "amarth/zitadel";
|
||||||
roles = {
|
description = "Zitadel service module";
|
||||||
controller = {
|
categories = [ "System" "Identity" "IAM" ];
|
||||||
interface = {
|
readme = readFile ./README.md;
|
||||||
options = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
perInstance = { instanceName, settings, machine, roles, ... }: {
|
|
||||||
nixosModule = { config }: {
|
|
||||||
config = {
|
|
||||||
services.zitadel.steps.${instanceName} = {
|
|
||||||
InstanceName = settings.hostName;
|
|
||||||
|
|
||||||
Org = {
|
|
||||||
Name = settings.displayName;
|
|
||||||
Human = {
|
|
||||||
UserName = "chris";
|
|
||||||
FirstName = "Chris";
|
|
||||||
LastName = "Kruining";
|
|
||||||
Email = {
|
|
||||||
Address = "chris@kruining.eu";
|
|
||||||
Verified = true;
|
|
||||||
};
|
|
||||||
Password = "KaasIsAwesome1!";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
peer = {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pweMachine = { instances, machine, ... }: {
|
#==============================================================================================================
|
||||||
|
# Controller configuration
|
||||||
|
#==============================================================================================================
|
||||||
|
roles.controller = {
|
||||||
|
interface = {
|
||||||
|
options = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
perInstance = instanceArgs: {
|
||||||
|
nixosModule = lib.modules.importApply ./roles/controller.nix instanceArgs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#==============================================================================================================
|
||||||
|
# Peer configuration
|
||||||
|
#==============================================================================================================
|
||||||
|
roles.peer = {
|
||||||
|
interface = {
|
||||||
|
options = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
perInstance = instanceArgs: {
|
||||||
|
nixosModule = lib.modules.importApply ./roles/peer.nix instanceArgs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
perMachine = { instances, machine, ... }: {
|
||||||
nixosModule = { config, ... }: {
|
nixosModule = { config, ... }: {
|
||||||
config = {
|
config = {
|
||||||
services.zitadel = {
|
services.zitadel = {
|
||||||
|
|
|
||||||
27
clanServices/zitadel/roles/controller.nix
Normal file
27
clanServices/zitadel/roles/controller.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{ instanceName, settings, machine, roles, config, ... }: {
|
||||||
|
config = {
|
||||||
|
clan.core.vars.generators = {
|
||||||
|
zitadel = {
|
||||||
|
share = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
services.zitadel.steps.${instanceName} = {
|
||||||
|
InstanceName = settings.hostName;
|
||||||
|
|
||||||
|
Org = {
|
||||||
|
Name = settings.displayName;
|
||||||
|
Human = {
|
||||||
|
UserName = "chris";
|
||||||
|
FirstName = "Chris";
|
||||||
|
LastName = "Kruining";
|
||||||
|
Email = {
|
||||||
|
Address = "chris@kruining.eu";
|
||||||
|
Verified = true;
|
||||||
|
};
|
||||||
|
Password = "KaasIsAwesome1!";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
3
clanServices/zitadel/roles/peer.nix
Normal file
3
clanServices/zitadel/roles/peer.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{ instanceName, settings, machine, roles, config, ... }: {
|
||||||
|
config = {};
|
||||||
|
}
|
||||||
40
clanServices/zitadel/tests/vm/default.nix
Normal file
40
clanServices/zitadel/tests/vm/default.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
name = "service-k3s";
|
||||||
|
|
||||||
|
clan = {
|
||||||
|
directory = ./.;
|
||||||
|
|
||||||
|
inventory = {
|
||||||
|
machines = {
|
||||||
|
node1 = {};
|
||||||
|
node2 = {};
|
||||||
|
node3 = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
instances = {
|
||||||
|
k3s = {
|
||||||
|
module = {
|
||||||
|
name = "@amarth/k3s";
|
||||||
|
input = "self";
|
||||||
|
};
|
||||||
|
|
||||||
|
roles.server.machines."node1" = {};
|
||||||
|
|
||||||
|
roles.agent.machines."node2" = {};
|
||||||
|
roles.agent.machines."node3" = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nodes = {
|
||||||
|
node1 = {};
|
||||||
|
node2 = {};
|
||||||
|
node3 = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue