mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-18 07:24:10 +01:00
Merge pull request #102 from ryan4yin/k3s-test-cluter-running-on-kubevirt
feat: add a test k3s cluster running on kubevirt
This commit is contained in:
@@ -23,6 +23,23 @@
|
||||
encode zstd gzip
|
||||
reverse_proxy http://localhost:3000
|
||||
'';
|
||||
|
||||
# https://caddyserver.com/docs/caddyfile/directives/file_server
|
||||
virtualHosts."http://file.writefor.fun".extraConfig = ''
|
||||
root * /var/lib/caddy/fileserver/
|
||||
encode zstd gzip
|
||||
file_server browse {
|
||||
hide .git
|
||||
precompressed zstd br gzip
|
||||
}
|
||||
'';
|
||||
};
|
||||
networking.firewall.allowedTCPPorts = [80 443];
|
||||
|
||||
# Create Directories
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /var/lib/caddy/fileserver/ 0755 caddy caddy"
|
||||
# directory for virual machine's images
|
||||
"d /var/lib/caddy/fileserver/vms 0755 caddy caddy"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
4. [Optional] Add a new integration test file under
|
||||
`outputs/<system-architecture>/integration-tests/<name>.nix` to test whether the new host's
|
||||
nix config can be built and deployed correctly.
|
||||
1. Under `vars/networking.nix`
|
||||
1. Add the new host's static IP address.
|
||||
1. Skip this step if the new host is not in the local network or is a mobile device.
|
||||
|
||||
## idols - Oshi no Ko
|
||||
|
||||
|
||||
28
hosts/k8s/k3s-test-1-master-1/default.nix
Normal file
28
hosts/k8s/k3s-test-1-master-1/default.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
myvars,
|
||||
mylib,
|
||||
...
|
||||
}: let
|
||||
hostName = "k3s-test-1-master-1"; # Define your hostname.
|
||||
|
||||
coreModule = mylib.genKubeVirtCoreModule {
|
||||
inherit pkgs hostName;
|
||||
inherit (myvars) networking;
|
||||
};
|
||||
k3sModule = mylib.genK3sServerModule {
|
||||
inherit pkgs;
|
||||
kubeconfigFile = "/home/${myvars.username}/.kube/config";
|
||||
tokenFile = config.age.secrets."k3s-prod-1-token".path;
|
||||
# the first node in the cluster should be the one to initialize the cluster
|
||||
clusterInit = true;
|
||||
};
|
||||
in {
|
||||
imports =
|
||||
(mylib.scanPaths ./.)
|
||||
++ [
|
||||
coreModule
|
||||
k3sModule
|
||||
];
|
||||
}
|
||||
28
hosts/k8s/k3s-test-1-master-2/default.nix
Normal file
28
hosts/k8s/k3s-test-1-master-2/default.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
myvars,
|
||||
mylib,
|
||||
...
|
||||
}: let
|
||||
hostName = "k3s-test-1-master-2"; # define your hostname.
|
||||
k3sServerName = "k3s-test-1-master-1";
|
||||
|
||||
coreModule = mylib.genKubeVirtCoreModule {
|
||||
inherit pkgs hostName;
|
||||
inherit (myvars) networking;
|
||||
};
|
||||
k3sModule = mylib.genK3sServerModule {
|
||||
inherit pkgs;
|
||||
kubeconfigFile = "/home/${myvars.username}/.kube/config";
|
||||
tokenFile = config.age.secrets."k3s-prod-1-token".path;
|
||||
serverIp = myvars.networking.hostsAddr.${k3sServerName}.ipv4;
|
||||
};
|
||||
in {
|
||||
imports =
|
||||
(mylib.scanPaths ./.)
|
||||
++ [
|
||||
coreModule
|
||||
k3sModule
|
||||
];
|
||||
}
|
||||
28
hosts/k8s/k3s-test-1-master-3/default.nix
Normal file
28
hosts/k8s/k3s-test-1-master-3/default.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
myvars,
|
||||
mylib,
|
||||
...
|
||||
}: let
|
||||
hostName = "k3s-test-1-master-3"; # define your hostname.
|
||||
k3sServerName = "k3s-test-1-master-1";
|
||||
|
||||
coreModule = mylib.genKubeVirtCoreModule {
|
||||
inherit pkgs hostName;
|
||||
inherit (myvars) networking;
|
||||
};
|
||||
k3sModule = mylib.genK3sServerModule {
|
||||
inherit pkgs;
|
||||
kubeconfigFile = "/home/${myvars.username}/.kube/config";
|
||||
tokenFile = config.age.secrets."k3s-prod-1-token".path;
|
||||
serverIp = myvars.networking.hostsAddr.${k3sServerName}.ipv4;
|
||||
};
|
||||
in {
|
||||
imports =
|
||||
(mylib.scanPaths ./.)
|
||||
++ [
|
||||
coreModule
|
||||
k3sModule
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user