Compare commits
1 commit
master
...
nix-snapsh
Author | SHA1 | Date | |
---|---|---|---|
c89209f1df |
110 changed files with 10742 additions and 16459 deletions
1
.envrc
1
.envrc
|
@ -1 +0,0 @@
|
|||
use flake
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,2 @@
|
|||
.direnv
|
||||
.deploy-gc/
|
||||
.pre-commit-config.yaml
|
||||
|
|
|
@ -5,11 +5,9 @@ keys:
|
|||
- &server_jefke age1upnqu4rpxppdw9zmqu8x3rnaqq2r6m82y25zvry5cec63vjsd9gqtl9e02
|
||||
- &server_lewis age108fn93z2c55g9dm9cv5v4w47pykf3khz7e3dmnpv5dhchwnaau0qs20stq
|
||||
- &server_warwick age1th8rdw4fs3vmgy9gzc0k9xy88tddjj4vasepckfx9h4nlzsg3q3q4cjgwu
|
||||
- &server_talos age1h5q9ul9f8vd7w7s2fvmpytaghgpv97a9r237agwzc52c76xsdegsugml73
|
||||
- &server_pikvm age1smqas3tre2hptnyn72fdzghqcnej48066l4hp6y98n8lkpm3ds4s8t8s0w
|
||||
|
||||
creation_rules:
|
||||
- path_regex: secrets/serverKeys.yaml$
|
||||
- path_regex: secrets/(kubernetes|serverKeys).yaml$
|
||||
key_groups:
|
||||
- age:
|
||||
- *admin_pim
|
||||
|
@ -23,5 +21,3 @@ creation_rules:
|
|||
- *server_jefke
|
||||
- *server_lewis
|
||||
- *server_warwick
|
||||
- *server_talos
|
||||
- *server_pikvm
|
||||
|
|
31
README.md
31
README.md
|
@ -1,8 +1,5 @@
|
|||
# nixos-servers
|
||||
|
||||
> [!CAUTION]
|
||||
> This repository has been deprecated in favor of [pim/nixos-configs](https://git.kun.is/pim/nixos-configs).
|
||||
|
||||
Nix definitions to configure our servers at home.
|
||||
|
||||
## Acknowledgements
|
||||
|
@ -12,14 +9,18 @@ Nix definitions to configure our servers at home.
|
|||
- [dns.nix](https://github.com/kirelagin/dns.nix): A Nix DSL for defining DNS zones
|
||||
- [flake-utils](https://github.com/numtide/flake-utils): Handy utilities to develop Nix flakes
|
||||
- [nixos-hardware](https://github.com/NixOS/nixos-hardware): Hardware-specific NixOS modules. Doing the heavy lifting for our Raspberry Pi
|
||||
- [kubenix](https://kubenix.org/): declare and deploy Kubernetes resources using Nix
|
||||
- [nixhelm](https://github.com/farcaller/nixhelm): Nix-digestible Helm charts
|
||||
- [sops-nix](https://github.com/Mic92/sops-nix): Sops secret management for Nix
|
||||
|
||||
## Prerequisites
|
||||
## Installation
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. Install the Nix package manager or NixOS ([link](https://nixos.org/download))
|
||||
2. Enable flake and nix commands ([link](https://nixos.wiki/wiki/Flakes#Enable_flakes_permanently_in_NixOS))
|
||||
|
||||
## Bootstrapping
|
||||
### Bootstrapping
|
||||
|
||||
We bootstrap our servers using [nixos-anywhere](https://github.com/nix-community/nixos-anywhere).
|
||||
This reformats the hard disk of the server and installs a fresh NixOS.
|
||||
|
@ -27,14 +28,24 @@ Additionally, it deploys an age identity, which is later used for decrypting sec
|
|||
|
||||
⚠️ This will wipe your server completely ⚠️
|
||||
|
||||
1. Make sure you can decrypt the Sops-encrypted secrets in `secrets/`. You can test this by running `sops -d secrets/serverKeys.yaml`.
|
||||
1. Make sure your have a [Secret service](https://www.gnu.org/software/emacs/manual/html_node/auth/Secret-Service-API.html) running (such as Keepassxc) that provides the age identity.
|
||||
2. Ensure you have root SSH access to the server.
|
||||
3. Run nixos-anywhere: `nix run '.#bootstrap' <servername> <hostname>`
|
||||
3. Run nixos-anywhere: `nix run .#bootstrap <servername> <hostname>`
|
||||
|
||||
## Deployment
|
||||
### Deployment
|
||||
|
||||
To deploy all servers at once: `nix run 'nixpkgs#deploy-rs' -- '.#' -k`
|
||||
To deploy only one server: `nix run 'nixpkgs#deploy-rs' -- -k --targets '.#<host>'`
|
||||
To deploy all servers at once: `nix run nixpkgs#deploy-rs -- .# -k`
|
||||
To deploy only one server: `nix run nixpkgs#deploy-rs -- -k --targets .#<host>`
|
||||
|
||||
## Deploying to Kubernetes
|
||||
|
||||
To deploy to the Kubernetes cluster, first make sure you have an admin account on the cluster.
|
||||
You can generate this using `nix run .#gen-k3s-cert <username> <servername> ~/.kube`, assuming you have SSH access to the master node.
|
||||
This puts a private key, signed certificate and a kubeconfig in the kubeconfig directory
|
||||
|
||||
If the cluster has not been initialized yet, next run `nix run .#kubenix-bootstrap.x86_64-linux`.
|
||||
|
||||
Lastly, deploy everything to the cluster using `nix run .#kubenix.x86_64-linux`.
|
||||
|
||||
## Known bugs
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[defaults]
|
||||
inventory = inventory
|
||||
remote_tmp = /tmp/ansible
|
||||
ansible_python_interpreter = /usr/bin/python3.12
|
|
@ -1,5 +0,0 @@
|
|||
all:
|
||||
hosts:
|
||||
pikvm:
|
||||
ansible_host: pikvm.dmz
|
||||
ansible_user: root
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
- name: Configure PiKVM server
|
||||
hosts: all
|
||||
|
||||
roles:
|
||||
- pikvm
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
- name: Mount filesystem as read-write
|
||||
ansible.builtin.command: rw
|
||||
vars:
|
||||
root_mount: "{{ ansible_mounts | selectattr('mount', 'equalto', '/') | first }}"
|
||||
when: "'ro' in root_mount.options.split(',')"
|
||||
|
||||
- name: Install Tailscale
|
||||
community.general.pacman:
|
||||
name: tailscale-pikvm
|
||||
state: latest
|
||||
|
||||
- name: Enable Tailscale
|
||||
ansible.builtin.systemd_service:
|
||||
name: tailscaled
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Mount filesystem as read-only
|
||||
ansible.builtin.command: ro
|
|
@ -1,33 +1,22 @@
|
|||
{
|
||||
self,
|
||||
pkgs,
|
||||
lib,
|
||||
inputs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
{ pkgs, self, config, lib, inputs, machine, ... }: {
|
||||
imports = [
|
||||
./storage.nix
|
||||
./backups.nix
|
||||
./networking
|
||||
./data-sharing.nix
|
||||
./monitoring
|
||||
./k3s
|
||||
./tailscale.nix
|
||||
./facter.nix
|
||||
"${self}/nixos-modules"
|
||||
machine.nixosModule
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
inputs.nix-snapshotter.nixosModules.nix-snapshotter
|
||||
];
|
||||
] ++ lib.lists.optional (machine.isRaspberryPi) inputs.nixos-hardware.nixosModules.raspberry-pi-4;
|
||||
|
||||
config = {
|
||||
time.timeZone = "Europe/Amsterdam";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkIf (! machine.isRaspberryPi) config.hardware.enableRedistributableFirmware;
|
||||
|
||||
nixpkgs = {
|
||||
config.allowUnfree = true;
|
||||
overlays = [
|
||||
(final: _prev: {
|
||||
unstable = import inputs.nixpkgs-unstable {
|
||||
system = config.nixpkgs.hostPlatform.system;
|
||||
system = machine.arch;
|
||||
};
|
||||
})
|
||||
];
|
||||
|
@ -36,9 +25,7 @@
|
|||
i18n = {
|
||||
defaultLocale = "en_US.UTF-8";
|
||||
|
||||
extraLocaleSettings = let
|
||||
extraLocale = "nl_NL.UTF-8";
|
||||
in {
|
||||
extraLocaleSettings = let extraLocale = "nl_NL.UTF-8"; in {
|
||||
LC_ADDRESS = extraLocale;
|
||||
LC_IDENTIFICATION = extraLocale;
|
||||
LC_MEASUREMENT = extraLocale;
|
||||
|
@ -59,8 +46,6 @@
|
|||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
GSSAPIAuthentication = false;
|
||||
UseDns = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -103,9 +88,26 @@
|
|||
fastfetch
|
||||
];
|
||||
|
||||
boot = lib.mkIf (! config.facter.lab.isRaspberryPi) {
|
||||
boot = lib.mkIf (! machine.isRaspberryPi) {
|
||||
kernelModules = [ "kvm-intel" ];
|
||||
extraModulePackages = [ ];
|
||||
|
||||
initrd = {
|
||||
kernelModules = [ ];
|
||||
|
||||
availableKernelModules = [
|
||||
"ahci"
|
||||
"xhci_pci"
|
||||
"nvme"
|
||||
"usbhid"
|
||||
"usb_storage"
|
||||
"sd_mod"
|
||||
"sdhci_pci"
|
||||
];
|
||||
};
|
||||
|
||||
loader = {
|
||||
systemd-boot.enable = lib.mkDefault true;
|
||||
systemd-boot.enable = true;
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
};
|
||||
|
@ -116,13 +118,6 @@
|
|||
extraOptions = ''
|
||||
experimental-features = nix-command flakes
|
||||
'';
|
||||
|
||||
gc = {
|
||||
automatic = true;
|
||||
persistent = true;
|
||||
dates = "weekly";
|
||||
options = "--delete-older-than 7d";
|
||||
};
|
||||
};
|
||||
|
||||
system = {
|
||||
|
@ -137,7 +132,7 @@
|
|||
|
||||
sops = {
|
||||
age.keyFile = "/root/.config/sops/age/keys.txt";
|
||||
defaultSopsFile = "${self}/secrets/nixos.yaml";
|
||||
defaultSopsFile = ./secrets/nixos.yaml;
|
||||
};
|
||||
};
|
||||
}
|
2
container-images/image-definitions.nix
Normal file
2
container-images/image-definitions.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
{ cyberchef = { cyberchef = { finalImageName = "mpepping/cyberchef"; finalImageTag = "v10.18.9"; imageDigest = "sha256:4b06936cbeff92cfebf86fdcfbb4bad7807d6a5f99b8affa114bd84f81461fe3"; imageName = "mpepping/cyberchef"; sha256 = "019wr9vrpjg6kq4sqkf9d9xr5w86hn4d93pkk57sliqwyjjn13x8"; }; }; inbucket = { inbucket = { finalImageName = "inbucket/inbucket"; finalImageTag = "edge"; imageDigest = "sha256:e39238af6ac485c406ead9cf411ca7d6bad5dd6e1bca2a02af87273db5f53c8e"; imageName = "inbucket/inbucket"; sha256 = "1z9gywpr3i5048k39dflqlp9k6227b7kdipwk790x711iga2jqpk"; }; }; }
|
||||
|
13
container-images/pulled-images.nix
Normal file
13
container-images/pulled-images.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
pkgs: lib:
|
||||
let
|
||||
imageDefs = import ./image-definitions.nix;
|
||||
in
|
||||
lib.attrsets.mapAttrs
|
||||
(projectName: project:
|
||||
lib.attrsets.mapAttrs
|
||||
(imageName: imageDef:
|
||||
pkgs.dockerTools.pullImage imageDef
|
||||
)
|
||||
project
|
||||
)
|
||||
imageDefs
|
27
deploy.nix
27
deploy.nix
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
self,
|
||||
deploy-rs,
|
||||
...
|
||||
}: let
|
||||
deployArch = "x86_64-linux";
|
||||
mkDeployNodes = nodeDef:
|
||||
builtins.mapAttrs
|
||||
(name: module: nodeDef name module)
|
||||
self.machines;
|
||||
in {
|
||||
deploy = {
|
||||
sshUser = "root";
|
||||
user = "root";
|
||||
|
||||
nodes = mkDeployNodes (name: _module: let
|
||||
nixosConfiguration = self.nixosConfigurations.${name};
|
||||
machineArch = nixosConfiguration.config.facter.report.system;
|
||||
in {
|
||||
hostname = nixosConfiguration.config.networking.fqdn;
|
||||
profiles.system = {
|
||||
remoteBuild = machineArch != deployArch;
|
||||
path = deploy-rs.lib.${machineArch}.activate.nixos nixosConfiguration;
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
64
docs/longhorn.md
Normal file
64
docs/longhorn.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
# Longhorn notes
|
||||
|
||||
## Migration from NFS to Longhorn
|
||||
|
||||
1. Delete the workload, and delete the PVC and PVC using NFS.
|
||||
2. Create Longhorn volumes as described below.
|
||||
3. Copy NFS data from lewis.dmz to local disk.
|
||||
4. Spin up a temporary pod and mount the Longhorn volume(s) in it:
|
||||
```nix
|
||||
{
|
||||
pods.testje.spec = {
|
||||
containers.testje = {
|
||||
image = "nginx";
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "uploads";
|
||||
mountPath = "/hedgedoc/public/uploads";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
uploads.persistentVolumeClaim.claimName = "hedgedoc-uploads";
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
5. Use `kubectl cp` to copy the data from the local disk to the pod.
|
||||
6. Delete the temporary pod.
|
||||
7. Be sure to set the group ownership of the mount to the correct GID.
|
||||
7. Create the workload with updated volume mounts.
|
||||
8. Delete the data from local disk.
|
||||
|
||||
## Creation of new Longhorn volumes
|
||||
|
||||
While it seems handy to use a K8s StorageClass for Longhorn, we do *not* want to use that.
|
||||
If you use a StorageClass, a PV and Longhorn volume will be automatically provisioned.
|
||||
These will have the name `pvc-<UID of PVC>`, where the UID of the PVC is random.
|
||||
This makes it hard to restore a backup to a Longhorn volume with the correct name.
|
||||
|
||||
Instead, we want to manually create the Longhorn volumes via the web UI.
|
||||
Then, we can create the PV and PVC as usual using our K8s provisioning tool (e.g. Kubectl/Kubenix).
|
||||
|
||||
Follow these actions to create a Volume:
|
||||
1. Using the Longhorn web UI, create a new Longhorn volume, keeping the following in mind:
|
||||
- The size can be some more than what we expect to reasonable use. We use storage-overprovisioning, so the total size of volumes can exceed real disk size.
|
||||
- The number of replicas should be 2.
|
||||
2. Enable the "backup-nfs" recurring job for the Longhorn volume.
|
||||
3. Disable the "default" recurring job group for the Longhorn volume.
|
||||
4. Create the PV, PVC and workload as usual.
|
||||
|
||||
## Disaster recovery using Longhorn backups
|
||||
|
||||
Backing up Longhorn volumes is very easy, but restoring them is more tricky.
|
||||
We consider here the case when all our machines are wiped, and all we have left is Longhorn backups.
|
||||
To restore a backup, perform the following actions:
|
||||
1. Restore the latest snapshot in the relevant Longhorn backup, keeping the following in mind:
|
||||
- The name should remain the same (i.e. the one chosen at Longhorn volume creation).
|
||||
- The number of replicas should be 2.
|
||||
- Disable recurring jobs.
|
||||
2. Enable the "backup-nfs" recurring job for the Longhorn volume.
|
||||
3. Disable the "default" recurring job group for the Longhorn volume.
|
||||
4. Create the PV, PVC and workload as usual.
|
14
flake-parts/checks.nix
Normal file
14
flake-parts/checks.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ self, pkgs, machines, flake-utils, deploy-rs, ... }: flake-utils.lib.eachDefaultSystem (system: {
|
||||
# Deploy-rs' flake checks seem broken for architectures different from the deployment machine.
|
||||
# We skip these here.
|
||||
|
||||
checks = deploy-rs.lib.${system}.deployChecks (
|
||||
pkgs.lib.attrsets.updateManyAttrsByPath [{
|
||||
path = [ "nodes" ];
|
||||
update = pkgs.lib.attrsets.filterAttrs (name: node:
|
||||
machines.${name}.arch == system
|
||||
);
|
||||
}]
|
||||
self.deploy
|
||||
);
|
||||
})
|
25
flake-parts/deploy.nix
Normal file
25
flake-parts/deploy.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ self, pkgs, machines, deploy-rs, ... }:
|
||||
let
|
||||
mkDeployNodes = nodeDef:
|
||||
builtins.mapAttrs
|
||||
(name: machine: nodeDef name machine)
|
||||
machines;
|
||||
in
|
||||
{
|
||||
deploy = {
|
||||
sshUser = "root";
|
||||
user = "root";
|
||||
|
||||
nodes = mkDeployNodes (name: machine:
|
||||
let
|
||||
nixosConfiguration = self.nixosConfigurations.${name};
|
||||
in
|
||||
{
|
||||
hostname = nixosConfiguration.config.networking.fqdn;
|
||||
profiles.system = {
|
||||
remoteBuild = machine.arch != pkgs.stdenv.hostPlatform.system;
|
||||
path = deploy-rs.lib.${machine.arch}.activate.nixos nixosConfiguration;
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
15
flake-parts/kubenix.nix
Normal file
15
flake-parts/kubenix.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ self, nixpkgs, machines, dns, myLib, flake-utils, kubenix, nixhelm, blog-pim, ... }: flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
pulledImages = (import "${self}/container-images/pulled-images.nix") pkgs pkgs.lib;
|
||||
mkKubenixPackage = module: kubenix.packages.${system}.default.override
|
||||
{
|
||||
specialArgs = { inherit myLib kubenix nixhelm system dns blog-pim machines pulledImages; };
|
||||
module = { imports = [ module ]; };
|
||||
};
|
||||
in
|
||||
{
|
||||
kubenix = mkKubenixPackage "${self}/kubenix-modules/all.nix";
|
||||
kubenix-bootstrap = mkKubenixPackage "${self}/kubenix-modules/base.nix";
|
||||
})
|
21
flake-parts/nixos.nix
Normal file
21
flake-parts/nixos.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ self, myLib, nixpkgs, machines, ... }@inputs:
|
||||
let
|
||||
mkNixosSystems = systemDef:
|
||||
builtins.mapAttrs
|
||||
(name: machine:
|
||||
nixpkgs.lib.nixosSystem (systemDef name machine)
|
||||
)
|
||||
machines;
|
||||
in
|
||||
{
|
||||
nixosConfigurations = mkNixosSystems (name: machine: {
|
||||
system = machine.arch;
|
||||
|
||||
specialArgs = { inherit self inputs myLib machine machines; };
|
||||
|
||||
modules = [
|
||||
"${self}/configuration.nix"
|
||||
{ networking.hostName = name; }
|
||||
];
|
||||
});
|
||||
}
|
108
flake-parts/scripts/default.nix
Normal file
108
flake-parts/scripts/default.nix
Normal file
|
@ -0,0 +1,108 @@
|
|||
{ flake-utils, pkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
createScript = { name, runtimeInputs, scriptPath, extraWrapperFlags ? "", ... }:
|
||||
let
|
||||
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
|
||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||
});
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
inherit name;
|
||||
paths = [ script ] ++ runtimeInputs;
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin ${extraWrapperFlags}";
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.bootstrap = createScript {
|
||||
name = "bootstrap";
|
||||
runtimeInputs = with pkgs; [ sops coreutils nixos-anywhere ];
|
||||
scriptPath = ./bootstrap.sh;
|
||||
};
|
||||
|
||||
packages.gen-k3s-cert = createScript {
|
||||
name = "create-k3s-cert";
|
||||
runtimeInputs = with pkgs; [ openssl coreutils openssh yq ];
|
||||
scriptPath = ./gen-k3s-cert.sh;
|
||||
};
|
||||
|
||||
packages.prefetch-container-images =
|
||||
let
|
||||
images = {
|
||||
cyberchef = {
|
||||
cyberchef = {
|
||||
image-name = "mpepping/cyberchef";
|
||||
image-tag = "v10.18.9";
|
||||
};
|
||||
};
|
||||
|
||||
inbucket = {
|
||||
inbucket = {
|
||||
image-name = "inbucket/inbucket";
|
||||
image-tag = "edge";
|
||||
};
|
||||
};
|
||||
};
|
||||
imagesJSON = builtins.toFile "images.json" (builtins.toJSON images);
|
||||
in
|
||||
pkgs.writers.writePython3Bin "prefetch-container-images"
|
||||
{ } ''
|
||||
import json
|
||||
import subprocess
|
||||
import tempfile
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
prefetch_docker_cmd = "${pkgs.lib.getExe pkgs.nix-prefetch-docker}" # noqa: E501
|
||||
nix_cmd = "${pkgs.lib.getExe pkgs.nix}" # noqa: E501
|
||||
images_file_name = "${imagesJSON}"
|
||||
|
||||
results = defaultdict(lambda: defaultdict(dict))
|
||||
|
||||
with open(images_file_name, 'r') as file:
|
||||
data = json.load(file)
|
||||
|
||||
for project_name, images in data.items():
|
||||
print(f"Prefetching images for project {project_name}", file=sys.stderr)
|
||||
|
||||
for image_name, image in images.items():
|
||||
name = image["image-name"]
|
||||
tag = image["image-tag"]
|
||||
|
||||
print(f"Prefetching image {name}:{tag}", file=sys.stderr)
|
||||
|
||||
prefetch_args = [
|
||||
prefetch_docker_cmd,
|
||||
"--os", "linux",
|
||||
"--arch", "amd64",
|
||||
"--image-name", name,
|
||||
"--image-tag", tag,
|
||||
"--json",
|
||||
"--quiet"
|
||||
]
|
||||
result = subprocess.run(prefetch_args,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True)
|
||||
|
||||
prefetch_data = json.loads(result.stdout)
|
||||
results[project_name][image_name] = prefetch_data
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode='w+', suffix='.json') as temp_file:
|
||||
json.dump(results, temp_file, indent=4)
|
||||
temp_file.flush()
|
||||
|
||||
to_nix_args = [
|
||||
nix_cmd,
|
||||
"eval",
|
||||
"--impure",
|
||||
"--expr", f'builtins.fromJSON (builtins.readFile {temp_file.name})'
|
||||
]
|
||||
result = subprocess.run(to_nix_args,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True)
|
||||
|
||||
print(result.stdout)
|
||||
'';
|
||||
})
|
88
flake-parts/scripts/gen-k3s-cert.sh
Normal file
88
flake-parts/scripts/gen-k3s-cert.sh
Normal file
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
username="${1-}"
|
||||
host="${2-}"
|
||||
output_path="${3:-.}"
|
||||
|
||||
if [ -z "$username" ] || [ -z "$host" ]
|
||||
then
|
||||
echo "Usage: $0 USERNAME HOST [OUTPUTPATH]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a temporary directory
|
||||
temp=$(mktemp -d)
|
||||
|
||||
# Function to cleanup temporary directory on exit
|
||||
cleanup() {
|
||||
rm -rf "$temp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo Generating the private key
|
||||
openssl genpkey -algorithm ed25519 -out "$temp/key.pem"
|
||||
|
||||
echo Generating the certificate request
|
||||
openssl req -new -key "$temp/key.pem" -out "$temp/req.csr" -subj "/CN=$username"
|
||||
|
||||
echo Creating K8S CSR manifest
|
||||
csr="$(cat "$temp/req.csr" | base64 | tr -d '\n')"
|
||||
k8s_csr="apiVersion: certificates.k8s.io/v1
|
||||
kind: CertificateSigningRequest
|
||||
metadata:
|
||||
name: $username-csr
|
||||
spec:
|
||||
request: $csr
|
||||
expirationSeconds: 307584000 # 10 years
|
||||
signerName: kubernetes.io/kube-apiserver-client
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
"
|
||||
|
||||
echo Creating K8S CSR resource
|
||||
ssh "root@$host" "echo \"$k8s_csr\" | k3s kubectl apply -f -"
|
||||
|
||||
echo Approving K8S CSR
|
||||
ssh "root@$host" "k3s kubectl certificate approve $username-csr"
|
||||
|
||||
echo Retrieving approved certificate
|
||||
encoded_cert="$(ssh root@"$host" "k3s kubectl get csr $username-csr -o jsonpath='{.status.certificate}'")"
|
||||
|
||||
echo Retrieving default K3S kubeconfig
|
||||
base_kubeconfig="$(ssh root@"$host" "cat /etc/rancher/k3s/k3s.yaml")"
|
||||
|
||||
echo Getting certificate authority data from default kubeconfig
|
||||
cert_authority_data="$(echo -n "$base_kubeconfig" | yq -r '.clusters[0].cluster."certificate-authority-data"')"
|
||||
|
||||
echo Generating final kubeconfig
|
||||
result_kubeconfig="apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: $cert_authority_data
|
||||
server: https://$host:6443
|
||||
name: default
|
||||
contexts:
|
||||
- context:
|
||||
cluster: default
|
||||
user: $username
|
||||
name: default
|
||||
current-context: default
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: $username
|
||||
user:
|
||||
client-certificate: $username.crt
|
||||
client-key: $username.key
|
||||
"
|
||||
|
||||
echo Writing resulting files to "$output_path"
|
||||
echo -n "$encoded_cert" | base64 -d > $output_path/$username.crt
|
||||
echo -n "$result_kubeconfig" > $output_path/config
|
||||
cp $temp/key.pem $output_path/$username.key
|
||||
|
387
flake.lock
387
flake.lock
|
@ -1,5 +1,27 @@
|
|||
{
|
||||
"nodes": {
|
||||
"blog-pim": {
|
||||
"inputs": {
|
||||
"flutils": "flutils",
|
||||
"nginx": "nginx",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716491160,
|
||||
"narHash": "sha256-dA6+BRp3ptxdgsysrVE5i+asQA8Yk5TTLnr+8hPNzrg=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "e82fb4539d51da22b6a01e50416ef6ecb548c681",
|
||||
"revCount": 22,
|
||||
"type": "git",
|
||||
"url": "https://git.kun.is/home/blog-pim"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.kun.is/home/blog-pim"
|
||||
}
|
||||
},
|
||||
"deploy-rs": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
|
@ -7,11 +29,11 @@
|
|||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727447169,
|
||||
"narHash": "sha256-3KyjMPUKHkiWhwR91J1YchF6zb6gvckCAY1jOE+ne0U=",
|
||||
"lastModified": 1715699772,
|
||||
"narHash": "sha256-sKhqIgucN5sI/7UQgBwsonzR4fONjfMr9OcHK/vPits=",
|
||||
"owner": "serokell",
|
||||
"repo": "deploy-rs",
|
||||
"rev": "aa07eb05537d4cd025e2310397a6adcedfe72c76",
|
||||
"rev": "b3ea6f333f9057b77efd9091119ba67089399ced",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -27,11 +49,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1729712798,
|
||||
"narHash": "sha256-a+Aakkb+amHw4biOZ0iMo8xYl37uUL48YEXIC5PYJ/8=",
|
||||
"lastModified": 1717770040,
|
||||
"narHash": "sha256-eq9gP060TqWqRf2k4WO5FrG49rVq5Jy3Ptusg0CFdds=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "09a776702b004fdf9c41a024e1299d575ee18a7d",
|
||||
"rev": "398acc470f7c2d68621db01900f053e6000129c4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -48,11 +70,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726867691,
|
||||
"narHash": "sha256-IK3r16N9pizf53AipOmrcrcyjVsPJwC4PI5hIqEyKwQ=",
|
||||
"lastModified": 1715873341,
|
||||
"narHash": "sha256-vOTcr7KXhNDvYPwGotjxcLBrrUq/Nt3sfKRtFwGdHGo=",
|
||||
"owner": "kirelagin",
|
||||
"repo": "dns.nix",
|
||||
"rev": "a3196708a56dee76186a9415c187473b94e6cbae",
|
||||
"rev": "9ebfa9158290de09fafcc759211e48bda48329ee",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -78,22 +100,6 @@
|
|||
}
|
||||
},
|
||||
"flake-compat_2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_3": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
|
@ -109,7 +115,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_4": {
|
||||
"flake-compat_3": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
|
@ -163,14 +169,14 @@
|
|||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726560853,
|
||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -179,57 +185,66 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks": {
|
||||
"flake-utils_3": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs-unstable"
|
||||
],
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
"systems": "systems_5"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730302582,
|
||||
"narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf",
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"id": "flake-utils",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"inputs": {
|
||||
"systems": "systems_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"flutils": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"git-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"kubenix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs-unstable"
|
||||
],
|
||||
"systems": "systems_3",
|
||||
"systems": "systems_4",
|
||||
"treefmt": "treefmt"
|
||||
},
|
||||
"locked": {
|
||||
|
@ -246,20 +261,73 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nginx": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713277799,
|
||||
"narHash": "sha256-VNDzQvUGeh54F3s6SIq6lBrp4RatURzJoJqVorexttA=",
|
||||
"owner": "nginx",
|
||||
"repo": "nginx",
|
||||
"rev": "d8a849ae3c99ee5ca82c9a06074761e937dac6d6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nginx",
|
||||
"repo": "nginx",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-github-actions": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixhelm",
|
||||
"poetry2nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1698974481,
|
||||
"narHash": "sha256-yPncV9Ohdz1zPZxYHQf47S8S0VrnhV7nNhCawY46hDA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"rev": "4bb5e752616262457bc7ca5882192a564c0472d2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-kube-generators": {
|
||||
"locked": {
|
||||
"lastModified": 1702548734,
|
||||
"narHash": "sha256-2pREm/iZ1FyyFuukt/B3nud2NYTUImy5vqc2tESoP9g=",
|
||||
"owner": "farcaller",
|
||||
"repo": "nix-kube-generators",
|
||||
"rev": "fb7a70a8cd76aa76fdf3281123582693aec486a7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "farcaller",
|
||||
"repo": "nix-kube-generators",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-snapshotter": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_4",
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": [
|
||||
"nixpkgs-unstable"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1729627456,
|
||||
"narHash": "sha256-TCZdXCmnqCPsd3PjLv/LDSKJhTspLliL0DE+c/XP9BY=",
|
||||
"lastModified": 1715438114,
|
||||
"narHash": "sha256-btb702TXuhDg0D6tW0dCOy4+II9Wl6BJ0LvpT+O9wrs=",
|
||||
"owner": "pdtpartners",
|
||||
"repo": "nix-snapshotter",
|
||||
"rev": "f2957822a3748c91e678657a1cfd009b0440bbfd",
|
||||
"rev": "7b251c9356bc7bb383ebeedcd0045b3ae431bff7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -268,49 +336,36 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixng": {
|
||||
"nixhelm": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nix-kube-generators": "nix-kube-generators",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
],
|
||||
"poetry2nix": "poetry2nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726571270,
|
||||
"narHash": "sha256-LEug48WOL+mmFYtKM57e/oudgjBk2Km5zIP3p27hF8I=",
|
||||
"owner": "pizzapim",
|
||||
"repo": "NixNG",
|
||||
"rev": "9538892da603608f0176d07d33b1265e038c0adf",
|
||||
"lastModified": 1717722458,
|
||||
"narHash": "sha256-D9DSHU68yifGrrwX9VARYs3BrWk1pmjULMVW0SaXPdQ=",
|
||||
"owner": "farcaller",
|
||||
"repo": "nixhelm",
|
||||
"rev": "a592d7672cfd0ee2c7dda33b8fc8fe75b6442f77",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pizzapim",
|
||||
"ref": "dnsmasq",
|
||||
"repo": "NixNG",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixos-facter-modules": {
|
||||
"locked": {
|
||||
"lastModified": 1730737399,
|
||||
"narHash": "sha256-PzJrTMhHb9f46uMxmRD4GjnyVuNqxeyEvxaq7OierUQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "nixos-facter-modules",
|
||||
"rev": "c22b916f629fee6941a2976c62247b0bec68082b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "nixos-facter-modules",
|
||||
"owner": "farcaller",
|
||||
"repo": "nixhelm",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1729742320,
|
||||
"narHash": "sha256-u3Of8xRkN//me8PU+RucKA59/6RNy4B2jcGAF36P4jI=",
|
||||
"lastModified": 1717574423,
|
||||
"narHash": "sha256-cz3P5MZffAHwL2IQaNzsqUBsJS+u0J/AAwArHMAcCa0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "e8a2f6d5513fe7b7d15701b2d05404ffdc3b6dda",
|
||||
"rev": "d6c6cf6f5fead4057d8fb2d5f30aa8ac1727f177",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -338,43 +393,27 @@
|
|||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1720386169,
|
||||
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
|
||||
"lastModified": 1717880976,
|
||||
"narHash": "sha256-BRvSCsKtDUr83NEtbGfHLUOdDK0Cgbezj2PtcHnz+sQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
|
||||
"rev": "4913a7c3d8b8d00cb9476a6bd730ff57777f740c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-stable_2": {
|
||||
"locked": {
|
||||
"lastModified": 1729357638,
|
||||
"narHash": "sha256-66RHecx+zohbZwJVEPF7uuwHeqf8rykZTMCTqIrOew4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "bb8c2cf7ea0dd2e18a52746b2c3a5b0c73b93c22",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "release-24.05",
|
||||
"ref": "release-23.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1729818716,
|
||||
"narHash": "sha256-XRfkUsxLzFkMn3Tpstio1gNOIQ+2PZPCKbifJ2IXxlw=",
|
||||
"lastModified": 1717646450,
|
||||
"narHash": "sha256-KE+UmfSVk5PG8jdKdclPVcMrUB8yVZHbsjo7ZT1Bm3c=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "062c4f59744fcffa2e5aa3ef443dc8b4d1674ed6",
|
||||
"rev": "818dbe2f96df233d2041739d6079bb616d3e5597",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -386,11 +425,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1729691686,
|
||||
"narHash": "sha256-BAuPWW+9fa1moZTU+jFh+1cUtmsuF8asgzFwejM4wac=",
|
||||
"lastModified": 1717555607,
|
||||
"narHash": "sha256-WZ1s48OODmRJ3DHC+I/DtM3tDRuRJlNqMvxvAPTD7ec=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "32e940c7c420600ef0d1ef396dc63b04ee9cad37",
|
||||
"rev": "0b8e7a1ae5a94da2e1ee3f3030a32020f6254105",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -400,38 +439,45 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"poetry2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nix-github-actions": "nix-github-actions",
|
||||
"nixpkgs": [
|
||||
"nixhelm",
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems_7",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726871744,
|
||||
"narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
|
||||
"lastModified": 1702365004,
|
||||
"narHash": "sha256-IRFvmyP1uk1hchRVxaXTqu6YoZCvMM/NVtUf2hD2Tag=",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"rev": "c12ac880114d52a3cad5fa02b00f2e2090e89982",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"blog-pim": "blog-pim",
|
||||
"deploy-rs": "deploy-rs",
|
||||
"disko": "disko",
|
||||
"dns": "dns",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"git-hooks": "git-hooks",
|
||||
"kubenix": "kubenix",
|
||||
"nix-snapshotter": "nix-snapshotter",
|
||||
"nixng": "nixng",
|
||||
"nixos-facter-modules": "nixos-facter-modules",
|
||||
"nixhelm": "nixhelm",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"sops-nix": "sops-nix",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
"sops-nix": "sops-nix"
|
||||
}
|
||||
},
|
||||
"sops-nix": {
|
||||
|
@ -439,14 +485,14 @@
|
|||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": "nixpkgs-stable_2"
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1729775275,
|
||||
"narHash": "sha256-J2vtHq9sw1wWm0aTMXpEEAzsVCUMZDTEe5kiBYccpLE=",
|
||||
"lastModified": 1718137936,
|
||||
"narHash": "sha256-psA+1Q5fPaK6yI3vzlLINNtb6EeXj111zQWnZYyJS9c=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "78a0e634fc8981d6b564f08b6715c69a755c4c7d",
|
||||
"rev": "c279dec105dd53df13a5e57525da97905cc0f0d6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -486,6 +532,65 @@
|
|||
}
|
||||
},
|
||||
"systems_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_4": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "systems",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"systems_5": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_6": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_7": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
|
@ -522,14 +627,18 @@
|
|||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
"nixpkgs": [
|
||||
"nixhelm",
|
||||
"poetry2nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730025913,
|
||||
"narHash": "sha256-Y9NtFmP8ciLyRsopcCx1tyoaaStKeq+EndwtGCgww7I=",
|
||||
"lastModified": 1699786194,
|
||||
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "bae131e525cc8718da22fbeb8d8c7c43c4ea502a",
|
||||
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -540,7 +649,7 @@
|
|||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
|
|
73
flake.nix
73
flake.nix
|
@ -1,29 +1,12 @@
|
|||
{
|
||||
description = "NixOS definitions for our home servers";
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = [
|
||||
"https://attic.kun.is/nixos-servers"
|
||||
];
|
||||
|
||||
extra-trusted-public-keys = [
|
||||
"nixos-servers:JThtPjQjDu3b3qXLgeXSJGgKL4OKQ4uLgTtoo1rg6Vw="
|
||||
];
|
||||
};
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
|
||||
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
deploy-rs.url = "github:serokell/deploy-rs";
|
||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
|
||||
|
||||
git-hooks = {
|
||||
url = "github:cachix/git-hooks.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
|
@ -35,6 +18,21 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
nixhelm = {
|
||||
url = "github:farcaller/nixhelm";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
blog-pim = {
|
||||
url = "git+https://git.kun.is/home/blog-pim";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
kubenix = {
|
||||
url = "github:pizzapim/kubenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
|
||||
sops-nix = {
|
||||
url = "github:Mic92/sops-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
@ -44,30 +42,23 @@
|
|||
url = "github:pdtpartners/nix-snapshotter";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
|
||||
nixng = {
|
||||
url = "github:pizzapim/NixNG/dnsmasq";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
kubenix = {
|
||||
url = "github:pizzapim/kubenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.meld inputs [
|
||||
./scripts
|
||||
./deploy.nix
|
||||
./nixos.nix
|
||||
./shell.nix
|
||||
./utils
|
||||
./machines
|
||||
./formatter.nix
|
||||
];
|
||||
outputs =
|
||||
inputs@{ self, nixpkgs, flake-utils, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
machines = (pkgs.lib.modules.evalModules { modules = [ (import ./machines) ]; }).config.machines;
|
||||
myLib = import ./my-lib pkgs.lib;
|
||||
in
|
||||
flake-utils.lib.meld (inputs // { inherit pkgs machines myLib; }) [
|
||||
./flake-parts/scripts
|
||||
./flake-parts/checks.nix
|
||||
./flake-parts/deploy.nix
|
||||
./flake-parts/nixos.nix
|
||||
./flake-parts/kubenix.nix
|
||||
] // (flake-utils.lib.eachDefaultSystem (system: {
|
||||
formatter = nixpkgs.legacyPackages.${system}.nixfmt;
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
treefmt-nix,
|
||||
flake-utils,
|
||||
git-hooks,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
|
||||
treefmtWrapper = treefmtEval.config.build.wrapper;
|
||||
in {
|
||||
packages.formatter = treefmtWrapper;
|
||||
formatter = self.packages.${system}.formatter;
|
||||
checks.pre-commit-check = git-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
treefmt = {
|
||||
enable = true;
|
||||
package = treefmtWrapper;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
41
kubenix-modules/all.nix
Normal file
41
kubenix-modules/all.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
let
|
||||
applications = [
|
||||
./freshrss.nix
|
||||
./cyberchef.nix
|
||||
./kms.nix
|
||||
./inbucket.nix
|
||||
./radicale.nix
|
||||
./syncthing.nix
|
||||
./nextcloud.nix
|
||||
./pihole.nix
|
||||
./hedgedoc.nix
|
||||
./paperless.nix
|
||||
./kitchenowl.nix
|
||||
./forgejo
|
||||
./media.nix
|
||||
./bind9
|
||||
./dnsmasq.nix
|
||||
./blog.nix
|
||||
./attic.nix
|
||||
./atuin.nix
|
||||
./immich.nix
|
||||
# ./argo.nix
|
||||
# ./minecraft.nix
|
||||
];
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./base.nix
|
||||
./longhorn.nix
|
||||
./esrom.nix
|
||||
./ek2024.nix
|
||||
./metallb.nix
|
||||
./cert-manager.nix
|
||||
./custom/ingress.nix
|
||||
./custom/nfs-volume.nix
|
||||
./custom/longhorn-volume.nix
|
||||
./traefik.nix
|
||||
./volumes.nix
|
||||
./custom-types.nix
|
||||
] ++ applications;
|
||||
}
|
55
kubenix-modules/argo.nix
Normal file
55
kubenix-modules/argo.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
ingresses.argo-workflows = {
|
||||
metadata.annotations = {
|
||||
"cert-manager.io/cluster-issuer" = "letsencrypt";
|
||||
"traefik.ingress.kubernetes.io/router.entrypoints" = "localsecure";
|
||||
};
|
||||
|
||||
spec = {
|
||||
ingressClassName = "traefik";
|
||||
|
||||
rules = [{
|
||||
host = "workflows.kun.is";
|
||||
|
||||
http.paths = [{
|
||||
path = "/";
|
||||
pathType = "Prefix";
|
||||
|
||||
backend.service = {
|
||||
name = "argo-workflows-server";
|
||||
port.number = 2746;
|
||||
};
|
||||
}];
|
||||
}];
|
||||
|
||||
tls = [{
|
||||
secretName = "argo-workflows-tls";
|
||||
hosts = [ "workflows.kun.is" ];
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
clusterRoles.argo-admin.rules = [{
|
||||
apiGroups = [ "argoproj.io" ];
|
||||
verbs = [ "*" ];
|
||||
resources = [ "*" ];
|
||||
}];
|
||||
|
||||
serviceAccounts.argo-admin = { };
|
||||
|
||||
clusterRoleBindings.argo-admin = {
|
||||
subjects = [{
|
||||
kind = "ServiceAccount";
|
||||
name = "argo-admin";
|
||||
namespace = "default";
|
||||
}];
|
||||
|
||||
roleRef = {
|
||||
kind = "ClusterRole";
|
||||
name = "argo-admin";
|
||||
apiGroup = "rbac.authorization.k8s.io";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
181
kubenix-modules/attic.nix
Normal file
181
kubenix-modules/attic.nix
Normal file
|
@ -0,0 +1,181 @@
|
|||
{ pkgs, ... }: {
|
||||
kubernetes.resources =
|
||||
let
|
||||
atticSettings = {
|
||||
database.url = "ref+sops://secrets/kubernetes.yaml#attic/databaseURL";
|
||||
|
||||
storage = {
|
||||
type = "local";
|
||||
path = "/var/lib/atticd/storage";
|
||||
};
|
||||
|
||||
listen = "[::]:8080";
|
||||
|
||||
# Data chunking
|
||||
#
|
||||
# Warning: If you change any of the values here, it will be
|
||||
# difficult to reuse existing chunks for newly-uploaded NARs
|
||||
# since the cutpoints will be different. As a result, the
|
||||
# deduplication ratio will suffer for a while after the change.
|
||||
chunking = {
|
||||
# The minimum NAR size to trigger chunking
|
||||
#
|
||||
# If 0, chunking is disabled entirely for newly-uploaded NARs.
|
||||
# If 1, all NARs are chunked.
|
||||
nar-size-threshold = 64 * 1024; # 64 KiB
|
||||
|
||||
# The preferred minimum size of a chunk, in bytes
|
||||
min-size = 16 * 1024; # 16 KiB
|
||||
|
||||
# The preferred average size of a chunk, in bytes
|
||||
avg-size = 64 * 1024; # 64 KiB
|
||||
|
||||
# The preferred maximum size of a chunk, in bytes
|
||||
max-size = 256 * 1024; # 256 KiB
|
||||
};
|
||||
};
|
||||
generatedConfig = (pkgs.formats.toml { }).generate "attic.toml" atticSettings;
|
||||
in
|
||||
{
|
||||
configMaps = {
|
||||
attic-env.data.ATTIC_SERVER_TOKEN_HS256_SECRET_BASE64 = "ref+sops://secrets/kubernetes.yaml#attic/jwtToken";
|
||||
attic-config.data.config = builtins.readFile generatedConfig;
|
||||
|
||||
attic-db-env.data = {
|
||||
POSTGRES_DB = "attic";
|
||||
POSTGRES_USER = "attic";
|
||||
POSTGRES_PASSWORD = "ref+sops://secrets/kubernetes.yaml#/attic/databasePassword";
|
||||
PGDATA = "/pgdata/data";
|
||||
};
|
||||
};
|
||||
|
||||
deployments = {
|
||||
attic = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.attic = {
|
||||
image = "git.kun.is/home/atticd:fd910d91c2143295e959d2c903e9ea25cf94ba27";
|
||||
envFrom = [{ configMapRef.name = "attic-env"; }];
|
||||
ports.web.containerPort = 8080;
|
||||
args = [ "-f" "/etc/atticd/config.toml" ];
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "data";
|
||||
mountPath = "/var/lib/atticd/storage";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/atticd/config.toml";
|
||||
subPath = "config";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "attic";
|
||||
config.configMap.name = "attic-config";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 0;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
attic-db = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.postgres = {
|
||||
image = "postgres:15";
|
||||
imagePullPolicy = "IfNotPresent";
|
||||
ports.postgres.containerPort = 5432;
|
||||
envFrom = [{ configMapRef.name = "attic-db-env"; }];
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/pgdata";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes.data.persistentVolumeClaim.claimName = "attic-db";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
attic.spec = {
|
||||
selector = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
attic-db.spec = {
|
||||
selector = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
ports.postgres = {
|
||||
port = 5432;
|
||||
targetPort = "postgres";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.attic = {
|
||||
host = "attic.kun.is";
|
||||
# entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "attic";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
99
kubenix-modules/atuin.nix
Normal file
99
kubenix-modules/atuin.nix
Normal file
|
@ -0,0 +1,99 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
secrets.atuin.stringData = {
|
||||
databasePassword = "ref+sops://secrets/kubernetes.yaml#/atuin/databasePassword";
|
||||
databaseURL = "ref+sops://secrets/kubernetes.yaml#/atuin/databaseURL";
|
||||
};
|
||||
|
||||
deployments.atuin = {
|
||||
metadata.labels.app = "atuin";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "atuin";
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "atuin";
|
||||
|
||||
spec = {
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "atuin";
|
||||
db.persistentVolumeClaim.claimName = "atuin-db";
|
||||
};
|
||||
|
||||
containers = {
|
||||
atuin = {
|
||||
image = "ghcr.io/atuinsh/atuin:18.3.0";
|
||||
imagePullPolicy = "Always";
|
||||
ports.web.containerPort = 8888;
|
||||
args = [ "server" "start" ];
|
||||
|
||||
env = {
|
||||
ATUIN_HOST.value = "0.0.0.0";
|
||||
ATUIN_PORT.value = "8888";
|
||||
ATUIN_OPEN_REGISTRATION.value = "false";
|
||||
|
||||
ATUIN_DB_URI.valueFrom.secretKeyRef = {
|
||||
name = "atuin";
|
||||
key = "databaseURL";
|
||||
};
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/config";
|
||||
}];
|
||||
};
|
||||
|
||||
database = {
|
||||
image = "postgres:14";
|
||||
ports.web.containerPort = 5432;
|
||||
|
||||
env = {
|
||||
POSTGRES_DB.value = "atuin";
|
||||
POSTGRES_USER.value = "atuin";
|
||||
|
||||
POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
|
||||
name = "atuin";
|
||||
key = "databasePassword";
|
||||
};
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "db";
|
||||
mountPath = "/var/lib/postgresql/data";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.atuin.spec = {
|
||||
selector.app = "atuin";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.atuin = {
|
||||
host = "atuin.kun.is";
|
||||
|
||||
service = {
|
||||
name = "atuin";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
73
kubenix-modules/base.nix
Normal file
73
kubenix-modules/base.nix
Normal file
|
@ -0,0 +1,73 @@
|
|||
# We deploy several resources that rely on "custom resource definitions".
|
||||
# We must first import these resources definitions, before deploying resources that depend on them.
|
||||
{ lib, kubenix, nixhelm, system, machines, ... }: {
|
||||
imports = [
|
||||
kubenix.modules.k8s
|
||||
kubenix.modules.helm
|
||||
];
|
||||
|
||||
config = {
|
||||
kubenix.project = "home";
|
||||
|
||||
kubernetes = {
|
||||
kubeconfig = "~/.kube/config";
|
||||
|
||||
# TODO: These were copied from https://github.com/cert-manager/cert-manager/releases/download/v1.14.4/cert-manager.crds.yaml
|
||||
# See https://cert-manager.io/docs/installation/helm/
|
||||
# Seems kubenix cannot import a list of resources, but only individual resources.
|
||||
# Might be good to create a PR for this.
|
||||
imports = [
|
||||
./cert-manager-manifests/certificaterequest.yaml
|
||||
./cert-manager-manifests/certificate.yaml
|
||||
./cert-manager-manifests/challenge.yaml
|
||||
./cert-manager-manifests/clusterissuer.yaml
|
||||
./cert-manager-manifests/issuer.yaml
|
||||
./cert-manager-manifests/order.yaml
|
||||
];
|
||||
|
||||
helm.releases = {
|
||||
metallb = {
|
||||
chart = nixhelm.chartsDerivations.${system}.metallb.metallb;
|
||||
includeCRDs = true;
|
||||
};
|
||||
|
||||
cert-manager = {
|
||||
chart = nixhelm.chartsDerivations.${system}.jetstack.cert-manager;
|
||||
includeCRDs = false;
|
||||
};
|
||||
|
||||
argo-workflows = {
|
||||
chart = nixhelm.chartsDerivations.${system}.argoproj.argo-workflows;
|
||||
includeCRDs = true;
|
||||
};
|
||||
|
||||
longhorn = {
|
||||
chart = nixhelm.chartsDerivations.${system}.longhorn.longhorn;
|
||||
includeCRDs = true;
|
||||
values = {
|
||||
defaultSettings = {
|
||||
defaultDataPath = "/mnt/longhorn";
|
||||
storageMinimalAvailablePercentage = 0;
|
||||
allowRecurringJobWhileVolumeDetached = true;
|
||||
backupTarget = "nfs://lewis.dmz:/mnt/longhorn/persistent/longhorn-backup";
|
||||
};
|
||||
|
||||
persistence = {
|
||||
defaultClassReplicaCount = 2;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
resources.nodes =
|
||||
let
|
||||
machinesWithKubernetesLabels = lib.filterAttrs (name: machine: machine.kubernetesNodeLabels != null) machines;
|
||||
in
|
||||
builtins.mapAttrs
|
||||
(name: machine: {
|
||||
metadata.labels = machine.kubernetesNodeLabels;
|
||||
})
|
||||
machinesWithKubernetesLabels;
|
||||
};
|
||||
};
|
||||
}
|
153
kubenix-modules/bind9/default.nix
Normal file
153
kubenix-modules/bind9/default.nix
Normal file
|
@ -0,0 +1,153 @@
|
|||
{ myLib, dns, ... }:
|
||||
let
|
||||
kunisZone = dns.lib.toString "kun.is" (import ./kun.is.zone.nix myLib dns);
|
||||
in
|
||||
{
|
||||
kubernetes.resources = {
|
||||
configMaps = {
|
||||
bind9-env.data.TZ = "Europe/Amsterdam";
|
||||
|
||||
bind9-config.data = {
|
||||
# TODO: this was copied from nix's generated bind config
|
||||
# Is there a way to generate this without actually running the nixos module?
|
||||
config = ''
|
||||
acl cachenetworks { 127.0.0.0/24; };
|
||||
acl badnetworks { };
|
||||
|
||||
options {
|
||||
listen-on { any; };
|
||||
listen-on-v6 { any; };
|
||||
allow-query { cachenetworks; };
|
||||
blackhole { badnetworks; };
|
||||
forward first;
|
||||
forwarders { };
|
||||
directory "/run/named";
|
||||
pid-file "/run/named/named.pid";
|
||||
allow-transfer { none; };
|
||||
allow-recursion { none; };
|
||||
version none;
|
||||
notify no;
|
||||
};
|
||||
|
||||
zone "kun.is" {
|
||||
type master;
|
||||
file "/etc/bind/kun.is.zone";
|
||||
allow-transfer { };
|
||||
allow-query { any; };
|
||||
};
|
||||
'';
|
||||
|
||||
kunis-zone = kunisZone;
|
||||
};
|
||||
};
|
||||
|
||||
deployments.bind9 = {
|
||||
metadata.labels.app = "bind9";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "bind9";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "bind9";
|
||||
|
||||
spec = {
|
||||
containers = {
|
||||
bind9-udp = {
|
||||
image = "ubuntu/bind9:9.18-22.04_beta";
|
||||
envFrom = [{ configMapRef.name = "bind9-env"; }];
|
||||
|
||||
ports.dns-udp = {
|
||||
containerPort = 53;
|
||||
protocol = "UDP";
|
||||
};
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/bind/named.conf";
|
||||
subPath = "config";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/bind/kun.is.zone";
|
||||
subPath = "kunis-zone";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
bind9-tcp = {
|
||||
image = "ubuntu/bind9:9.18-22.04_beta";
|
||||
envFrom = [{ configMapRef.name = "bind9-env"; }];
|
||||
|
||||
ports.dns-tcp = {
|
||||
containerPort = 53;
|
||||
protocol = "TCP";
|
||||
};
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/bind/named.conf";
|
||||
subPath = "config";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/bind/kun.is.zone";
|
||||
subPath = "kunis-zone";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
volumes = [{
|
||||
name = "config";
|
||||
configMap.name = "bind9-config";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
bind9-udp = {
|
||||
metadata.annotations = {
|
||||
"metallb.universe.tf/loadBalancerIPs" = "${myLib.globals.bind9IPv4},${myLib.globals.bind9Ipv6}";
|
||||
"metallb.universe.tf/allow-shared-ip" = "dns";
|
||||
};
|
||||
|
||||
spec = {
|
||||
type = "LoadBalancer";
|
||||
selector.app = "bind9";
|
||||
ipFamilies = [ "IPv4" "IPv6" ];
|
||||
ipFamilyPolicy = "RequireDualStack";
|
||||
|
||||
ports.dns = {
|
||||
port = 53;
|
||||
targetPort = "dns-udp";
|
||||
protocol = "UDP";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
bind9-tcp = {
|
||||
metadata.annotations = {
|
||||
"metallb.universe.tf/loadBalancerIPs" = "${myLib.globals.bind9IPv4},${myLib.globals.bind9Ipv6}";
|
||||
"metallb.universe.tf/allow-shared-ip" = "dns";
|
||||
};
|
||||
|
||||
spec = {
|
||||
type = "LoadBalancer";
|
||||
selector.app = "bind9";
|
||||
ipFamilies = [ "IPv4" "IPv6" ];
|
||||
ipFamilyPolicy = "RequireDualStack";
|
||||
|
||||
ports.dns = {
|
||||
port = 53;
|
||||
targetPort = "dns-tcp";
|
||||
protocol = "TCP";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
52
kubenix-modules/bind9/kun.is.zone.nix
Normal file
52
kubenix-modules/bind9/kun.is.zone.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
myLib: dns: with dns.lib.combinators; {
|
||||
CAA = letsEncrypt "caa@kun.is";
|
||||
|
||||
SOA = {
|
||||
nameServer = "ns1";
|
||||
adminEmail = "webmaster.kun.is";
|
||||
serial = 2024041301;
|
||||
};
|
||||
|
||||
NS = [
|
||||
"ns1.kun.is."
|
||||
"ns2.kun.is."
|
||||
];
|
||||
|
||||
MX = [
|
||||
(mx.mx 10 "mail.kun.is.")
|
||||
];
|
||||
|
||||
TXT = [
|
||||
(with spf; soft [ "include:spf.glasnet.nl" ])
|
||||
];
|
||||
|
||||
subdomains = rec {
|
||||
"*".A = [ myLib.globals.routerPublicIPv4 ];
|
||||
|
||||
ns = {
|
||||
A = [ myLib.globals.routerPublicIPv4 ];
|
||||
AAAA = [ ];
|
||||
};
|
||||
|
||||
ns1 = ns;
|
||||
ns2 = ns;
|
||||
|
||||
wg = {
|
||||
A = [ myLib.globals.routerPublicIPv4 ];
|
||||
AAAA = [ ];
|
||||
};
|
||||
|
||||
#for SMTP2GO to be able send emails from kun.is domain
|
||||
em670271 = {
|
||||
CNAME = [ "return.smtp2go.net." ];
|
||||
};
|
||||
|
||||
"s670271._domainkey" = {
|
||||
CNAME = [ "dkim.smtp2go.net." ];
|
||||
};
|
||||
|
||||
link = {
|
||||
CNAME = [ "track.smtp2go.net." ];
|
||||
};
|
||||
};
|
||||
}
|
40
kubenix-modules/blog.nix
Normal file
40
kubenix-modules/blog.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{ blog-pim, ... }: {
|
||||
kubernetes.resources = {
|
||||
deployments.blog = {
|
||||
metadata.labels.app = "blog";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "blog";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "blog";
|
||||
|
||||
spec = {
|
||||
containers.blog = {
|
||||
image = "git.kun.is/home/blog-pim:${blog-pim.rev}";
|
||||
ports.web.containerPort = 80;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.blog.spec = {
|
||||
selector.app = "blog";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.blog = {
|
||||
host = "pim.kun.is";
|
||||
|
||||
service = {
|
||||
name = "blog";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
443
kubenix-modules/cert-manager-manifests/certificate.yaml
Normal file
443
kubenix-modules/cert-manager-manifests/certificate.yaml
Normal file
|
@ -0,0 +1,443 @@
|
|||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: certificates.cert-manager.io
|
||||
labels:
|
||||
app: 'cert-manager'
|
||||
app.kubernetes.io/name: 'cert-manager'
|
||||
app.kubernetes.io/instance: 'cert-manager'
|
||||
# Generated labels
|
||||
app.kubernetes.io/version: "v1.14.4"
|
||||
spec:
|
||||
group: cert-manager.io
|
||||
names:
|
||||
kind: Certificate
|
||||
listKind: CertificateList
|
||||
plural: certificates
|
||||
shortNames:
|
||||
- cert
|
||||
- certs
|
||||
singular: certificate
|
||||
categories:
|
||||
- cert-manager
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
subresources:
|
||||
status: {}
|
||||
additionalPrinterColumns:
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].status
|
||||
name: Ready
|
||||
type: string
|
||||
- jsonPath: .spec.secretName
|
||||
name: Secret
|
||||
type: string
|
||||
- jsonPath: .spec.issuerRef.name
|
||||
name: Issuer
|
||||
priority: 1
|
||||
type: string
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].message
|
||||
name: Status
|
||||
priority: 1
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
description: CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.
|
||||
name: Age
|
||||
type: date
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: "A Certificate resource should be created to ensure an up to date and signed X.509 certificate is stored in the Kubernetes Secret resource named in `spec.secretName`. \n The stored certificate will be renewed before it expires (as configured by `spec.renewBefore`)."
|
||||
type: object
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: Specification of the desired state of the Certificate resource. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
|
||||
type: object
|
||||
required:
|
||||
- issuerRef
|
||||
- secretName
|
||||
properties:
|
||||
additionalOutputFormats:
|
||||
description: "Defines extra output formats of the private key and signed certificate chain to be written to this Certificate's target Secret. \n This is an Alpha Feature and is only enabled with the `--feature-gates=AdditionalCertificateOutputFormats=true` option set on both the controller and webhook components."
|
||||
type: array
|
||||
items:
|
||||
description: CertificateAdditionalOutputFormat defines an additional output format of a Certificate resource. These contain supplementary data formats of the signed certificate chain and paired private key.
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
properties:
|
||||
type:
|
||||
description: Type is the name of the format type that should be written to the Certificate's target Secret.
|
||||
type: string
|
||||
enum:
|
||||
- DER
|
||||
- CombinedPEM
|
||||
commonName:
|
||||
description: "Requested common name X509 certificate subject attribute. More info: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6 NOTE: TLS clients will ignore this value when any subject alternative name is set (see https://tools.ietf.org/html/rfc6125#section-6.4.4). \n Should have a length of 64 characters or fewer to avoid generating invalid CSRs. Cannot be set if the `literalSubject` field is set."
|
||||
type: string
|
||||
dnsNames:
|
||||
description: Requested DNS subject alternative names.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
duration:
|
||||
description: "Requested 'duration' (i.e. lifetime) of the Certificate. Note that the issuer may choose to ignore the requested duration, just like any other requested attribute. \n If unset, this defaults to 90 days. Minimum accepted duration is 1 hour. Value must be in units accepted by Go time.ParseDuration https://golang.org/pkg/time/#ParseDuration."
|
||||
type: string
|
||||
emailAddresses:
|
||||
description: Requested email subject alternative names.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
encodeUsagesInRequest:
|
||||
description: "Whether the KeyUsage and ExtKeyUsage extensions should be set in the encoded CSR. \n This option defaults to true, and should only be disabled if the target issuer does not support CSRs with these X509 KeyUsage/ ExtKeyUsage extensions."
|
||||
type: boolean
|
||||
ipAddresses:
|
||||
description: Requested IP address subject alternative names.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
isCA:
|
||||
description: "Requested basic constraints isCA value. The isCA value is used to set the `isCA` field on the created CertificateRequest resources. Note that the issuer may choose to ignore the requested isCA value, just like any other requested attribute. \n If true, this will automatically add the `cert sign` usage to the list of requested `usages`."
|
||||
type: boolean
|
||||
issuerRef:
|
||||
description: "Reference to the issuer responsible for issuing the certificate. If the issuer is namespace-scoped, it must be in the same namespace as the Certificate. If the issuer is cluster-scoped, it can be used from any namespace. \n The `name` field of the reference must always be specified."
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
group:
|
||||
description: Group of the resource being referred to.
|
||||
type: string
|
||||
kind:
|
||||
description: Kind of the resource being referred to.
|
||||
type: string
|
||||
name:
|
||||
description: Name of the resource being referred to.
|
||||
type: string
|
||||
keystores:
|
||||
description: Additional keystore output formats to be stored in the Certificate's Secret.
|
||||
type: object
|
||||
properties:
|
||||
jks:
|
||||
description: JKS configures options for storing a JKS keystore in the `spec.secretName` Secret resource.
|
||||
type: object
|
||||
required:
|
||||
- create
|
||||
- passwordSecretRef
|
||||
properties:
|
||||
create:
|
||||
description: Create enables JKS keystore creation for the Certificate. If true, a file named `keystore.jks` will be created in the target Secret resource, encrypted using the password stored in `passwordSecretRef`. The keystore file will be updated immediately. If the issuer provided a CA certificate, a file named `truststore.jks` will also be created in the target Secret resource, encrypted using the password stored in `passwordSecretRef` containing the issuing Certificate Authority
|
||||
type: boolean
|
||||
passwordSecretRef:
|
||||
description: PasswordSecretRef is a reference to a key in a Secret resource containing the password used to encrypt the JKS keystore.
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
key:
|
||||
description: The key of the entry in the Secret resource's `data` field to be used. Some instances of this field may be defaulted, in others it may be required.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the resource being referred to. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
|
||||
type: string
|
||||
pkcs12:
|
||||
description: PKCS12 configures options for storing a PKCS12 keystore in the `spec.secretName` Secret resource.
|
||||
type: object
|
||||
required:
|
||||
- create
|
||||
- passwordSecretRef
|
||||
properties:
|
||||
create:
|
||||
description: Create enables PKCS12 keystore creation for the Certificate. If true, a file named `keystore.p12` will be created in the target Secret resource, encrypted using the password stored in `passwordSecretRef`. The keystore file will be updated immediately. If the issuer provided a CA certificate, a file named `truststore.p12` will also be created in the target Secret resource, encrypted using the password stored in `passwordSecretRef` containing the issuing Certificate Authority
|
||||
type: boolean
|
||||
passwordSecretRef:
|
||||
description: PasswordSecretRef is a reference to a key in a Secret resource containing the password used to encrypt the PKCS12 keystore.
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
key:
|
||||
description: The key of the entry in the Secret resource's `data` field to be used. Some instances of this field may be defaulted, in others it may be required.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the resource being referred to. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
|
||||
type: string
|
||||
profile:
|
||||
description: "Profile specifies the key and certificate encryption algorithms and the HMAC algorithm used to create the PKCS12 keystore. Default value is `LegacyRC2` for backward compatibility. \n If provided, allowed values are: `LegacyRC2`: Deprecated. Not supported by default in OpenSSL 3 or Java 20. `LegacyDES`: Less secure algorithm. Use this option for maximal compatibility. `Modern2023`: Secure algorithm. Use this option in case you have to always use secure algorithms (eg. because of company policy). Please note that the security of the algorithm is not that important in reality, because the unencrypted certificate and private key are also stored in the Secret."
|
||||
type: string
|
||||
enum:
|
||||
- LegacyRC2
|
||||
- LegacyDES
|
||||
- Modern2023
|
||||
literalSubject:
|
||||
description: "Requested X.509 certificate subject, represented using the LDAP \"String Representation of a Distinguished Name\" [1]. Important: the LDAP string format also specifies the order of the attributes in the subject, this is important when issuing certs for LDAP authentication. Example: `CN=foo,DC=corp,DC=example,DC=com` More info [1]: https://datatracker.ietf.org/doc/html/rfc4514 More info: https://github.com/cert-manager/cert-manager/issues/3203 More info: https://github.com/cert-manager/cert-manager/issues/4424 \n Cannot be set if the `subject` or `commonName` field is set. This is an Alpha Feature and is only enabled with the `--feature-gates=LiteralCertificateSubject=true` option set on both the controller and webhook components."
|
||||
type: string
|
||||
nameConstraints:
|
||||
description: "x.509 certificate NameConstraint extension which MUST NOT be used in a non-CA certificate. More Info: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.10 \n This is an Alpha Feature and is only enabled with the `--feature-gates=NameConstraints=true` option set on both the controller and webhook components."
|
||||
type: object
|
||||
properties:
|
||||
critical:
|
||||
description: if true then the name constraints are marked critical.
|
||||
type: boolean
|
||||
excluded:
|
||||
description: Excluded contains the constraints which must be disallowed. Any name matching a restriction in the excluded field is invalid regardless of information appearing in the permitted
|
||||
type: object
|
||||
properties:
|
||||
dnsDomains:
|
||||
description: DNSDomains is a list of DNS domains that are permitted or excluded.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
emailAddresses:
|
||||
description: EmailAddresses is a list of Email Addresses that are permitted or excluded.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
ipRanges:
|
||||
description: IPRanges is a list of IP Ranges that are permitted or excluded. This should be a valid CIDR notation.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
uriDomains:
|
||||
description: URIDomains is a list of URI domains that are permitted or excluded.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
permitted:
|
||||
description: Permitted contains the constraints in which the names must be located.
|
||||
type: object
|
||||
properties:
|
||||
dnsDomains:
|
||||
description: DNSDomains is a list of DNS domains that are permitted or excluded.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
emailAddresses:
|
||||
description: EmailAddresses is a list of Email Addresses that are permitted or excluded.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
ipRanges:
|
||||
description: IPRanges is a list of IP Ranges that are permitted or excluded. This should be a valid CIDR notation.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
uriDomains:
|
||||
description: URIDomains is a list of URI domains that are permitted or excluded.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
otherNames:
|
||||
description: '`otherNames` is an escape hatch for SAN that allows any type. We currently restrict the support to string like otherNames, cf RFC 5280 p 37 Any UTF8 String valued otherName can be passed with by setting the keys oid: x.x.x.x and UTF8Value: somevalue for `otherName`. Most commonly this would be UPN set with oid: 1.3.6.1.4.1.311.20.2.3 You should ensure that any OID passed is valid for the UTF8String type as we do not explicitly validate this.'
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
oid:
|
||||
description: OID is the object identifier for the otherName SAN. The object identifier must be expressed as a dotted string, for example, "1.2.840.113556.1.4.221".
|
||||
type: string
|
||||
utf8Value:
|
||||
description: utf8Value is the string value of the otherName SAN. The utf8Value accepts any valid UTF8 string to set as value for the otherName SAN.
|
||||
type: string
|
||||
privateKey:
|
||||
description: Private key options. These include the key algorithm and size, the used encoding and the rotation policy.
|
||||
type: object
|
||||
properties:
|
||||
algorithm:
|
||||
description: "Algorithm is the private key algorithm of the corresponding private key for this certificate. \n If provided, allowed values are either `RSA`, `ECDSA` or `Ed25519`. If `algorithm` is specified and `size` is not provided, key size of 2048 will be used for `RSA` key algorithm and key size of 256 will be used for `ECDSA` key algorithm. key size is ignored when using the `Ed25519` key algorithm."
|
||||
type: string
|
||||
enum:
|
||||
- RSA
|
||||
- ECDSA
|
||||
- Ed25519
|
||||
encoding:
|
||||
description: "The private key cryptography standards (PKCS) encoding for this certificate's private key to be encoded in. \n If provided, allowed values are `PKCS1` and `PKCS8` standing for PKCS#1 and PKCS#8, respectively. Defaults to `PKCS1` if not specified."
|
||||
type: string
|
||||
enum:
|
||||
- PKCS1
|
||||
- PKCS8
|
||||
rotationPolicy:
|
||||
description: "RotationPolicy controls how private keys should be regenerated when a re-issuance is being processed. \n If set to `Never`, a private key will only be generated if one does not already exist in the target `spec.secretName`. If one does exists but it does not have the correct algorithm or size, a warning will be raised to await user intervention. If set to `Always`, a private key matching the specified requirements will be generated whenever a re-issuance occurs. Default is `Never` for backward compatibility."
|
||||
type: string
|
||||
enum:
|
||||
- Never
|
||||
- Always
|
||||
size:
|
||||
description: "Size is the key bit size of the corresponding private key for this certificate. \n If `algorithm` is set to `RSA`, valid values are `2048`, `4096` or `8192`, and will default to `2048` if not specified. If `algorithm` is set to `ECDSA`, valid values are `256`, `384` or `521`, and will default to `256` if not specified. If `algorithm` is set to `Ed25519`, Size is ignored. No other values are allowed."
|
||||
type: integer
|
||||
renewBefore:
|
||||
description: "How long before the currently issued certificate's expiry cert-manager should renew the certificate. For example, if a certificate is valid for 60 minutes, and `renewBefore=10m`, cert-manager will begin to attempt to renew the certificate 50 minutes after it was issued (i.e. when there are 10 minutes remaining until the certificate is no longer valid). \n NOTE: The actual lifetime of the issued certificate is used to determine the renewal time. If an issuer returns a certificate with a different lifetime than the one requested, cert-manager will use the lifetime of the issued certificate. \n If unset, this defaults to 1/3 of the issued certificate's lifetime. Minimum accepted value is 5 minutes. Value must be in units accepted by Go time.ParseDuration https://golang.org/pkg/time/#ParseDuration."
|
||||
type: string
|
||||
revisionHistoryLimit:
|
||||
description: "The maximum number of CertificateRequest revisions that are maintained in the Certificate's history. Each revision represents a single `CertificateRequest` created by this Certificate, either when it was created, renewed, or Spec was changed. Revisions will be removed by oldest first if the number of revisions exceeds this number. \n If set, revisionHistoryLimit must be a value of `1` or greater. If unset (`nil`), revisions will not be garbage collected. Default value is `nil`."
|
||||
type: integer
|
||||
format: int32
|
||||
secretName:
|
||||
description: Name of the Secret resource that will be automatically created and managed by this Certificate resource. It will be populated with a private key and certificate, signed by the denoted issuer. The Secret resource lives in the same namespace as the Certificate resource.
|
||||
type: string
|
||||
secretTemplate:
|
||||
description: Defines annotations and labels to be copied to the Certificate's Secret. Labels and annotations on the Secret will be changed as they appear on the SecretTemplate when added or removed. SecretTemplate annotations are added in conjunction with, and cannot overwrite, the base set of annotations cert-manager sets on the Certificate's Secret.
|
||||
type: object
|
||||
properties:
|
||||
annotations:
|
||||
description: Annotations is a key value map to be copied to the target Kubernetes Secret.
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
labels:
|
||||
description: Labels is a key value map to be copied to the target Kubernetes Secret.
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
subject:
|
||||
description: "Requested set of X509 certificate subject attributes. More info: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6 \n The common name attribute is specified separately in the `commonName` field. Cannot be set if the `literalSubject` field is set."
|
||||
type: object
|
||||
properties:
|
||||
countries:
|
||||
description: Countries to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
localities:
|
||||
description: Cities to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
organizationalUnits:
|
||||
description: Organizational Units to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
organizations:
|
||||
description: Organizations to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
postalCodes:
|
||||
description: Postal codes to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
provinces:
|
||||
description: State/Provinces to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
serialNumber:
|
||||
description: Serial number to be used on the Certificate.
|
||||
type: string
|
||||
streetAddresses:
|
||||
description: Street addresses to be used on the Certificate.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
uris:
|
||||
description: Requested URI subject alternative names.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
usages:
|
||||
description: "Requested key usages and extended key usages. These usages are used to set the `usages` field on the created CertificateRequest resources. If `encodeUsagesInRequest` is unset or set to `true`, the usages will additionally be encoded in the `request` field which contains the CSR blob. \n If unset, defaults to `digital signature` and `key encipherment`."
|
||||
type: array
|
||||
items:
|
||||
description: "KeyUsage specifies valid usage contexts for keys. See: https://tools.ietf.org/html/rfc5280#section-4.2.1.3 https://tools.ietf.org/html/rfc5280#section-4.2.1.12 \n Valid KeyUsage values are as follows: \"signing\", \"digital signature\", \"content commitment\", \"key encipherment\", \"key agreement\", \"data encipherment\", \"cert sign\", \"crl sign\", \"encipher only\", \"decipher only\", \"any\", \"server auth\", \"client auth\", \"code signing\", \"email protection\", \"s/mime\", \"ipsec end system\", \"ipsec tunnel\", \"ipsec user\", \"timestamping\", \"ocsp signing\", \"microsoft sgc\", \"netscape sgc\""
|
||||
type: string
|
||||
enum:
|
||||
- signing
|
||||
- digital signature
|
||||
- content commitment
|
||||
- key encipherment
|
||||
- key agreement
|
||||
- data encipherment
|
||||
- cert sign
|
||||
- crl sign
|
||||
- encipher only
|
||||
- decipher only
|
||||
- any
|
||||
- server auth
|
||||
- client auth
|
||||
- code signing
|
||||
- email protection
|
||||
- s/mime
|
||||
- ipsec end system
|
||||
- ipsec tunnel
|
||||
- ipsec user
|
||||
- timestamping
|
||||
- ocsp signing
|
||||
- microsoft sgc
|
||||
- netscape sgc
|
||||
status:
|
||||
description: 'Status of the Certificate. This is set and managed automatically. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status'
|
||||
type: object
|
||||
properties:
|
||||
conditions:
|
||||
description: List of status conditions to indicate the status of certificates. Known condition types are `Ready` and `Issuing`.
|
||||
type: array
|
||||
items:
|
||||
description: CertificateCondition contains condition information for an Certificate.
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
- type
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: LastTransitionTime is the timestamp corresponding to the last status change of this condition.
|
||||
type: string
|
||||
format: date-time
|
||||
message:
|
||||
description: Message is a human readable description of the details of the last transition, complementing reason.
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: If set, this represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date with respect to the current state of the Certificate.
|
||||
type: integer
|
||||
format: int64
|
||||
reason:
|
||||
description: Reason is a brief machine readable explanation for the condition's last transition.
|
||||
type: string
|
||||
status:
|
||||
description: Status of the condition, one of (`True`, `False`, `Unknown`).
|
||||
type: string
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type:
|
||||
description: Type of the condition, known values are (`Ready`, `Issuing`).
|
||||
type: string
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
failedIssuanceAttempts:
|
||||
description: The number of continuous failed issuance attempts up till now. This field gets removed (if set) on a successful issuance and gets set to 1 if unset and an issuance has failed. If an issuance has failed, the delay till the next issuance will be calculated using formula time.Hour * 2 ^ (failedIssuanceAttempts - 1).
|
||||
type: integer
|
||||
lastFailureTime:
|
||||
description: LastFailureTime is set only if the lastest issuance for this Certificate failed and contains the time of the failure. If an issuance has failed, the delay till the next issuance will be calculated using formula time.Hour * 2 ^ (failedIssuanceAttempts - 1). If the latest issuance has succeeded this field will be unset.
|
||||
type: string
|
||||
format: date-time
|
||||
nextPrivateKeySecretName:
|
||||
description: The name of the Secret resource containing the private key to be used for the next certificate iteration. The keymanager controller will automatically set this field if the `Issuing` condition is set to `True`. It will automatically unset this field when the Issuing condition is not set or False.
|
||||
type: string
|
||||
notAfter:
|
||||
description: The expiration time of the certificate stored in the secret named by this resource in `spec.secretName`.
|
||||
type: string
|
||||
format: date-time
|
||||
notBefore:
|
||||
description: The time after which the certificate stored in the secret named by this resource in `spec.secretName` is valid.
|
||||
type: string
|
||||
format: date-time
|
||||
renewalTime:
|
||||
description: RenewalTime is the time at which the certificate will be next renewed. If not set, no upcoming renewal is scheduled.
|
||||
type: string
|
||||
format: date-time
|
||||
revision:
|
||||
description: "The current 'revision' of the certificate as issued. \n When a CertificateRequest resource is created, it will have the `cert-manager.io/certificate-revision` set to one greater than the current value of this field. \n Upon issuance, this field will be set to the value of the annotation on the CertificateRequest resource used to issue the certificate. \n Persisting the value on the CertificateRequest resource allows the certificates controller to know whether a request is part of an old issuance or if it is part of the ongoing revision's issuance by checking if the revision value in the annotation is greater than this field."
|
||||
type: integer
|
||||
served: true
|
||||
storage: true
|
196
kubenix-modules/cert-manager-manifests/certificaterequest.yaml
Normal file
196
kubenix-modules/cert-manager-manifests/certificaterequest.yaml
Normal file
|
@ -0,0 +1,196 @@
|
|||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: certificaterequests.cert-manager.io
|
||||
labels:
|
||||
app: 'cert-manager'
|
||||
app.kubernetes.io/name: 'cert-manager'
|
||||
app.kubernetes.io/instance: 'cert-manager'
|
||||
# Generated labels
|
||||
app.kubernetes.io/version: "v1.14.4"
|
||||
spec:
|
||||
group: cert-manager.io
|
||||
names:
|
||||
kind: CertificateRequest
|
||||
listKind: CertificateRequestList
|
||||
plural: certificaterequests
|
||||
shortNames:
|
||||
- cr
|
||||
- crs
|
||||
singular: certificaterequest
|
||||
categories:
|
||||
- cert-manager
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
subresources:
|
||||
status: {}
|
||||
additionalPrinterColumns:
|
||||
- jsonPath: .status.conditions[?(@.type=="Approved")].status
|
||||
name: Approved
|
||||
type: string
|
||||
- jsonPath: .status.conditions[?(@.type=="Denied")].status
|
||||
name: Denied
|
||||
type: string
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].status
|
||||
name: Ready
|
||||
type: string
|
||||
- jsonPath: .spec.issuerRef.name
|
||||
name: Issuer
|
||||
type: string
|
||||
- jsonPath: .spec.username
|
||||
name: Requestor
|
||||
type: string
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].message
|
||||
name: Status
|
||||
priority: 1
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
description: CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.
|
||||
name: Age
|
||||
type: date
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: "A CertificateRequest is used to request a signed certificate from one of the configured issuers. \n All fields within the CertificateRequest's `spec` are immutable after creation. A CertificateRequest will either succeed or fail, as denoted by its `Ready` status condition and its `status.failureTime` field. \n A CertificateRequest is a one-shot resource, meaning it represents a single point in time request for a certificate and cannot be re-used."
|
||||
type: object
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: Specification of the desired state of the CertificateRequest resource. https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
|
||||
type: object
|
||||
required:
|
||||
- issuerRef
|
||||
- request
|
||||
properties:
|
||||
duration:
|
||||
description: Requested 'duration' (i.e. lifetime) of the Certificate. Note that the issuer may choose to ignore the requested duration, just like any other requested attribute.
|
||||
type: string
|
||||
extra:
|
||||
description: Extra contains extra attributes of the user that created the CertificateRequest. Populated by the cert-manager webhook on creation and immutable.
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
groups:
|
||||
description: Groups contains group membership of the user that created the CertificateRequest. Populated by the cert-manager webhook on creation and immutable.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
x-kubernetes-list-type: atomic
|
||||
isCA:
|
||||
description: "Requested basic constraints isCA value. Note that the issuer may choose to ignore the requested isCA value, just like any other requested attribute. \n NOTE: If the CSR in the `Request` field has a BasicConstraints extension, it must have the same isCA value as specified here. \n If true, this will automatically add the `cert sign` usage to the list of requested `usages`."
|
||||
type: boolean
|
||||
issuerRef:
|
||||
description: "Reference to the issuer responsible for issuing the certificate. If the issuer is namespace-scoped, it must be in the same namespace as the Certificate. If the issuer is cluster-scoped, it can be used from any namespace. \n The `name` field of the reference must always be specified."
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
group:
|
||||
description: Group of the resource being referred to.
|
||||
type: string
|
||||
kind:
|
||||
description: Kind of the resource being referred to.
|
||||
type: string
|
||||
name:
|
||||
description: Name of the resource being referred to.
|
||||
type: string
|
||||
request:
|
||||
description: "The PEM-encoded X.509 certificate signing request to be submitted to the issuer for signing. \n If the CSR has a BasicConstraints extension, its isCA attribute must match the `isCA` value of this CertificateRequest. If the CSR has a KeyUsage extension, its key usages must match the key usages in the `usages` field of this CertificateRequest. If the CSR has a ExtKeyUsage extension, its extended key usages must match the extended key usages in the `usages` field of this CertificateRequest."
|
||||
type: string
|
||||
format: byte
|
||||
uid:
|
||||
description: UID contains the uid of the user that created the CertificateRequest. Populated by the cert-manager webhook on creation and immutable.
|
||||
type: string
|
||||
usages:
|
||||
description: "Requested key usages and extended key usages. \n NOTE: If the CSR in the `Request` field has uses the KeyUsage or ExtKeyUsage extension, these extensions must have the same values as specified here without any additional values. \n If unset, defaults to `digital signature` and `key encipherment`."
|
||||
type: array
|
||||
items:
|
||||
description: "KeyUsage specifies valid usage contexts for keys. See: https://tools.ietf.org/html/rfc5280#section-4.2.1.3 https://tools.ietf.org/html/rfc5280#section-4.2.1.12 \n Valid KeyUsage values are as follows: \"signing\", \"digital signature\", \"content commitment\", \"key encipherment\", \"key agreement\", \"data encipherment\", \"cert sign\", \"crl sign\", \"encipher only\", \"decipher only\", \"any\", \"server auth\", \"client auth\", \"code signing\", \"email protection\", \"s/mime\", \"ipsec end system\", \"ipsec tunnel\", \"ipsec user\", \"timestamping\", \"ocsp signing\", \"microsoft sgc\", \"netscape sgc\""
|
||||
type: string
|
||||
enum:
|
||||
- signing
|
||||
- digital signature
|
||||
- content commitment
|
||||
- key encipherment
|
||||
- key agreement
|
||||
- data encipherment
|
||||
- cert sign
|
||||
- crl sign
|
||||
- encipher only
|
||||
- decipher only
|
||||
- any
|
||||
- server auth
|
||||
- client auth
|
||||
- code signing
|
||||
- email protection
|
||||
- s/mime
|
||||
- ipsec end system
|
||||
- ipsec tunnel
|
||||
- ipsec user
|
||||
- timestamping
|
||||
- ocsp signing
|
||||
- microsoft sgc
|
||||
- netscape sgc
|
||||
username:
|
||||
description: Username contains the name of the user that created the CertificateRequest. Populated by the cert-manager webhook on creation and immutable.
|
||||
type: string
|
||||
status:
|
||||
description: 'Status of the CertificateRequest. This is set and managed automatically. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status'
|
||||
type: object
|
||||
properties:
|
||||
ca:
|
||||
description: The PEM encoded X.509 certificate of the signer, also known as the CA (Certificate Authority). This is set on a best-effort basis by different issuers. If not set, the CA is assumed to be unknown/not available.
|
||||
type: string
|
||||
format: byte
|
||||
certificate:
|
||||
description: The PEM encoded X.509 certificate resulting from the certificate signing request. If not set, the CertificateRequest has either not been completed or has failed. More information on failure can be found by checking the `conditions` field.
|
||||
type: string
|
||||
format: byte
|
||||
conditions:
|
||||
description: List of status conditions to indicate the status of a CertificateRequest. Known condition types are `Ready`, `InvalidRequest`, `Approved` and `Denied`.
|
||||
type: array
|
||||
items:
|
||||
description: CertificateRequestCondition contains condition information for a CertificateRequest.
|
||||
type: object
|
||||
required:
|
||||
- status
|
||||
- type
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: LastTransitionTime is the timestamp corresponding to the last status change of this condition.
|
||||
type: string
|
||||
format: date-time
|
||||
message:
|
||||
description: Message is a human readable description of the details of the last transition, complementing reason.
|
||||
type: string
|
||||
reason:
|
||||
description: Reason is a brief machine readable explanation for the condition's last transition.
|
||||
type: string
|
||||
status:
|
||||
description: Status of the condition, one of (`True`, `False`, `Unknown`).
|
||||
type: string
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type:
|
||||
description: Type of the condition, known values are (`Ready`, `InvalidRequest`, `Approved`, `Denied`).
|
||||
type: string
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
failureTime:
|
||||
description: FailureTime stores the time that this CertificateRequest failed. This is used to influence garbage collection and back-off.
|
||||
type: string
|
||||
format: date-time
|
||||
served: true
|
||||
storage: true
|
1124
kubenix-modules/cert-manager-manifests/challenge.yaml
Normal file
1124
kubenix-modules/cert-manager-manifests/challenge.yaml
Normal file
File diff suppressed because it is too large
Load diff
1371
kubenix-modules/cert-manager-manifests/clusterissuer.yaml
Normal file
1371
kubenix-modules/cert-manager-manifests/clusterissuer.yaml
Normal file
File diff suppressed because it is too large
Load diff
1371
kubenix-modules/cert-manager-manifests/issuer.yaml
Normal file
1371
kubenix-modules/cert-manager-manifests/issuer.yaml
Normal file
File diff suppressed because it is too large
Load diff
180
kubenix-modules/cert-manager-manifests/order.yaml
Normal file
180
kubenix-modules/cert-manager-manifests/order.yaml
Normal file
|
@ -0,0 +1,180 @@
|
|||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: orders.acme.cert-manager.io
|
||||
labels:
|
||||
app: 'cert-manager'
|
||||
app.kubernetes.io/name: 'cert-manager'
|
||||
app.kubernetes.io/instance: 'cert-manager'
|
||||
# Generated labels
|
||||
app.kubernetes.io/version: "v1.14.4"
|
||||
spec:
|
||||
group: acme.cert-manager.io
|
||||
names:
|
||||
kind: Order
|
||||
listKind: OrderList
|
||||
plural: orders
|
||||
singular: order
|
||||
categories:
|
||||
- cert-manager
|
||||
- cert-manager-acme
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
subresources:
|
||||
status: {}
|
||||
additionalPrinterColumns:
|
||||
- jsonPath: .status.state
|
||||
name: State
|
||||
type: string
|
||||
- jsonPath: .spec.issuerRef.name
|
||||
name: Issuer
|
||||
priority: 1
|
||||
type: string
|
||||
- jsonPath: .status.reason
|
||||
name: Reason
|
||||
priority: 1
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
description: CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.
|
||||
name: Age
|
||||
type: date
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: Order is a type to represent an Order with an ACME server
|
||||
type: object
|
||||
required:
|
||||
- metadata
|
||||
- spec
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
type: object
|
||||
required:
|
||||
- issuerRef
|
||||
- request
|
||||
properties:
|
||||
commonName:
|
||||
description: CommonName is the common name as specified on the DER encoded CSR. If specified, this value must also be present in `dnsNames` or `ipAddresses`. This field must match the corresponding field on the DER encoded CSR.
|
||||
type: string
|
||||
dnsNames:
|
||||
description: DNSNames is a list of DNS names that should be included as part of the Order validation process. This field must match the corresponding field on the DER encoded CSR.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
duration:
|
||||
description: Duration is the duration for the not after date for the requested certificate. this is set on order creation as pe the ACME spec.
|
||||
type: string
|
||||
ipAddresses:
|
||||
description: IPAddresses is a list of IP addresses that should be included as part of the Order validation process. This field must match the corresponding field on the DER encoded CSR.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
issuerRef:
|
||||
description: IssuerRef references a properly configured ACME-type Issuer which should be used to create this Order. If the Issuer does not exist, processing will be retried. If the Issuer is not an 'ACME' Issuer, an error will be returned and the Order will be marked as failed.
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
group:
|
||||
description: Group of the resource being referred to.
|
||||
type: string
|
||||
kind:
|
||||
description: Kind of the resource being referred to.
|
||||
type: string
|
||||
name:
|
||||
description: Name of the resource being referred to.
|
||||
type: string
|
||||
request:
|
||||
description: Certificate signing request bytes in DER encoding. This will be used when finalizing the order. This field must be set on the order.
|
||||
type: string
|
||||
format: byte
|
||||
status:
|
||||
type: object
|
||||
properties:
|
||||
authorizations:
|
||||
description: Authorizations contains data returned from the ACME server on what authorizations must be completed in order to validate the DNS names specified on the Order.
|
||||
type: array
|
||||
items:
|
||||
description: ACMEAuthorization contains data returned from the ACME server on an authorization that must be completed in order validate a DNS name on an ACME Order resource.
|
||||
type: object
|
||||
required:
|
||||
- url
|
||||
properties:
|
||||
challenges:
|
||||
description: Challenges specifies the challenge types offered by the ACME server. One of these challenge types will be selected when validating the DNS name and an appropriate Challenge resource will be created to perform the ACME challenge process.
|
||||
type: array
|
||||
items:
|
||||
description: Challenge specifies a challenge offered by the ACME server for an Order. An appropriate Challenge resource can be created to perform the ACME challenge process.
|
||||
type: object
|
||||
required:
|
||||
- token
|
||||
- type
|
||||
- url
|
||||
properties:
|
||||
token:
|
||||
description: Token is the token that must be presented for this challenge. This is used to compute the 'key' that must also be presented.
|
||||
type: string
|
||||
type:
|
||||
description: Type is the type of challenge being offered, e.g. 'http-01', 'dns-01', 'tls-sni-01', etc. This is the raw value retrieved from the ACME server. Only 'http-01' and 'dns-01' are supported by cert-manager, other values will be ignored.
|
||||
type: string
|
||||
url:
|
||||
description: URL is the URL of this challenge. It can be used to retrieve additional metadata about the Challenge from the ACME server.
|
||||
type: string
|
||||
identifier:
|
||||
description: Identifier is the DNS name to be validated as part of this authorization
|
||||
type: string
|
||||
initialState:
|
||||
description: InitialState is the initial state of the ACME authorization when first fetched from the ACME server. If an Authorization is already 'valid', the Order controller will not create a Challenge resource for the authorization. This will occur when working with an ACME server that enables 'authz reuse' (such as Let's Encrypt's production endpoint). If not set and 'identifier' is set, the state is assumed to be pending and a Challenge will be created.
|
||||
type: string
|
||||
enum:
|
||||
- valid
|
||||
- ready
|
||||
- pending
|
||||
- processing
|
||||
- invalid
|
||||
- expired
|
||||
- errored
|
||||
url:
|
||||
description: URL is the URL of the Authorization that must be completed
|
||||
type: string
|
||||
wildcard:
|
||||
description: Wildcard will be true if this authorization is for a wildcard DNS name. If this is true, the identifier will be the *non-wildcard* version of the DNS name. For example, if '*.example.com' is the DNS name being validated, this field will be 'true' and the 'identifier' field will be 'example.com'.
|
||||
type: boolean
|
||||
certificate:
|
||||
description: Certificate is a copy of the PEM encoded certificate for this Order. This field will be populated after the order has been successfully finalized with the ACME server, and the order has transitioned to the 'valid' state.
|
||||
type: string
|
||||
format: byte
|
||||
failureTime:
|
||||
description: FailureTime stores the time that this order failed. This is used to influence garbage collection and back-off.
|
||||
type: string
|
||||
format: date-time
|
||||
finalizeURL:
|
||||
description: FinalizeURL of the Order. This is used to obtain certificates for this order once it has been completed.
|
||||
type: string
|
||||
reason:
|
||||
description: Reason optionally provides more information about a why the order is in the current state.
|
||||
type: string
|
||||
state:
|
||||
description: State contains the current state of this Order resource. States 'success' and 'expired' are 'final'
|
||||
type: string
|
||||
enum:
|
||||
- valid
|
||||
- ready
|
||||
- pending
|
||||
- processing
|
||||
- invalid
|
||||
- expired
|
||||
- errored
|
||||
url:
|
||||
description: URL of the Order. This will initially be empty when the resource is first created. The Order controller will populate this field when the Order is first processed. This field will be immutable after it is initially set.
|
||||
type: string
|
||||
served: true
|
||||
storage: true
|
15
kubenix-modules/cert-manager.nix
Normal file
15
kubenix-modules/cert-manager.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
kubernetes.resources.clusterIssuers.letsencrypt = {
|
||||
metadata.namespace = "kube-system";
|
||||
|
||||
spec.acme = {
|
||||
server = "https://acme-v02.api.letsencrypt.org/directory";
|
||||
email = "pim@kunis.nl";
|
||||
privateKeySecretRef.name = "letsencrypt-private-key";
|
||||
solvers = [{
|
||||
selector = { };
|
||||
http01.ingress.class = "traefik";
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
42
kubenix-modules/custom-types.nix
Normal file
42
kubenix-modules/custom-types.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
kubernetes.customTypes = {
|
||||
# HACK: These are dummy custom types.
|
||||
# This is needed, because the CRDs imported as a chart are not available as Nix modules.
|
||||
# There is no nix-based validation on resources defined using these types!
|
||||
# See: https://github.com/hall/kubenix/issues/34
|
||||
ipAddressPool = {
|
||||
attrName = "ipAddressPools";
|
||||
group = "metallb.io";
|
||||
version = "v1beta1";
|
||||
kind = "IPAddressPool";
|
||||
};
|
||||
|
||||
l2Advertisement = {
|
||||
attrName = "l2Advertisements";
|
||||
group = "metallb.io";
|
||||
version = "v1beta1";
|
||||
kind = "L2Advertisement";
|
||||
};
|
||||
|
||||
helmChartConfig = {
|
||||
attrName = "helmChartConfigs";
|
||||
group = "helm.cattle.io";
|
||||
version = "v1";
|
||||
kind = "HelmChartConfig";
|
||||
};
|
||||
|
||||
clusterIssuer = {
|
||||
attrName = "clusterIssuers";
|
||||
group = "cert-manager.io";
|
||||
version = "v1";
|
||||
kind = "ClusterIssuer";
|
||||
};
|
||||
|
||||
recurringJob = {
|
||||
attrName = "recurringJobs";
|
||||
group = "longhorn.io";
|
||||
version = "v1beta1";
|
||||
kind = "RecurringJob";
|
||||
};
|
||||
};
|
||||
}
|
67
kubenix-modules/custom/ingress.nix
Normal file
67
kubenix-modules/custom/ingress.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
ingressOpts = { name, ... }: {
|
||||
options = {
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
|
||||
entrypoint = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "websecure";
|
||||
};
|
||||
|
||||
service = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
|
||||
portName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lab.ingresses = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule ingressOpts);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
kubernetes.resources.ingresses = builtins.mapAttrs
|
||||
(name: ingress: {
|
||||
metadata.annotations = {
|
||||
"cert-manager.io/cluster-issuer" = "letsencrypt";
|
||||
"traefik.ingress.kubernetes.io/router.entrypoints" = ingress.entrypoint;
|
||||
};
|
||||
|
||||
spec = {
|
||||
ingressClassName = "traefik";
|
||||
|
||||
rules = [{
|
||||
host = ingress.host;
|
||||
|
||||
http.paths = [{
|
||||
path = "/";
|
||||
pathType = "Prefix";
|
||||
|
||||
backend.service = {
|
||||
name = ingress.service.name;
|
||||
port.name = ingress.service.portName;
|
||||
};
|
||||
}];
|
||||
}];
|
||||
|
||||
tls = [{
|
||||
secretName = "${name}-tls";
|
||||
hosts = [ ingress.host ];
|
||||
}];
|
||||
};
|
||||
})
|
||||
config.lab.ingresses;
|
||||
};
|
||||
}
|
68
kubenix-modules/custom/longhorn-volume.nix
Normal file
68
kubenix-modules/custom/longhorn-volume.nix
Normal file
|
@ -0,0 +1,68 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
longhornVolumeOpts = { name, ... }: {
|
||||
options = {
|
||||
storage = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lab.longhornVolumes = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule longhornVolumeOpts);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
kubernetes.resources = {
|
||||
persistentVolumes = builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
capacity.storage = longhornVolume.storage;
|
||||
persistentVolumeReclaimPolicy = "Delete";
|
||||
volumeMode = "Filesystem";
|
||||
|
||||
claimRef = {
|
||||
inherit name;
|
||||
namespace = "default";
|
||||
};
|
||||
|
||||
csi = {
|
||||
driver = "driver.longhorn.io";
|
||||
fsType = "ext4";
|
||||
volumeHandle = name;
|
||||
|
||||
volumeAttributes = {
|
||||
dataLocality = "disabled";
|
||||
fromBackup = "";
|
||||
fsType = "ext4";
|
||||
numberOfReplicas = "2";
|
||||
staleReplicaTimeout = "30";
|
||||
unmapMarkSnapChainRemoved = "ignored";
|
||||
|
||||
recurringJobSelector = lib.generators.toYAML { } [{
|
||||
name = "backup-nfs";
|
||||
isGroup = false;
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes;
|
||||
|
||||
persistentVolumeClaims = builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = longhornVolume.storage;
|
||||
storageClassName = "";
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes;
|
||||
};
|
||||
};
|
||||
}
|
47
kubenix-modules/custom/nfs-volume.nix
Normal file
47
kubenix-modules/custom/nfs-volume.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
nfsVolumeOpts = { name, ... }: {
|
||||
options = {
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lab.nfsVolumes = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule nfsVolumeOpts);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
kubernetes.resources = {
|
||||
persistentVolumes = builtins.mapAttrs
|
||||
(name: nfsVolume: {
|
||||
spec = {
|
||||
capacity.storage = "1Mi";
|
||||
accessModes = [ "ReadWriteMany" ];
|
||||
|
||||
nfs = {
|
||||
server = "lewis.dmz";
|
||||
path = "/mnt/longhorn/persistent/${nfsVolume.path}";
|
||||
};
|
||||
};
|
||||
})
|
||||
config.lab.nfsVolumes;
|
||||
|
||||
persistentVolumeClaims = builtins.mapAttrs
|
||||
(name: nfsVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteMany" ];
|
||||
storageClassName = "";
|
||||
resources.requests.storage = "1Mi";
|
||||
volumeName = name;
|
||||
};
|
||||
})
|
||||
config.lab.nfsVolumes;
|
||||
};
|
||||
};
|
||||
}
|
35
kubenix-modules/cyberchef.nix
Normal file
35
kubenix-modules/cyberchef.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ pulledImages, ... }: {
|
||||
kubernetes.resources = {
|
||||
deployments.cyberchef.spec = {
|
||||
replicas = 3;
|
||||
selector.matchLabels.app = "cyberchef";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "cyberchef";
|
||||
|
||||
spec.containers.cyberchef = {
|
||||
image = "mpepping/cyberchef:latest";
|
||||
ports.web.containerPort = 8000;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.cyberchef.spec = {
|
||||
selector.app = "cyberchef";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.cyberchef = {
|
||||
host = "cyberchef.kun.is";
|
||||
|
||||
service = {
|
||||
name = "cyberchef";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
62
kubenix-modules/dnsmasq.nix
Normal file
62
kubenix-modules/dnsmasq.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{ myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
# TODO: generate this with nix?
|
||||
configMaps.dnsmasq-config.data.config = ''
|
||||
address=/kms.kun.is/${myLib.globals.kmsIPv4}
|
||||
address=/ssh.git.kun.is/${myLib.globals.gitIPv4}
|
||||
alias=${myLib.globals.routerPublicIPv4},${myLib.globals.traefikIPv4}
|
||||
expand-hosts
|
||||
host-record=hermes.dmz,${myLib.globals.dnsmasqIPv4}
|
||||
local=/dmz/
|
||||
log-queries
|
||||
no-hosts
|
||||
no-resolv
|
||||
port=53
|
||||
server=192.168.30.1
|
||||
server=/kun.is/${myLib.globals.bind9IPv4}
|
||||
'';
|
||||
|
||||
deployments.dnsmasq = {
|
||||
metadata.labels.app = "dnsmasq";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "dnsmasq";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "dnsmasq";
|
||||
|
||||
spec = {
|
||||
containers.dnsmasq = {
|
||||
image = "dockurr/dnsmasq:2.90";
|
||||
|
||||
ports.dns = {
|
||||
containerPort = 53;
|
||||
protocol = "UDP";
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "config";
|
||||
mountPath = "/etc/dnsmasq.conf";
|
||||
subPath = "config";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes.config.configMap.name = "dnsmasq-config";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.dnsmasq.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.dnsmasqIPv4;
|
||||
selector.app = "dnsmasq";
|
||||
|
||||
ports.dns = {
|
||||
port = 53;
|
||||
targetPort = "dns";
|
||||
protocol = "UDP";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
22
kubenix-modules/ek2024.nix
Normal file
22
kubenix-modules/ek2024.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
services.ek2024.spec = {
|
||||
type = "ExternalName";
|
||||
externalName = "ek2024.dmz";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = 80;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.ek2024 = {
|
||||
host = "ek2024.kun.is";
|
||||
|
||||
service = {
|
||||
name = "ek2024";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
22
kubenix-modules/esrom.nix
Normal file
22
kubenix-modules/esrom.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
services.esrom.spec = {
|
||||
type = "ExternalName";
|
||||
externalName = "esrom.dmz";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = 80;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.esrom = {
|
||||
host = "esrom.kun.is";
|
||||
|
||||
service = {
|
||||
name = "esrom";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
101
kubenix-modules/forgejo/config.nix
Normal file
101
kubenix-modules/forgejo/config.nix
Normal file
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
"repository.local".LOCAL_COPY_PATH = "/data/gitea/tmp/local-repo";
|
||||
"repository.upload".TEMP_PATH = "/data/gitea/uploads";
|
||||
attachment.PATH = "/data/gitea/attachments";
|
||||
lfs.PATH = "/data/git/lfs";
|
||||
mailer.ENABLED = false;
|
||||
"repository.pull-request".DEFAULT_MERGE_STYLE = "merge";
|
||||
"repository.signing".DEFAULT_TRUST_MODEL = "committer";
|
||||
ui.DEFAULT_THEME = "forgejo-light";
|
||||
oauth2.ENABLED = false;
|
||||
|
||||
DEFAULT = {
|
||||
APP_NAME = "Forgejo: Beyond coding. We forge.";
|
||||
RUN_MODE = "prod";
|
||||
RUN_USER = "git";
|
||||
WORK_PATH = "/data/gitea";
|
||||
};
|
||||
|
||||
repository = {
|
||||
ROOT = "/data/git/repositories";
|
||||
DEFAULT_BRANCH = "master";
|
||||
};
|
||||
|
||||
server = {
|
||||
APP_DATA_PATH = "/data/gitea";
|
||||
DOMAIN = "git.kun.is";
|
||||
SSH_DOMAIN = "ssh.git.kun.is";
|
||||
HTTP_PORT = 3000;
|
||||
ROOT_URL = "https://git.kun.is";
|
||||
DISABLE_SSH = false;
|
||||
SSH_PORT = 56287;
|
||||
SSH_LISTEN_PORT = 22;
|
||||
LFS_START_SERVER = true;
|
||||
LFS_JWT_SECRET = "ref+sops://secrets/kubernetes.yaml#/forgejo/lfsJwtSecret";
|
||||
OFFLINE_MODE = false;
|
||||
};
|
||||
|
||||
database = {
|
||||
PATH = "/data/gitea/gitea.db";
|
||||
DB_TYPE = "sqlite3";
|
||||
HOST = "localhost:3306";
|
||||
NAME = "gitea";
|
||||
USER = "root";
|
||||
PASSWD = "";
|
||||
LOG_SQL = false;
|
||||
SCHEMA = "";
|
||||
SSL_MODE = "disable";
|
||||
CHARSET = "utf8";
|
||||
};
|
||||
|
||||
indexer = {
|
||||
ISSUE_INDEXER_PATH = "/data/gitea/indexers/issues.bleve";
|
||||
ISSUE_INDEXER_TYPE = "db";
|
||||
};
|
||||
|
||||
session = {
|
||||
PROVIDER_CONFIG = "/data/gitea/sessions";
|
||||
PROVIDER = "file";
|
||||
};
|
||||
|
||||
picture = {
|
||||
AVATAR_UPLOAD_PATH = "/data/gitea/avatars";
|
||||
REPOSITORY_AVATAR_UPLOAD_PATH = "/data/gitea/repo-avatars";
|
||||
ENABLE_FEDERATED_AVATAR = false;
|
||||
};
|
||||
|
||||
log = {
|
||||
MODE = "console";
|
||||
LEVEL = "info";
|
||||
"logger.router.MODE" = "console";
|
||||
ROOT_PATH = "/data/gitea/log";
|
||||
"logger.access.MODE" = "console";
|
||||
};
|
||||
|
||||
security = {
|
||||
INSTALL_LOCK = true;
|
||||
SECRET_KEY = "";
|
||||
REVERSE_PROXY_LIMIT = 1;
|
||||
REVERSE_PROXY_TRUSTED_PROXIES = "*";
|
||||
INTERNAL_TOKEN = "ref+sops://secrets/kubernetes.yaml#/forgejo/internalToken";
|
||||
PASSWORD_HASH_ALGO = "pbkdf2";
|
||||
};
|
||||
|
||||
service = {
|
||||
DISABLE_REGISTRATION = true;
|
||||
REQUIRE_SIGNIN_VIEW = false;
|
||||
REGISTER_EMAIL_CONFIRM = false;
|
||||
ENABLE_NOTIFY_MAIL = false;
|
||||
ALLOW_ONLY_EXTERNAL_REGISTRATION = false;
|
||||
ENABLE_CAPTCHA = false;
|
||||
DEFAULT_KEEP_EMAIL_PRIVATE = true;
|
||||
DEFAULT_ALLOW_CREATE_ORGANIZATION = true;
|
||||
DEFAULT_ENABLE_TIMETRACKING = true;
|
||||
NO_REPLY_ADDRESS = "noreply.localhost";
|
||||
};
|
||||
|
||||
openid = {
|
||||
ENABLE_OPENID_SIGNIN = true;
|
||||
ENABLE_OPENID_SIGNUP = false;
|
||||
};
|
||||
}
|
102
kubenix-modules/forgejo/default.nix
Normal file
102
kubenix-modules/forgejo/default.nix
Normal file
|
@ -0,0 +1,102 @@
|
|||
{ lib, myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
configMaps = {
|
||||
forgejo-config.data = {
|
||||
config = lib.generators.toINI { } (import ./config.nix);
|
||||
};
|
||||
|
||||
forgejo-env.data = {
|
||||
USER_UID = "1000";
|
||||
USER_GID = "1000";
|
||||
};
|
||||
};
|
||||
|
||||
deployments = {
|
||||
forgejo = {
|
||||
metadata.labels = {
|
||||
app = "forgejo";
|
||||
component = "forgejo";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "forgejo";
|
||||
component = "forgejo";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "forgejo";
|
||||
component = "forgejo";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.forgejo = {
|
||||
image = "codeberg.org/forgejo/forgejo:7.0.1";
|
||||
envFrom = [{ configMapRef.name = "forgejo-env"; }];
|
||||
|
||||
ports = {
|
||||
web.containerPort = 3000;
|
||||
ssh.containerPort = 22;
|
||||
};
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "data";
|
||||
mountPath = "/data";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/data/gitea/conf/app.ini";
|
||||
subPath = "config";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "forgejo";
|
||||
config.configMap.name = "forgejo-config";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
forgejo-web.spec = {
|
||||
selector = {
|
||||
app = "forgejo";
|
||||
component = "forgejo";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
forgejo-ssh.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.gitIPv4;
|
||||
selector.app = "forgejo";
|
||||
|
||||
ports.ssh = {
|
||||
port = 56287;
|
||||
targetPort = "ssh";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.forgejo = {
|
||||
host = "git.kun.is";
|
||||
|
||||
service = {
|
||||
name = "forgejo-web";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
86
kubenix-modules/freshrss.nix
Normal file
86
kubenix-modules/freshrss.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
configMaps.freshrss.data = {
|
||||
TZ = "Europe/Amsterdam";
|
||||
CRON_MIN = "2,32";
|
||||
ADMIN_EMAIL = "pim@kunis.nl";
|
||||
PUBLISHED_PORT = "443";
|
||||
};
|
||||
|
||||
secrets.freshrss.stringData.adminPassword = "ref+sops://secrets/kubernetes.yaml#/freshrss/password";
|
||||
|
||||
deployments.freshrss = {
|
||||
metadata.labels.app = "freshrss";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "freshrss";
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "freshrss";
|
||||
|
||||
spec = {
|
||||
containers.freshrss = {
|
||||
image = "freshrss/freshrss:1.24.1";
|
||||
imagePullPolicy = "Always";
|
||||
envFrom = [{ configMapRef.name = "freshrss"; }];
|
||||
ports.web.containerPort = 80;
|
||||
|
||||
env = {
|
||||
ADMIN_PASSWORD.valueFrom.secretKeyRef = {
|
||||
name = "freshrss";
|
||||
key = "adminPassword";
|
||||
};
|
||||
|
||||
ADMIN_API_PASSWORD.valueFrom.secretKeyRef = {
|
||||
name = "freshrss";
|
||||
key = "adminPassword";
|
||||
};
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/var/www/FreshRSS/data";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes.data.persistentVolumeClaim.claimName = "freshrss";
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 33;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.freshrss.spec = {
|
||||
selector.app = "freshrss";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.freshrss = {
|
||||
host = "rss.kun.is";
|
||||
|
||||
service = {
|
||||
name = "freshrss";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
170
kubenix-modules/hedgedoc.nix
Normal file
170
kubenix-modules/hedgedoc.nix
Normal file
|
@ -0,0 +1,170 @@
|
|||
{ lib, ... }: {
|
||||
kubernetes.resources = {
|
||||
configMaps = {
|
||||
hedgedoc-env.data = {
|
||||
CMD_DOMAIN = "md.kun.is";
|
||||
CMD_PORT = "3000";
|
||||
CMD_URL_ADDPORT = "false";
|
||||
CMD_ALLOW_ANONYMOUS = "true";
|
||||
CMD_ALLOW_EMAIL_REGISTER = "false";
|
||||
CMD_PROTOCOL_USESSL = "true";
|
||||
CMD_CSP_ENABLE = "false";
|
||||
};
|
||||
|
||||
hedgedoc-config.data.config = lib.generators.toJSON { } {
|
||||
useSSL = false;
|
||||
};
|
||||
|
||||
hedgedoc-db-env.data = {
|
||||
POSTGRES_DB = "hedgedoc";
|
||||
POSTGRES_USER = "hedgedoc";
|
||||
POSTGRES_PASSWORD = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/databasePassword";
|
||||
PGDATA = "/pgdata/data";
|
||||
};
|
||||
};
|
||||
|
||||
secrets.hedgedoc.stringData = {
|
||||
databaseURL = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/databaseURL";
|
||||
sessionSecret = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/sessionSecret";
|
||||
};
|
||||
|
||||
deployments = {
|
||||
hedgedoc = {
|
||||
metadata.labels = {
|
||||
app = "hedgedoc";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "hedgedoc";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "hedgedoc";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.hedgedoc = {
|
||||
image = "quay.io/hedgedoc/hedgedoc:1.9.9";
|
||||
envFrom = [{ configMapRef.name = "hedgedoc-env"; }];
|
||||
ports.web.containerPort = 3000;
|
||||
|
||||
env = {
|
||||
CMD_DB_URL.valueFrom.secretKeyRef = {
|
||||
name = "hedgedoc";
|
||||
key = "databaseURL";
|
||||
};
|
||||
|
||||
CMD_SESSION_SECRET.valueFrom.secretKeyRef = {
|
||||
name = "hedgedoc";
|
||||
key = "sessionSecret";
|
||||
};
|
||||
};
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "uploads";
|
||||
mountPath = "/hedgedoc/public/uploads";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/hedgedoc/config.json";
|
||||
subPath = "config";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
uploads.persistentVolumeClaim.claimName = "hedgedoc-uploads";
|
||||
config.configMap.name = "hedgedoc-config";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 65534;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
hedgedoc-db = {
|
||||
metadata.labels = {
|
||||
app = "hedgedoc";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "hedgedoc";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "hedgedoc";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.postgres = {
|
||||
image = "postgres:15";
|
||||
imagePullPolicy = "IfNotPresent";
|
||||
ports.postgres.containerPort = 5432;
|
||||
envFrom = [{ configMapRef.name = "hedgedoc-db-env"; }];
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/pgdata";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes.data.persistentVolumeClaim.claimName = "hedgedoc-db";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
hedgedoc.spec = {
|
||||
selector = {
|
||||
app = "hedgedoc";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
hedgedoc-db.spec = {
|
||||
selector = {
|
||||
app = "hedgedoc";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
ports.postgres = {
|
||||
port = 5432;
|
||||
targetPort = "postgres";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.hedgedoc = {
|
||||
host = "md.kun.is";
|
||||
|
||||
service = {
|
||||
name = "hedgedoc";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
256
kubenix-modules/immich.nix
Normal file
256
kubenix-modules/immich.nix
Normal file
|
@ -0,0 +1,256 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
deployments = {
|
||||
immich-server = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "server";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "immich";
|
||||
component = "server";
|
||||
};
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "server";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "immich";
|
||||
|
||||
containers.immich = {
|
||||
image = "ghcr.io/immich-app/immich-server:v1.106.4";
|
||||
imagePullPolicy = "Always";
|
||||
ports.web.containerPort = 3001;
|
||||
|
||||
env = {
|
||||
TZ.value = "Europe/Amsterdam";
|
||||
REDIS_HOSTNAME.value = "immich-redis.default.svc.cluster.local";
|
||||
DB_HOSTNAME.value = "immich-postgres.default.svc.cluster.local";
|
||||
DB_USERNAME.value = "postgres";
|
||||
DB_PASSWORD.value = "ref+sops://secrets/kubernetes.yaml#/immich/databasePassword";
|
||||
DB_DATABASE_NAME.value = "immich";
|
||||
IMMICH_MACHINE_LEARNING_URL.value = "http://immich-ml.default.svc.cluster.local";
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/usr/src/app/upload";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
immich-ml = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "machine-learning";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "immich";
|
||||
component = "machine-learning";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "machine-learning";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.cache.persistentVolumeClaim.claimName = "immich-cache";
|
||||
|
||||
containers.machine-learning = {
|
||||
image = "ghcr.io/immich-app/immich-machine-learning:v1.106.4";
|
||||
imagePullPolicy = "Always";
|
||||
ports.ml.containerPort = 3003;
|
||||
env.MACHINE_LEARNING_WORKER_TIMEOUT.value = "600";
|
||||
|
||||
volumeMounts = [{
|
||||
name = "cache";
|
||||
mountPath = "/cache";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
immich-redis = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "immich";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.redis = {
|
||||
image = "docker.io/redis:6.2-alpine@sha256:d6c2911ac51b289db208767581a5d154544f2b2fe4914ea5056443f62dc6e900";
|
||||
ports.redis.containerPort = 6379;
|
||||
imagePullPolicy = "Always";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
immich-database = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "immich";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "immich";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "immich-db";
|
||||
|
||||
containers.postgres = {
|
||||
image = "docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0";
|
||||
imagePullPolicy = "Always";
|
||||
command = [ "postgres" ];
|
||||
args = [ "-c" "shared_preload_libraries=vectors.so" "-c" "search_path=\"$$user\", public, vectors" "-c" "logging_collector=on" "-c" "max_wal_size=2GB" "-c" "shared_buffers=512MB" "-c" "wal_compression=on" ];
|
||||
ports.postgres.containerPort = 5432;
|
||||
securityContext.runAsUser = 999;
|
||||
securityContext.runAsGroup = 999;
|
||||
|
||||
env = {
|
||||
POSTGRES_PASSWORD.value = "ref+sops://secrets/kubernetes.yaml#/immich/databasePassword";
|
||||
POSTGRES_USER.value = "postgres";
|
||||
POSTGRES_DB.value = "immich";
|
||||
POSTGRES_INITDB_ARGS.value = "--data-checksums";
|
||||
PGDATA.value = "/pgdata/data";
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/pgdata";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
immich-server.spec = {
|
||||
selector = {
|
||||
app = "immich";
|
||||
component = "server";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
immich-redis.spec = {
|
||||
selector = {
|
||||
app = "immich";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
ports.redis = {
|
||||
port = 6379;
|
||||
targetPort = "redis";
|
||||
};
|
||||
};
|
||||
|
||||
immich-ml.spec = {
|
||||
selector = {
|
||||
app = "immich";
|
||||
component = "machine-learning";
|
||||
};
|
||||
|
||||
ports.ml = {
|
||||
port = 80;
|
||||
targetPort = "ml";
|
||||
};
|
||||
};
|
||||
|
||||
immich-postgres.spec = {
|
||||
selector = {
|
||||
app = "immich";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
ports.postgres = {
|
||||
port = 5432;
|
||||
targetPort = "postgres";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
persistentVolumeClaims.immich-cache.spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = "5Gi";
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.immich-test = {
|
||||
host = "immich.kun.is";
|
||||
|
||||
service = {
|
||||
name = "immich-server";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
58
kubenix-modules/inbucket.nix
Normal file
58
kubenix-modules/inbucket.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
{ pulledImages, myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
deployments.inbucket = {
|
||||
metadata.labels.app = "inbucket";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "inbucket";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "inbucket";
|
||||
|
||||
spec = {
|
||||
containers.inbucket = {
|
||||
image = "inbucket/inbucket:edge";
|
||||
|
||||
ports = {
|
||||
web.containerPort = 9000;
|
||||
smtp.containerPort = 2500;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
inbucket-web.spec = {
|
||||
selector.app = "inbucket";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
inbucket-email.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.inbucketIPv4;
|
||||
selector.app = "inbucket";
|
||||
|
||||
ports = [{
|
||||
port = 25;
|
||||
targetPort = "smtp";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab.ingresses.inbucket = {
|
||||
host = "inbucket.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "inbucket-web";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
}
|
61
kubenix-modules/kitchenowl.nix
Normal file
61
kubenix-modules/kitchenowl.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
secrets.kitchenowl.stringData.jwtSecretKey = "ref+sops://secrets/kubernetes.yaml#/kitchenowl/jwtSecretKey";
|
||||
|
||||
deployments.kitchenowl = {
|
||||
metadata.labels.app = "kitchenowl";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "kitchenowl";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "kitchenowl";
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "kitchenowl";
|
||||
|
||||
containers.kitchenowl = {
|
||||
image = "tombursch/kitchenowl:v0.5.1";
|
||||
ports.web.containerPort = 8080;
|
||||
|
||||
env.JWT_SECRET_KEY.valueFrom.secretKeyRef = {
|
||||
name = "kitchenowl";
|
||||
key = "jwtSecretKey";
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/data";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 0;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.kitchenowl.spec = {
|
||||
selector.app = "kitchenowl";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.kitchenowl = {
|
||||
host = "boodschappen.kun.is";
|
||||
|
||||
service = {
|
||||
name = "kitchenowl";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
31
kubenix-modules/kms.nix
Normal file
31
kubenix-modules/kms.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
deployments.kms = {
|
||||
metadata.labels.app = "kms";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "kms";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "kms";
|
||||
|
||||
spec.containers.kms = {
|
||||
image = "teddysun/kms";
|
||||
ports.kms.containerPort = 1688;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.kms.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.kmsIPv4;
|
||||
selector.app = "kms";
|
||||
|
||||
ports.kms = {
|
||||
port = 1688;
|
||||
targetPort = "kms";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
44
kubenix-modules/longhorn.nix
Normal file
44
kubenix-modules/longhorn.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ lib, nixhelm, system, ... }: {
|
||||
config = {
|
||||
kubernetes = {
|
||||
resources = {
|
||||
ingresses.longhorn = {
|
||||
metadata.annotations = {
|
||||
"cert-manager.io/cluster-issuer" = "letsencrypt";
|
||||
"traefik.ingress.kubernetes.io/router.entrypoints" = "localsecure";
|
||||
};
|
||||
|
||||
spec = {
|
||||
ingressClassName = "traefik";
|
||||
|
||||
rules = [{
|
||||
host = "longhorn.kun.is";
|
||||
|
||||
http.paths = [{
|
||||
path = "/";
|
||||
pathType = "Prefix";
|
||||
|
||||
backend.service = {
|
||||
name = "longhorn-frontend";
|
||||
port.number = 80;
|
||||
};
|
||||
}];
|
||||
}];
|
||||
|
||||
tls = [{
|
||||
secretName = "longhorn-tls";
|
||||
hosts = [ "longhorn.kun.is" ];
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
recurringJobs.backup-nfs.spec = {
|
||||
cron = "0 1 * * *"; # One o'clock at night
|
||||
task = "backup";
|
||||
retain = 2; # We don't need many, as we also make Borg backups.
|
||||
concurrency = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
585
kubenix-modules/media.nix
Normal file
585
kubenix-modules/media.nix
Normal file
|
@ -0,0 +1,585 @@
|
|||
{ myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
configMaps = {
|
||||
jellyfin-env.data.JELLYFIN_PublishedServerUrl = "https://media.kun.is";
|
||||
transmission-env.data = {
|
||||
PUID = "1000";
|
||||
PGID = "1000";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
|
||||
jellyseerr-env.data = {
|
||||
LOG_LEVEL = "debug";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
|
||||
radarr-env.data = {
|
||||
PUID = "1000";
|
||||
PGID = "1000";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
|
||||
prowlarr-env.data = {
|
||||
PUID = "1000";
|
||||
PGID = "1000";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
|
||||
sonarr-env.data = {
|
||||
PUID = "1000";
|
||||
PGID = "1000";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
|
||||
bazarr-env.data = {
|
||||
PUID = "1000";
|
||||
PGID = "1000";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
};
|
||||
|
||||
deployments = {
|
||||
jellyfin = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "jellyfin";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "jellyfin";
|
||||
};
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "jellyfin";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.jellyfin = {
|
||||
image = "jellyfin/jellyfin:10.9.6";
|
||||
envFrom = [{ configMapRef.name = "jellyfin-env"; }];
|
||||
ports.web.containerPort = 8096;
|
||||
imagePullPolicy = "Always";
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}
|
||||
{
|
||||
name = "media";
|
||||
mountPath = "/media";
|
||||
}
|
||||
{
|
||||
name = "cache";
|
||||
mountPath = "/config/transcodes";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
config.persistentVolumeClaim.claimName = "jellyfin";
|
||||
cache.persistentVolumeClaim.claimName = "jellyfin-cache";
|
||||
|
||||
media.hostPath = {
|
||||
path = "/mnt/longhorn/persistent/media";
|
||||
type = "Directory";
|
||||
};
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 0;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
|
||||
affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms = [{
|
||||
matchExpressions = [{
|
||||
key = "hasMedia";
|
||||
operator = "In";
|
||||
values = [ "true" ];
|
||||
}];
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
transmission = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "transmission";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "transmission";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "transmission";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.transmission = {
|
||||
image = "lscr.io/linuxserver/transmission:latest";
|
||||
envFrom = [{ configMapRef.name = "transmission-env"; }];
|
||||
|
||||
ports = {
|
||||
web.containerPort = 9091;
|
||||
bittorrent.containerPort = 31780;
|
||||
};
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}
|
||||
{
|
||||
name = "media";
|
||||
mountPath = "/media";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
config.persistentVolumeClaim.claimName = "transmission";
|
||||
media.persistentVolumeClaim.claimName = "media";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
jellyseerr = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "jellyseerr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "jellyseerr";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "jellyseerr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.config.persistentVolumeClaim.claimName = "jellyseerr";
|
||||
|
||||
containers.jellyseerr = {
|
||||
image = "fallenbagel/jellyseerr:1.7.0";
|
||||
envFrom = [{ configMapRef.name = "jellyseerr-env"; }];
|
||||
ports.web.containerPort = 5055;
|
||||
|
||||
volumeMounts = [{
|
||||
name = "config";
|
||||
mountPath = "/app/config";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 0;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
radarr = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "radarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "radarr";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "radarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.radarr = {
|
||||
image = "lscr.io/linuxserver/radarr:latest";
|
||||
envFrom = [{ configMapRef.name = "radarr-env"; }];
|
||||
ports.web.containerPort = 7878;
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}
|
||||
{
|
||||
name = "media";
|
||||
mountPath = "/media";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
config.persistentVolumeClaim.claimName = "radarr";
|
||||
media.persistentVolumeClaim.claimName = "media";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
prowlarr = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "prowlarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "prowlarr";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "prowlarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.config.persistentVolumeClaim.claimName = "prowlarr";
|
||||
|
||||
containers.prowlarr = {
|
||||
image = "lscr.io/linuxserver/prowlarr:latest";
|
||||
envFrom = [{ configMapRef.name = "prowlarr-env"; }];
|
||||
ports.web.containerPort = 9696;
|
||||
|
||||
volumeMounts = [{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sonarr = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "sonarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "sonarr";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "sonarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.sonarr = {
|
||||
image = "lscr.io/linuxserver/sonarr:latest";
|
||||
envFrom = [{ configMapRef.name = "sonarr-env"; }];
|
||||
ports.web.containerPort = 8989;
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}
|
||||
{
|
||||
name = "media";
|
||||
mountPath = "/media";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
config.persistentVolumeClaim.claimName = "sonarr";
|
||||
media.persistentVolumeClaim.claimName = "media";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
bazarr = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "bazarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "media";
|
||||
component = "bazarr";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "media";
|
||||
component = "bazarr";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.bazarr = {
|
||||
image = "lscr.io/linuxserver/bazarr:latest";
|
||||
envFrom = [{ configMapRef.name = "bazarr-env"; }];
|
||||
ports.web.containerPort = 6767;
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}
|
||||
{
|
||||
name = "media";
|
||||
mountPath = "/media";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
config.persistentVolumeClaim.claimName = "bazarr";
|
||||
media.persistentVolumeClaim.claimName = "media";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
jellyfin.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "jellyfin";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
transmission-web.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "transmission";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
transmission-bittorrent.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.bittorrentIPv4;
|
||||
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "transmission";
|
||||
};
|
||||
|
||||
ports.bittorrent = {
|
||||
port = 31780;
|
||||
targetPort = "bittorrent";
|
||||
};
|
||||
};
|
||||
|
||||
jellyseerr.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "jellyseerr";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
radarr.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "radarr";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
prowlarr.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "prowlarr";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
sonarr.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "sonarr";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
bazarr.spec = {
|
||||
selector = {
|
||||
app = "media";
|
||||
component = "bazarr";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
persistentVolumeClaims.jellyfin-cache.spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = "20Gi";
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses = {
|
||||
jellyfin = {
|
||||
host = "media.kun.is";
|
||||
|
||||
service = {
|
||||
name = "jellyfin";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
||||
transmission = {
|
||||
host = "transmission.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "transmission-web";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
||||
jellyseerr = {
|
||||
host = "jellyseerr.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "jellyseerr";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
||||
radarr = {
|
||||
host = "radarr.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "radarr";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
||||
prowlarr = {
|
||||
host = "prowlarr.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "prowlarr";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
||||
sonarr = {
|
||||
host = "sonarr.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "sonarr";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
||||
bazarr = {
|
||||
host = "bazarr.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "bazarr";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
7
kubenix-modules/metallb.nix
Normal file
7
kubenix-modules/metallb.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
# TODO: These resources should probably exist within the kube-system namespace.
|
||||
{
|
||||
kubernetes.resources = {
|
||||
ipAddressPools.main.spec.addresses = [ "192.168.30.128-192.168.30.200" "2a0d:6e00:1a77:30::2-2a0d:6e00:1a77:30:ffff:ffff:ffff:fffe" ];
|
||||
l2Advertisements.main.metadata = { };
|
||||
};
|
||||
}
|
48
kubenix-modules/minecraft.nix
Normal file
48
kubenix-modules/minecraft.nix
Normal file
|
@ -0,0 +1,48 @@
|
|||
{ myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
configMaps.minecraft-env.data.EULA = "TRUE";
|
||||
|
||||
deployments.minecraft = {
|
||||
metadata.labels.app = "minecraft";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "minecraft";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "minecraft";
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "minecraft";
|
||||
|
||||
containers.minecraft = {
|
||||
image = "itzg/minecraft-server";
|
||||
envFrom = [{ configMapRef.name = "minecraft-env"; }];
|
||||
ports.minecraft.containerPort = 25565;
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/data";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.minecraft.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.minecraftIPv4;
|
||||
selector.app = "minecraft";
|
||||
|
||||
ports.minecraft = {
|
||||
port = 25565;
|
||||
targetPort = "minecraft";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
160
kubenix-modules/nextcloud.nix
Normal file
160
kubenix-modules/nextcloud.nix
Normal file
|
@ -0,0 +1,160 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
configMaps = {
|
||||
nextcloud.data = {
|
||||
POSTGRES_USER = "nextcloud";
|
||||
POSTGRES_DB = "nextcloud";
|
||||
POSTGRES_HOST = "lewis.dmz";
|
||||
};
|
||||
|
||||
nextcloud-db-env.data = {
|
||||
POSTGRES_DB = "nextcloud";
|
||||
POSTGRES_USER = "nextcloud";
|
||||
POSTGRES_PASSWORD = "ref+sops://secrets/kubernetes.yaml#/nextcloud/databasePassword";
|
||||
PGDATA = "/pgdata/data";
|
||||
};
|
||||
};
|
||||
|
||||
secrets.nextcloud.stringData.databasePassword = "ref+sops://secrets/kubernetes.yaml#/nextcloud/databasePassword";
|
||||
|
||||
deployments = {
|
||||
nextcloud = {
|
||||
metadata.labels = {
|
||||
app = "nextcloud";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "nextcloud";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
strategy = {
|
||||
type = "RollingUpdate";
|
||||
|
||||
rollingUpdate = {
|
||||
maxSurge = 0;
|
||||
maxUnavailable = 1;
|
||||
};
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "nextcloud";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "nextcloud";
|
||||
|
||||
containers.nextcloud = {
|
||||
image = "nextcloud:28";
|
||||
envFrom = [{ configMapRef.name = "nextcloud"; }];
|
||||
ports.web.containerPort = 80;
|
||||
|
||||
env.POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
|
||||
name = "nextcloud";
|
||||
key = "databasePassword";
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/var/www/html";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 33;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
|
||||
affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution = [{
|
||||
weight = 1;
|
||||
preference.matchExpressions = [{
|
||||
key = "storageType";
|
||||
operator = "In";
|
||||
values = [ "fast" ];
|
||||
}];
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nextcloud-db = {
|
||||
metadata.labels = {
|
||||
app = "nextcloud";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "nextcloud";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "nextcloud";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.postgres = {
|
||||
image = "postgres:15";
|
||||
imagePullPolicy = "IfNotPresent";
|
||||
ports.postgres.containerPort = 5432;
|
||||
envFrom = [{ configMapRef.name = "nextcloud-db-env"; }];
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/pgdata";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes.data.persistentVolumeClaim.claimName = "nextcloud-db";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
nextcloud.spec = {
|
||||
selector = {
|
||||
app = "nextcloud";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
nextcloud-db.spec = {
|
||||
selector = {
|
||||
app = "nextcloud";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
ports.postgres = {
|
||||
port = 5432;
|
||||
targetPort = "postgres";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.nextcloud = {
|
||||
host = "cloud.kun.is";
|
||||
|
||||
service = {
|
||||
name = "nextcloud";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
213
kubenix-modules/paperless.nix
Normal file
213
kubenix-modules/paperless.nix
Normal file
|
@ -0,0 +1,213 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
configMaps = {
|
||||
paperless.data = {
|
||||
PAPERLESS_REDIS = "redis://paperless-redis.default.svc.cluster.local:6379";
|
||||
PAPERLESS_DBENGINE = "postgresql";
|
||||
PAPERLESS_DBHOST = "paperless-db.default.svc.cluster.local";
|
||||
PAPERLESS_DBNAME = "paperless";
|
||||
PAPERLESS_DBUSER = "paperless";
|
||||
PAPERLESS_DATA_DIR = "/data/";
|
||||
PAPERLESS_MEDIA_ROOT = "/data/";
|
||||
PAPERLESS_OCR_LANGUAGES = "nld eng";
|
||||
PAPERLESS_URL = "https://paperless.kun.is";
|
||||
PAPERLESS_TIME_ZONE = "Europe/Amsterdam";
|
||||
PAPERLESS_OCR_LANGUAGE = "nld";
|
||||
USERMAP_UID = "33";
|
||||
USERMAP_GID = "33";
|
||||
};
|
||||
|
||||
paperless-db-env.data = {
|
||||
POSTGRES_DB = "paperless";
|
||||
POSTGRES_USER = "paperless";
|
||||
POSTGRES_PASSWORD = "ref+sops://secrets/kubernetes.yaml#/paperless/databasePassword";
|
||||
PGDATA = "/pgdata/data";
|
||||
};
|
||||
};
|
||||
|
||||
secrets.paperless.stringData = {
|
||||
databasePassword = "ref+sops://secrets/kubernetes.yaml#/paperless/databasePassword";
|
||||
secretKey = "ref+sops://secrets/kubernetes.yaml#/paperless/secretKey";
|
||||
};
|
||||
|
||||
deployments = {
|
||||
paperless-web = {
|
||||
metadata.labels = {
|
||||
app = "paperless";
|
||||
component = "web";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "paperless";
|
||||
component = "web";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "paperless";
|
||||
component = "web";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "paperless-data";
|
||||
|
||||
containers.paperless = {
|
||||
image = "ghcr.io/paperless-ngx/paperless-ngx:2.3";
|
||||
envFrom = [{ configMapRef.name = "paperless"; }];
|
||||
ports.web.containerPort = 8000;
|
||||
|
||||
env = {
|
||||
PAPERLESS_DBPASS.valueFrom.secretKeyRef = {
|
||||
name = "paperless";
|
||||
key = "databasePassword";
|
||||
};
|
||||
PAPERLESS_SECRET_KEY.valueFrom.secretKeyRef = {
|
||||
name = "paperless";
|
||||
key = "secretKey";
|
||||
};
|
||||
};
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/data";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 33;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
paperless-redis = {
|
||||
metadata.labels = {
|
||||
app = "paperless";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "paperless";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "paperless";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
spec = {
|
||||
volumes.data.persistentVolumeClaim.claimName = "paperless-redisdata";
|
||||
|
||||
containers.redis = {
|
||||
image = "docker.io/library/redis:7";
|
||||
ports.redis.containerPort = 6379;
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/data";
|
||||
}];
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 999;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
paperless-db = {
|
||||
metadata.labels = {
|
||||
app = "paperless";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "paperless";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "paperless";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.postgres = {
|
||||
image = "postgres:15";
|
||||
imagePullPolicy = "IfNotPresent";
|
||||
ports.postgres.containerPort = 5432;
|
||||
envFrom = [{ configMapRef.name = "paperless-db-env"; }];
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/pgdata";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes.data.persistentVolumeClaim.claimName = "paperless-db";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
paperless-web.spec = {
|
||||
selector = {
|
||||
app = "paperless";
|
||||
component = "web";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
paperless-redis.spec = {
|
||||
selector = {
|
||||
app = "paperless";
|
||||
component = "redis";
|
||||
};
|
||||
|
||||
ports.redis = {
|
||||
port = 6379;
|
||||
targetPort = "redis";
|
||||
};
|
||||
};
|
||||
|
||||
paperless-db.spec = {
|
||||
selector = {
|
||||
app = "paperless";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
ports.postgres = {
|
||||
port = 5432;
|
||||
targetPort = "postgres";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.paperless = {
|
||||
host = "paperless.kun.is";
|
||||
|
||||
service = {
|
||||
name = "paperless-web";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
99
kubenix-modules/pihole.nix
Normal file
99
kubenix-modules/pihole.nix
Normal file
|
@ -0,0 +1,99 @@
|
|||
{ myLib, ... }: {
|
||||
kubernetes.resources = {
|
||||
configMaps.pihole.data = {
|
||||
TZ = "Europe/Amsterdam";
|
||||
PIHOLE_DNS_ = "192.168.30.1";
|
||||
};
|
||||
|
||||
secrets.pihole.stringData.webPassword = "ref+sops://secrets/kubernetes.yaml#/pihole/password";
|
||||
|
||||
deployments.pihole = {
|
||||
metadata.labels.app = "pihole";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "pihole";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "pihole";
|
||||
|
||||
spec = {
|
||||
containers.pihole = {
|
||||
image = "pihole/pihole:latest";
|
||||
envFrom = [{ configMapRef.name = "pihole"; }];
|
||||
|
||||
ports = {
|
||||
web.containerPort = 80;
|
||||
|
||||
dns = {
|
||||
containerPort = 53;
|
||||
protocol = "UDP";
|
||||
};
|
||||
};
|
||||
|
||||
env.WEBPASSWORD.valueFrom.secretKeyRef = {
|
||||
name = "pihole";
|
||||
key = "webPassword";
|
||||
};
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "data";
|
||||
mountPath = "/etc/pihole";
|
||||
}
|
||||
{
|
||||
name = "dnsmasq";
|
||||
mountPath = "/etc/dnsmasq.d";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "pihole-data";
|
||||
dnsmasq.persistentVolumeClaim.claimName = "pihole-dnsmasq";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
pihole-web.spec = {
|
||||
selector.app = "pihole";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
pihole-dns.spec = {
|
||||
type = "LoadBalancer";
|
||||
loadBalancerIP = myLib.globals.piholeIPv4;
|
||||
selector.app = "pihole";
|
||||
|
||||
ports.dns = {
|
||||
protocol = "UDP";
|
||||
port = 53;
|
||||
targetPort = "dns";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.pihole = {
|
||||
host = "pihole.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "pihole-web";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
102
kubenix-modules/radicale.nix
Normal file
102
kubenix-modules/radicale.nix
Normal file
|
@ -0,0 +1,102 @@
|
|||
{ lib, ... }: {
|
||||
kubernetes.resources = {
|
||||
configMaps.radicale.data = {
|
||||
users = "pim:$apr1$GUiTihkS$dDCkaUxFx/O86m6NCy/yQ.";
|
||||
|
||||
config = lib.generators.toINI { } {
|
||||
server = {
|
||||
hosts = "0.0.0.0:5232, [::]:5232";
|
||||
ssl = false;
|
||||
};
|
||||
|
||||
encoding = {
|
||||
request = "utf-8";
|
||||
stock = "utf-8";
|
||||
};
|
||||
|
||||
auth = {
|
||||
realm = "Radicale - Password Required";
|
||||
type = "htpasswd";
|
||||
htpasswd_filename = "/config/users";
|
||||
htpasswd_encryption = "md5";
|
||||
};
|
||||
|
||||
rights.type = "owner_only";
|
||||
|
||||
storage = {
|
||||
type = "multifilesystem";
|
||||
filesystem_folder = "/data";
|
||||
};
|
||||
|
||||
logging = { };
|
||||
headers = { };
|
||||
};
|
||||
};
|
||||
|
||||
deployments.radicale = {
|
||||
metadata.labels.app = "radicale";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "radicale";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "radicale";
|
||||
|
||||
spec = {
|
||||
containers.radicale = {
|
||||
image = "tomsquest/docker-radicale:3.2.0.0";
|
||||
ports.web.containerPort = 5232;
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "data";
|
||||
mountPath = "/data";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config/config";
|
||||
subPath = "config";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config/users";
|
||||
subPath = "users";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "radicale";
|
||||
config.configMap.name = "radicale";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 2999;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.radicale.spec = {
|
||||
selector.app = "radicale";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.radicale = {
|
||||
host = "dav.kun.is";
|
||||
|
||||
service = {
|
||||
name = "radicale";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
71
kubenix-modules/syncthing.nix
Normal file
71
kubenix-modules/syncthing.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
kubernetes.resources = {
|
||||
configMaps.syncthing.data = {
|
||||
PUID = "33";
|
||||
PGID = "33";
|
||||
TZ = "Europe/Amsterdam";
|
||||
};
|
||||
|
||||
deployments.syncthing = {
|
||||
metadata.labels.app = "syncthing";
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "syncthing";
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "syncthing";
|
||||
|
||||
spec = {
|
||||
containers.syncthing = {
|
||||
image = "lscr.io/linuxserver/syncthing:1.23.6";
|
||||
envFrom = [{ configMapRef.name = "syncthing"; }];
|
||||
ports.web.containerPort = 8384;
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/config";
|
||||
}
|
||||
{
|
||||
name = "music";
|
||||
mountPath = "/music";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
config.persistentVolumeClaim.claimName = "syncthing";
|
||||
music.persistentVolumeClaim.claimName = "music";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 33;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.syncthing.spec = {
|
||||
selector.app = "syncthing";
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.syncthing = {
|
||||
host = "sync.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "syncthing";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
34
kubenix-modules/traefik.nix
Normal file
34
kubenix-modules/traefik.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ lib, myLib, ... }: {
|
||||
kubernetes.resources.helmChartConfigs = {
|
||||
traefik = {
|
||||
metadata.namespace = "kube-system";
|
||||
|
||||
# Override Traefik's service with a static load balancer IP.
|
||||
# Create endpoint for HTTPS on port 444.
|
||||
# Allow external name services for esrom.
|
||||
spec.valuesContent = lib.generators.toYAML { } {
|
||||
# service.annotations."metallb.universe.tf/loadBalancerIPs" = myLib.globals.traefikIPv4;
|
||||
providers.kubernetesIngress.allowExternalNameServices = true;
|
||||
service.loadBalancerIP = myLib.globals.traefikIPv4;
|
||||
|
||||
ports = {
|
||||
localsecure = {
|
||||
port = 8444;
|
||||
expose = true;
|
||||
exposedPort = 444;
|
||||
protocol = "TCP";
|
||||
|
||||
tls = {
|
||||
enabled = true;
|
||||
options = "";
|
||||
certResolver = "";
|
||||
domains = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
web.redirectTo = "websecure";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
54
kubenix-modules/volumes.nix
Normal file
54
kubenix-modules/volumes.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
# kubernetes.resources.pods.testje.spec = {
|
||||
# containers.testje = {
|
||||
# image = "nginx";
|
||||
|
||||
# volumeMounts = [
|
||||
|
||||
# { name = "immich"; mountPath = "/immich"; }
|
||||
# { name = "immich-db"; mountPath = "/immich-db"; }
|
||||
# ];
|
||||
# };
|
||||
|
||||
# volumes.immich.persistentVolumeClaim.claimName = "immich";
|
||||
# volumes.immich-db.persistentVolumeClaim.claimName = "immich-db";
|
||||
# };
|
||||
|
||||
lab = {
|
||||
longhornVolumes = {
|
||||
hedgedoc-uploads.storage = "50Mi";
|
||||
hedgedoc-db.storage = "100Mi";
|
||||
freshrss.storage = "400Mi";
|
||||
radicale.storage = "200Mi";
|
||||
minecraft.storage = "1Gi";
|
||||
nextcloud.storage = "50Gi";
|
||||
nextcloud-db.storage = "400Mi";
|
||||
pihole-data.storage = "750Mi";
|
||||
pihole-dnsmasq.storage = "16Mi";
|
||||
forgejo.storage = "20Gi";
|
||||
kitchenowl.storage = "100Mi";
|
||||
syncthing.storage = "400Mi";
|
||||
paperless-data.storage = "10Gi";
|
||||
paperless-redisdata.storage = "20Mi";
|
||||
paperless-db.storage = "150Mi";
|
||||
jellyfin.storage = "5Gi";
|
||||
transmission.storage = "25Mi";
|
||||
jellyseerr.storage = "75Mi";
|
||||
radarr.storage = "300Mi";
|
||||
prowlarr.storage = "150Mi";
|
||||
sonarr.storage = "150Mi";
|
||||
bazarr.storage = "25Mi";
|
||||
attic.storage = "15Gi";
|
||||
attic-db.storage = "150Mi";
|
||||
atuin.storage = "600Mi";
|
||||
atuin-db.storage = "100Mi";
|
||||
immich.storage = "50Gi";
|
||||
immich-db.storage = "5Gi";
|
||||
};
|
||||
|
||||
nfsVolumes = {
|
||||
media.path = "media";
|
||||
music.path = "media/music";
|
||||
};
|
||||
};
|
||||
}
|
13
machines/atlas.nix
Normal file
13
machines/atlas.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
machines.atlas = {
|
||||
arch = "x86_64-linux";
|
||||
kubernetesNodeLabels.storageType = "slow";
|
||||
|
||||
nixosModule.lab = {
|
||||
k3s = {
|
||||
enable = true;
|
||||
serverAddr = "https://jefke.dmz:6443";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
facter.reportPath = ./facter.json;
|
||||
|
||||
lab = {
|
||||
storage.profile = "kubernetes";
|
||||
tailscale.enable = true;
|
||||
|
||||
k3s = {
|
||||
enable = true;
|
||||
serverAddr = "https://jefke.dmz:6443";
|
||||
};
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
40
machines/bird.conf
Normal file
40
machines/bird.conf
Normal file
|
@ -0,0 +1,40 @@
|
|||
log syslog all;
|
||||
debug protocols all;
|
||||
|
||||
router id 44.137.17.110;
|
||||
|
||||
protocol bgp hamgre {
|
||||
local as 4220401706;
|
||||
neighbor 44.137.61.33 as 4220406100;
|
||||
source address 44.137.61.34;
|
||||
multihop;
|
||||
ipv4 {
|
||||
import all;
|
||||
export none;
|
||||
};
|
||||
}
|
||||
|
||||
protocol device {
|
||||
}
|
||||
|
||||
protocol direct {
|
||||
interface "lo";
|
||||
ipv4 {
|
||||
};
|
||||
}
|
||||
|
||||
protocol kernel {
|
||||
metric 0;
|
||||
learn;
|
||||
ipv4 {
|
||||
import none;
|
||||
export all;
|
||||
};
|
||||
}
|
||||
|
||||
protocol static {
|
||||
route 44.137.17.96/28 via 44.137.61.33;
|
||||
ipv4 {
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,49 @@
|
|||
{...}: {
|
||||
machines = {
|
||||
lewis = import ./lewis;
|
||||
{ lib, ... }:
|
||||
let
|
||||
machineOpts = { config, ... }: {
|
||||
options = {
|
||||
arch = lib.mkOption {
|
||||
default = null;
|
||||
type = with lib.types; nullOr str;
|
||||
description = ''
|
||||
CPU architecture of this machine.
|
||||
'';
|
||||
};
|
||||
|
||||
isRaspberryPi = lib.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
|
||||
nixosModule = lib.mkOption {
|
||||
default = { ... }: { };
|
||||
type = lib.types.anything;
|
||||
description = ''
|
||||
Customized configuration for this machine in the form of a NixOS module.
|
||||
'';
|
||||
};
|
||||
|
||||
kubernetesNodeLabels = lib.mkOption {
|
||||
default = null;
|
||||
type = with lib.types; nullOr attrs;
|
||||
description = ''
|
||||
Any labels to add to the Kubernetes node.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./warwick.nix
|
||||
./atlas.nix
|
||||
./jefke.nix
|
||||
./lewis.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
machines = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule machineOpts);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
13
machines/jefke.nix
Normal file
13
machines/jefke.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
machines.jefke = {
|
||||
arch = "x86_64-linux";
|
||||
kubernetesNodeLabels.storageType = "fast";
|
||||
|
||||
nixosModule.lab = {
|
||||
k3s = {
|
||||
enable = true;
|
||||
clusterInit = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
facter.reportPath = ./facter.json;
|
||||
|
||||
lab = {
|
||||
storage.profile = "kubernetes";
|
||||
tailscale.enable = true;
|
||||
|
||||
k3s = {
|
||||
enable = true;
|
||||
clusterInit = true;
|
||||
};
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
21
machines/lewis.nix
Normal file
21
machines/lewis.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
machines.lewis = {
|
||||
arch = "x86_64-linux";
|
||||
kubernetesNodeLabels = {
|
||||
storageType = "fast";
|
||||
hasMedia = "true";
|
||||
};
|
||||
|
||||
nixosModule = {
|
||||
lab = {
|
||||
backups.enable = true;
|
||||
data-sharing.enable = true;
|
||||
|
||||
k3s = {
|
||||
enable = true;
|
||||
serverAddr = "https://jefke.dmz:6443";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
facter.reportPath = ./facter.json;
|
||||
|
||||
lab = {
|
||||
storage.profile = "kubernetes";
|
||||
backups.enable = true;
|
||||
data-sharing.enable = true;
|
||||
tailscale.enable = true;
|
||||
|
||||
k3s = {
|
||||
enable = true;
|
||||
serverAddr = "https://jefke.dmz:6443";
|
||||
};
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
56
machines/warwick.nix
Normal file
56
machines/warwick.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
machines.warwick = {
|
||||
arch = "aarch64-linux";
|
||||
isRaspberryPi = true;
|
||||
|
||||
nixosModule = {
|
||||
lab.monitoring.server.enable = true;
|
||||
|
||||
services.bird2 = {
|
||||
enable = false;
|
||||
config = builtins.readFile ./bird.conf;
|
||||
};
|
||||
|
||||
#systemd.network = {
|
||||
# netdevs = {
|
||||
# hamgre = {
|
||||
# netdevConfig = {
|
||||
# Name = "hamgre";
|
||||
# Kind = "gre";
|
||||
# MTUBytes = "1468";
|
||||
# };
|
||||
|
||||
# tunnelConfig = {
|
||||
# Remote = "145.220.78.4";
|
||||
# #Local = "192.145.57.90";
|
||||
# };
|
||||
# };
|
||||
|
||||
# # hambr = {
|
||||
# # netdevConfig = {
|
||||
# # Name = "hambr";
|
||||
# # Kind = "bridge";
|
||||
# # };
|
||||
# # };
|
||||
# };
|
||||
|
||||
# networks = {
|
||||
# "30-main-nic".networkConfig.Tunnel = "hamgre";
|
||||
|
||||
# "40-hamgre" = {
|
||||
# matchConfig.Name = "hamgre";
|
||||
|
||||
# networkConfig = {
|
||||
# Address = "44.137.61.34/30";
|
||||
# };
|
||||
# };
|
||||
|
||||
# # "40-hambr" = {
|
||||
# # matchConfig.Name = "hambr";
|
||||
|
||||
# # };
|
||||
# };
|
||||
#};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{inputs, ...}: {
|
||||
imports = [inputs.nixos-hardware.nixosModules.raspberry-pi-4];
|
||||
|
||||
config = {
|
||||
facter.reportPath = ./facter.json;
|
||||
|
||||
lab = {
|
||||
storage.profile = "pi";
|
||||
monitoring.server.enable = true;
|
||||
|
||||
tailscale = {
|
||||
advertiseExitNode = true;
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
imports = [inputs.nixos-facter-modules.nixosModules.facter];
|
||||
|
||||
options.facter.lab = {
|
||||
isRaspberryPi = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = config.facter.report.system == "aarch64-linux";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
machines,
|
||||
...
|
||||
}: let
|
||||
cfg = config.lab.monitoring;
|
||||
in {
|
||||
options = {
|
||||
lab.monitoring = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
|
||||
server.enable = lib.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts =
|
||||
[config.services.prometheus.exporters.node.port]
|
||||
++ lib.lists.optionals cfg.server.enable [80];
|
||||
|
||||
services.prometheus = {
|
||||
enable = cfg.server.enable;
|
||||
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
scrapeConfigs = lib.mkIf cfg.server.enable (
|
||||
let
|
||||
generated =
|
||||
lib.attrsets.mapAttrsToList
|
||||
(name: _module: {
|
||||
job_name = name;
|
||||
static_configs = [
|
||||
{
|
||||
targets = ["${name}.dmz:${toString config.services.prometheus.exporters.node.port}"];
|
||||
}
|
||||
];
|
||||
})
|
||||
machines;
|
||||
|
||||
pikvm = {
|
||||
job_name = "pikvm";
|
||||
metrics_path = "/api/export/prometheus/metrics";
|
||||
scheme = "https";
|
||||
tls_config.insecure_skip_verify = true;
|
||||
|
||||
# We don't care about security here, it's behind a VPN.
|
||||
basic_auth = {
|
||||
username = "admin";
|
||||
password = "admin";
|
||||
};
|
||||
|
||||
static_configs = [
|
||||
{
|
||||
targets = ["pikvm.dmz"];
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
generated ++ [pikvm]
|
||||
);
|
||||
};
|
||||
|
||||
services.nginx = lib.mkIf cfg.server.enable {
|
||||
enable = true;
|
||||
|
||||
virtualHosts."${config.networking.fqdn}" = {
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.prometheus.port}";
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.lab.storage;
|
||||
modules = [
|
||||
{
|
||||
config = lib.mkIf (cfg.profile == "pi") {
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/NIXOS_SD";
|
||||
fsType = "ext4";
|
||||
options = ["noatime"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
config = lib.mkIf (cfg.profile == "kubernetes") {
|
||||
disko.devices = {
|
||||
disk = {
|
||||
nvme = {
|
||||
device = "/dev/nvme0n1";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
type = "gpt";
|
||||
|
||||
partitions = {
|
||||
boot = {
|
||||
type = "EF00";
|
||||
size = "500M";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
|
||||
pv_os = {
|
||||
size = "79G";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_os";
|
||||
};
|
||||
};
|
||||
|
||||
pv_nvme_extra = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_data";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sata = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
type = "gpt";
|
||||
|
||||
partitions.pv_sata = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_data";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lvm_vg = {
|
||||
vg_os = {
|
||||
type = "lvm_vg";
|
||||
|
||||
lvs = {
|
||||
root = {
|
||||
size = "75G";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = ["defaults"];
|
||||
};
|
||||
};
|
||||
|
||||
swap = {
|
||||
size = "100%FREE";
|
||||
content.type = "swap";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
vg_data = {
|
||||
type = "lvm_vg";
|
||||
|
||||
lvs.longhorn = {
|
||||
size = "100%FREE";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "xfs";
|
||||
mountpoint = "/mnt/longhorn";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
config = lib.mkIf (cfg.profile == "normal") {
|
||||
disko.devices = {
|
||||
disk.sata = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
type = "gpt";
|
||||
|
||||
partitions = {
|
||||
boot = {
|
||||
type = "EF00";
|
||||
size = "500M";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
|
||||
root = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = ["defaults"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
in {
|
||||
imports = modules;
|
||||
|
||||
options.lab.storage = {
|
||||
profile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.lab.tailscale;
|
||||
in {
|
||||
options = {
|
||||
lab.tailscale = {
|
||||
enable = lib.mkEnableOption "tailscale";
|
||||
|
||||
advertiseExitNode = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
authKeyFile = config.sops.secrets."tailscale/authKey".path;
|
||||
useRoutingFeatures = "server";
|
||||
openFirewall = true;
|
||||
|
||||
extraUpFlags =
|
||||
[
|
||||
"--accept-dns=false"
|
||||
"--hostname=${config.networking.hostName}"
|
||||
]
|
||||
++ lib.lists.optional cfg.advertiseExitNode "--advertise-exit-node"
|
||||
++ lib.lists.optional cfg.advertiseExitNode "--advertise-routes=192.168.30.0/24";
|
||||
};
|
||||
|
||||
sops.secrets."tailscale/authKey" = {};
|
||||
|
||||
systemd.network.wait-online.ignoredInterfaces = ["tailscale0"];
|
||||
};
|
||||
}
|
4
my-lib/default.nix
Normal file
4
my-lib/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
lib: {
|
||||
net = import ./net.nix lib;
|
||||
globals = import ./globals.nix;
|
||||
}
|
14
my-lib/globals.nix
Normal file
14
my-lib/globals.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
routerPublicIPv4 = "192.145.57.90";
|
||||
routerPublicIPv6 = "2a0d:6e00:1a77::1";
|
||||
minecraftIPv4 = "192.168.30.136";
|
||||
dnsmasqIPv4 = "192.168.30.135";
|
||||
bind9IPv4 = "192.168.30.134";
|
||||
bind9Ipv6 = "2a0d:6e00:1a77:30::134";
|
||||
bittorrentIPv4 = "192.168.30.133";
|
||||
gitIPv4 = "192.168.30.132";
|
||||
piholeIPv4 = "192.168.30.131";
|
||||
inbucketIPv4 = "192.168.30.130";
|
||||
kmsIPv4 = "192.168.30.129";
|
||||
traefikIPv4 = "192.168.30.128";
|
||||
}
|
1323
my-lib/net.nix
Normal file
1323
my-lib/net.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,16 +1,12 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
cfg = config.lab.backups;
|
||||
|
||||
borgmaticConfig = pkgs.writeTextFile {
|
||||
name = "borgmatic-config.yaml";
|
||||
|
||||
text = lib.generators.toYAML {} {
|
||||
source_directories = ["/mnt/longhorn/persistent/longhorn-backup"];
|
||||
text = lib.generators.toYAML { } {
|
||||
source_directories = [ "/mnt/longhorn/persistent/longhorn-backup" ];
|
||||
|
||||
repositories = [
|
||||
{
|
||||
|
@ -31,7 +27,8 @@
|
|||
encryption_passcommand = "${pkgs.coreutils}/bin/cat ${config.sops.secrets."borg/borgPassphrase".path}";
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.lab.backups = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
|
@ -51,13 +48,13 @@ in {
|
|||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [borgbackup];
|
||||
environment.systemPackages = with pkgs; [ borgbackup ];
|
||||
# Converted from:
|
||||
# https://github.com/borgmatic-collective/borgmatic/tree/84823dfb912db650936e3492f6ead7e0e0d32a0f/sample/systemd
|
||||
systemd.services.borgmatic = {
|
||||
description = "borgmatic backup";
|
||||
wants = ["network-online.target"];
|
||||
after = ["network-online.target"];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
unitConfig.ConditionACPower = true;
|
||||
preStart = "${pkgs.coreutils}/bin/sleep 10s";
|
||||
|
||||
|
@ -78,7 +75,7 @@ in {
|
|||
|
||||
systemd.timers.borgmatic = {
|
||||
description = "Run borgmatic backup";
|
||||
wantedBy = ["timers.target"];
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "*-*-* 3:00:00";
|
||||
Persistent = true;
|
||||
|
@ -87,8 +84,8 @@ in {
|
|||
};
|
||||
|
||||
sops.secrets = {
|
||||
"borg/borgPassphrase" = {};
|
||||
"borg/borgbasePrivateKey" = {};
|
||||
"borg/borgPassphrase" = { };
|
||||
"borg/borgbasePrivateKey" = { };
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.lab.data-sharing;
|
||||
|
||||
nfsShares = [
|
||||
|
@ -16,12 +13,13 @@
|
|||
|
||||
nfsExports = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(
|
||||
share: "${share} 192.168.30.0/16(rw,sync,no_subtree_check,no_root_squash) 127.0.0.1/8(rw,sync,no_subtree_check,no_root_squash) 10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash)"
|
||||
(share:
|
||||
"${share} 192.168.30.0/16(rw,sync,no_subtree_check,no_root_squash) 127.0.0.1/8(rw,sync,no_subtree_check,no_root_squash)"
|
||||
)
|
||||
nfsShares
|
||||
);
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.lab.data-sharing = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
10
nixos-modules/default.nix
Normal file
10
nixos-modules/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
imports = [
|
||||
./storage.nix
|
||||
./backups.nix
|
||||
./networking
|
||||
./data-sharing.nix
|
||||
./monitoring
|
||||
./k3s
|
||||
];
|
||||
}
|
89
nixos-modules/globals.nix
Normal file
89
nixos-modules/globals.nix
Normal file
|
@ -0,0 +1,89 @@
|
|||
{ lib, ... }: {
|
||||
options.lab = {
|
||||
|
||||
networking = {
|
||||
public = {
|
||||
ipv4 = {
|
||||
router = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Public IPv4 address of the router.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
ipv6 = {
|
||||
router = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Publicly routable IPv6 address of the router.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dmz = {
|
||||
ipv4 = {
|
||||
prefixLength = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
IPv4 prefix length of DMZ network.
|
||||
'';
|
||||
};
|
||||
|
||||
dockerSwarm = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
IPv4 address of the Docker Swarm in the DMZ.
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
router = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The router's IPv4 address on the DMZ network.
|
||||
'';
|
||||
};
|
||||
|
||||
services = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The IPv4 address of the interface serving DHCP and DNS on the DMZ network.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
ipv6 = {
|
||||
prefixLength = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
IPv6 prefix length of DMZ network.
|
||||
'';
|
||||
};
|
||||
|
||||
dockerSwarm = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Globally routable IPv6 address of the Docker Swarm.
|
||||
'';
|
||||
};
|
||||
|
||||
router = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The router's IPv6 address on the DMZ network.
|
||||
'';
|
||||
};
|
||||
|
||||
services = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The IPv6 address of the interface serving DHCP and DNS on the DMZ network.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{kubenix, ...}: {
|
||||
imports = [kubenix.modules.k8s];
|
||||
{ kubenix, ... }: {
|
||||
imports = [ kubenix.modules.k8s ];
|
||||
kubernetes.resources.clusterRoleBindings.cluster-admins = {
|
||||
roleRef = {
|
||||
apiGroup = "rbac.authorization.k8s.io";
|
|
@ -1,12 +1,24 @@
|
|||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
{ self, inputs, pkgs, lib, config, ... }:
|
||||
let
|
||||
cfg = config.lab.k3s;
|
||||
in {
|
||||
|
||||
k3s-cni-plugins = pkgs.buildEnv {
|
||||
name = "k3s-cni-plugins";
|
||||
paths = with pkgs; [
|
||||
cni-plugins
|
||||
cni-plugin-flannel
|
||||
];
|
||||
};
|
||||
|
||||
image = pkgs.nix-snapshotter.buildImage {
|
||||
name = "redis";
|
||||
resolvedByNix = true;
|
||||
config = {
|
||||
entrypoint = [ "${pkgs.redis}/bin/redis-server" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.lab.k3s = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
|
@ -49,7 +61,6 @@ in {
|
|||
nfs-utils # Required for Longhorn
|
||||
];
|
||||
|
||||
# TODO!!!!!
|
||||
networking = {
|
||||
nftables.enable = lib.mkForce false;
|
||||
firewall.enable = lib.mkForce false;
|
||||
|
@ -66,15 +77,7 @@ in {
|
|||
address = "/run/nix-snapshotter/nix-snapshotter.sock";
|
||||
};
|
||||
|
||||
plugins = let
|
||||
k3s-cni-plugins = pkgs.buildEnv {
|
||||
name = "k3s-cni-plugins";
|
||||
paths = with pkgs; [
|
||||
cni-plugins
|
||||
cni-plugin-flannel
|
||||
];
|
||||
};
|
||||
in {
|
||||
plugins = {
|
||||
"io.containerd.grpc.v1.cri" = {
|
||||
stream_server_address = "127.0.0.1";
|
||||
stream_server_port = "10010";
|
||||
|
@ -93,12 +96,10 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
"io.containerd.transfer.v1.local".unpack_config = [
|
||||
{
|
||||
"io.containerd.transfer.v1.local".unpack_config = [{
|
||||
platform = "linux/amd64";
|
||||
snapshotter = "nix";
|
||||
}
|
||||
];
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -106,7 +107,8 @@ in {
|
|||
services = {
|
||||
nix-snapshotter.enable = true;
|
||||
|
||||
k3s = let
|
||||
k3s =
|
||||
let
|
||||
serverFlagList = [
|
||||
"--image-service-endpoint=unix:///run/nix-snapshotter/nix-snapshotter.sock"
|
||||
"--snapshotter=overlayfs"
|
||||
|
@ -118,7 +120,8 @@ in {
|
|||
];
|
||||
|
||||
serverFlags = builtins.concatStringsSep " " serverFlagList;
|
||||
in {
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
role = cfg.role;
|
||||
tokenFile = config.sops.secrets."k3s/serverToken".path;
|
||||
|
@ -141,26 +144,21 @@ in {
|
|||
"L+ /usr/local/bin - - - - /run/current-system/sw/bin/"
|
||||
];
|
||||
|
||||
system.activationScripts = {
|
||||
k3s-bootstrap = lib.mkIf (cfg.role == "server") {
|
||||
text = (
|
||||
system = lib.mkIf (cfg.role == "server") {
|
||||
activationScripts = {
|
||||
k3s-bootstrap.text = (
|
||||
let
|
||||
k3sBootstrapFile =
|
||||
(inputs.kubenix.evalModules.x86_64-linux {
|
||||
k3sBootstrapFile = (inputs.kubenix.evalModules.x86_64-linux {
|
||||
module = import ./bootstrap.nix;
|
||||
})
|
||||
.config
|
||||
.kubernetes
|
||||
.result;
|
||||
in ''
|
||||
}).config.kubernetes.result;
|
||||
in
|
||||
''
|
||||
mkdir -p /var/lib/rancher/k3s/server/manifests
|
||||
ln -sf ${k3sBootstrapFile} /var/lib/rancher/k3s/server/manifests/k3s-bootstrap.json
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
k3s-certs = lib.mkIf (cfg.role == "server") {
|
||||
text = ''
|
||||
k3s-certs.text = ''
|
||||
mkdir -p /var/lib/rancher/k3s/server/tls/etcd
|
||||
cp -f ${./k3s-ca/server-ca.crt} /var/lib/rancher/k3s/server/tls/server-ca.crt
|
||||
cp -f ${./k3s-ca/client-ca.crt} /var/lib/rancher/k3s/server/tls/client-ca.crt
|
||||
|
@ -168,13 +166,40 @@ in {
|
|||
cp -f ${./k3s-ca/etcd/peer-ca.crt} /var/lib/rancher/k3s/server/tls/etcd/peer-ca.crt
|
||||
cp -f ${./k3s-ca/etcd/server-ca.crt} /var/lib/rancher/k3s/server/tls/etcd/server-ca.crt
|
||||
'';
|
||||
|
||||
docker-images =
|
||||
let
|
||||
pulledImages = (import "${self}/container-images/pulled-images.nix") pkgs lib;
|
||||
basePath = "/var/docker_images";
|
||||
linesForImage = projectName: imageName: pulledImage:
|
||||
let
|
||||
projectPath = "${basePath}/${projectName}";
|
||||
in
|
||||
''
|
||||
mkdir -p ${projectPath}
|
||||
ln -sf ${pulledImage} ${projectPath}/${imageName}.tar
|
||||
'';
|
||||
linesForProject = projectName: project:
|
||||
let
|
||||
lines = lib.attrsets.mapAttrsToList (linesForImage projectName) project;
|
||||
in
|
||||
builtins.concatStringsSep "\n" lines;
|
||||
generateLines = projects:
|
||||
let
|
||||
lines = lib.attrsets.mapAttrsToList linesForProject projects;
|
||||
in
|
||||
builtins.concatStringsSep "\n" lines;
|
||||
in
|
||||
generateLines pulledImages;
|
||||
};
|
||||
};
|
||||
|
||||
sops.secrets = let
|
||||
sops.secrets =
|
||||
let
|
||||
keyPathBase = "/var/lib/rancher/k3s/server/tls";
|
||||
in {
|
||||
"k3s/serverToken" = {};
|
||||
in
|
||||
{
|
||||
"k3s/serverToken" = { };
|
||||
"k3s/keys/clientCAKey".path = "${keyPathBase}/client-ca.key";
|
||||
"k3s/keys/requestHeaderCAKey".path = "${keyPathBase}/request-header-ca.key";
|
||||
"k3s/keys/serverCAKey".path = "${keyPathBase}/server-ca.key";
|
57
nixos-modules/monitoring/default.nix
Normal file
57
nixos-modules/monitoring/default.nix
Normal file
|
@ -0,0 +1,57 @@
|
|||
{ lib, config, machines, ... }:
|
||||
let
|
||||
cfg = config.lab.monitoring;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lab.monitoring = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
|
||||
server.enable = lib.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts = [ config.services.prometheus.exporters.node.port ]
|
||||
++ lib.lists.optionals cfg.server.enable [ 80 ];
|
||||
|
||||
services.prometheus = {
|
||||
enable = cfg.server.enable;
|
||||
webExternalUrl = "/prometheus";
|
||||
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
scrapeConfigs = lib.mkIf cfg.server.enable (
|
||||
lib.attrsets.mapAttrsToList
|
||||
(name: machine: {
|
||||
job_name = name;
|
||||
static_configs = [{
|
||||
targets = [ "${name}.dmz:${toString config.services.prometheus.exporters.node.port}" ];
|
||||
}];
|
||||
})
|
||||
machines
|
||||
);
|
||||
};
|
||||
|
||||
services.nginx = lib.mkIf cfg.server.enable {
|
||||
enable = true;
|
||||
|
||||
virtualHosts."${config.networking.fqdn}" = {
|
||||
locations."/prometheus/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.prometheus.port}";
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,22 +1,20 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
{ lib, machine, ... }: {
|
||||
config = {
|
||||
networking = {
|
||||
domain = "dmz";
|
||||
nftables.enable = lib.mkDefault true;
|
||||
nftables.enable = true;
|
||||
useDHCP = false;
|
||||
|
||||
firewall.enable = lib.mkDefault true;
|
||||
firewall = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.network = {
|
||||
enable = true;
|
||||
|
||||
networks = lib.attrsets.mergeAttrsList [
|
||||
(lib.optionalAttrs (! config.facter.lab.isRaspberryPi) {
|
||||
(lib.optionalAttrs (! machine.isRaspberryPi) {
|
||||
"30-main-nic" = {
|
||||
matchConfig.Name = "en*";
|
||||
|
||||
|
@ -25,7 +23,7 @@
|
|||
};
|
||||
};
|
||||
})
|
||||
(lib.optionalAttrs config.facter.lab.isRaspberryPi {
|
||||
(lib.optionalAttrs machine.isRaspberryPi {
|
||||
"30-main-nic" = {
|
||||
matchConfig.Name = "end*";
|
||||
networkConfig = {
|
122
nixos-modules/storage.nix
Normal file
122
nixos-modules/storage.nix
Normal file
|
@ -0,0 +1,122 @@
|
|||
{ lib, config, machine, ... }:
|
||||
let cfg = config.lab.storage;
|
||||
in {
|
||||
options.lab.storage = {
|
||||
osDisk = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
description = ''
|
||||
The disk to be used for the machine's operating system.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
fileSystems."/" = lib.mkIf machine.isRaspberryPi {
|
||||
device = "/dev/disk/by-label/NIXOS_SD";
|
||||
fsType = "ext4";
|
||||
options = [ "noatime" ];
|
||||
};
|
||||
|
||||
disko = lib.mkIf (! machine.isRaspberryPi) {
|
||||
devices = {
|
||||
disk = {
|
||||
nvme = {
|
||||
device = "/dev/nvme0n1";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
type = "gpt";
|
||||
|
||||
partitions = {
|
||||
boot = {
|
||||
type = "EF00";
|
||||
size = "500M";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
|
||||
pv_os = {
|
||||
size = "79G";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_os";
|
||||
};
|
||||
};
|
||||
|
||||
pv_nvme_extra = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_data";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sata = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
|
||||
content = {
|
||||
type = "gpt";
|
||||
|
||||
partitions.pv_sata = {
|
||||
size = "100%";
|
||||
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg_data";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lvm_vg = {
|
||||
vg_os = {
|
||||
type = "lvm_vg";
|
||||
|
||||
lvs = {
|
||||
root = {
|
||||
size = "75G";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [ "defaults" ];
|
||||
};
|
||||
};
|
||||
|
||||
swap = {
|
||||
size = "100%FREE";
|
||||
content.type = "swap";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
vg_data = {
|
||||
type = "lvm_vg";
|
||||
|
||||
lvs.longhorn = {
|
||||
size = "100%FREE";
|
||||
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "xfs";
|
||||
mountpoint = "/mnt/longhorn";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue