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
|
||||
inherit (builtins) readFile head;
|
||||
inherit (builtins) readFile;
|
||||
in
|
||||
{
|
||||
_class = "clan.service";
|
||||
|
||||
manifest = {
|
||||
name = "amarth/k3s";
|
||||
description = "amarth/k3s";
|
||||
categories = [ "System" "Network" ];
|
||||
description = "K3s service in order to set up a cluster";
|
||||
categories = [ "System" "Network" "Containers" "Virtualisation" ];
|
||||
readme = readFile ./README.md;
|
||||
};
|
||||
|
||||
|
|
@ -27,8 +27,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
perInstance = { settings, ... }: {
|
||||
nixosModule = ./server.nix;
|
||||
perInstance = instanceArgs: {
|
||||
nixosModule = lib.modules.importApply ./roles/server.nix instanceArgs;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -36,10 +36,12 @@ in
|
|||
# Agent configuration
|
||||
#==============================================================================================================
|
||||
roles.agent = {
|
||||
interface = { lib, ... }: { };
|
||||
interface = { lib, ... }: {
|
||||
options = {};
|
||||
};
|
||||
|
||||
perInstance = { settings, instanceName, roles, ... }: {
|
||||
nixosModule = ./agent.nix;
|
||||
perInstance = instanceArgs: {
|
||||
nixosModule = lib.modules.importApply ./roles/agent.nix instanceArgs;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -5,12 +5,12 @@ let
|
|||
controller = head (lib.attrNames roles.controller.machines or {});
|
||||
|
||||
# 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;
|
||||
|
||||
# Read the controller's token
|
||||
tokenPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s-token/token";
|
||||
token = if pathExists ipAddressPath then readFile ipAddressPath else null;
|
||||
tokenPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s/token";
|
||||
token = if pathExists tokenPath then readFile tokenPath else null;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
|
|
@ -2,30 +2,26 @@
|
|||
{
|
||||
config = {
|
||||
clan.core.vars.generators = {
|
||||
k3s-ip = {
|
||||
k3s = {
|
||||
share = false;
|
||||
files.ip_v6 = {
|
||||
files = {
|
||||
ip_v6 = {
|
||||
deploy = false;
|
||||
secret = false;
|
||||
};
|
||||
files.ip_v4 = {
|
||||
ip_v4 = {
|
||||
deploy = false;
|
||||
secret = false;
|
||||
};
|
||||
script = ''
|
||||
echo "::1" > "$out/ip_v6"
|
||||
echo "127.0.0.1" > "$out/ip_v4"
|
||||
'';
|
||||
};
|
||||
|
||||
k3s-token = {
|
||||
share = false;
|
||||
files.token = {
|
||||
token = {
|
||||
deploy = false;
|
||||
secret = true;
|
||||
};
|
||||
};
|
||||
runtimeInputs = with pkgs; [ pwgen ];
|
||||
script = ''
|
||||
echo "::1" > "$out/ip_v6"
|
||||
echo "127.0.0.1" > "$out/ip_v4"
|
||||
pwgen 50 1 > "$out/token"
|
||||
'';
|
||||
};
|
||||
|
|
@ -47,7 +43,7 @@
|
|||
k3s = {
|
||||
enable = true;
|
||||
role = "server";
|
||||
token = config.clan.core.vars.generators.k3s-token.token.value;
|
||||
token = config.clan.core.vars.generators.k3s.token.value;
|
||||
clusterInit = true;
|
||||
};
|
||||
};
|
||||
|
|
@ -1,44 +1,44 @@
|
|||
{ ... }:
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (builtins) readFile;
|
||||
in
|
||||
{
|
||||
_class = "clan.service";
|
||||
|
||||
manifest.name = "zitadel";
|
||||
manifest = {
|
||||
name = "amarth/zitadel";
|
||||
description = "Zitadel service module";
|
||||
categories = [ "System" "Identity" "IAM" ];
|
||||
readme = readFile ./README.md;
|
||||
};
|
||||
|
||||
roles = {
|
||||
controller = {
|
||||
#==============================================================================================================
|
||||
# Controller configuration
|
||||
#==============================================================================================================
|
||||
roles.controller = {
|
||||
interface = {
|
||||
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!";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
perInstance = instanceArgs: {
|
||||
nixosModule = lib.modules.importApply ./roles/controller.nix instanceArgs;
|
||||
};
|
||||
};
|
||||
|
||||
peer = {};
|
||||
#==============================================================================================================
|
||||
# Peer configuration
|
||||
#==============================================================================================================
|
||||
roles.peer = {
|
||||
interface = {
|
||||
options = {};
|
||||
};
|
||||
|
||||
pweMachine = { instances, machine, ... }: {
|
||||
perInstance = instanceArgs: {
|
||||
nixosModule = lib.modules.importApply ./roles/peer.nix instanceArgs;
|
||||
};
|
||||
};
|
||||
|
||||
perMachine = { instances, machine, ... }: {
|
||||
nixosModule = { config, ... }: {
|
||||
config = {
|
||||
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