kube bootstrap manifests

This commit is contained in:
Evan Reichard 2025-01-25 14:17:40 -05:00
parent 1f91305b6e
commit 1002e1cbe2
7 changed files with 91 additions and 8 deletions

View File

@ -10,7 +10,7 @@ scp -r * nixos@10.10.10.10:/tmp/
```bash ```bash
# Validate Disk # Validate Disk
sudo fdisk -l ls -l /dev/disk/by-id
# Partition Disk # Partition Disk
sudo nix \ sudo nix \

View File

@ -15,6 +15,7 @@
./hosts/llama-server.nix ./hosts/llama-server.nix
{ {
networking.hostName = "lin-va-llama1"; networking.hostName = "lin-va-llama1";
disko.devices.disk.main.device = "/dev/sda";
} }
]; ];
}; };
@ -27,6 +28,7 @@
./hosts/k3s.nix ./hosts/k3s.nix
{ {
networking.hostName = "lin-va-k3s1"; networking.hostName = "lin-va-k3s1";
disko.devices.disk.main.device = "/dev/sda";
} }
]; ];
}; };
@ -39,6 +41,8 @@
./hosts/rke2.nix ./hosts/rke2.nix
{ {
networking.hostName = "lin-va-rke1"; networking.hostName = "lin-va-rke1";
disko.devices.disk.main.device = "/dev/nvme0n1";
k8s.diskPoolID = "/dev/disk/by-id/ata-INTEL_SSDSC2BW240A4_CVDA418201Z42403GN";
} }
]; ];
}; };

View File

@ -16,9 +16,8 @@
# Disk Configuration # Disk Configuration
disko.devices = { disko.devices = {
disk = { disk = {
sda = { main = {
type = "disk"; type = "disk";
device = "/dev/sda";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {

View File

@ -58,9 +58,8 @@ in
# Disk Configuration # Disk Configuration
disko.devices = { disko.devices = {
disk = { disk = {
sda = { main = {
type = "disk"; type = "disk";
device = "/dev/sda";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {

View File

@ -1,6 +1,11 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [
../k8s
];
k8s.manifestsDir = "/var/lib/rancher/rke2/server/manifests";
# Enable Flakes # Enable Flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];
@ -16,9 +21,8 @@
# Disk Configuration # Disk Configuration
disko.devices = { disko.devices = {
disk = { disk = {
nvme0n1 = { main = {
type = "disk"; type = "disk";
device = "/dev/nvme0n1";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@ -79,7 +83,17 @@
enable = true; enable = true;
disable = [ disable = [
# Utilize Traefik
"rke2-ingress-nginx" "rke2-ingress-nginx"
# Utilize OpenEBS's Snapshot Controller
"rke2-snapshot-controller"
"rke2-snapshot-controller-crd"
"rke2-snapshot-validation-webhook"
];
nodeLabel = [
"openebs.io/engine=mayastor"
]; ];
# ------------------- # -------------------
@ -96,7 +110,6 @@
# agentTokenFile = ""; # agentTokenFile = "";
}; };
# Enable SSH Server # Enable SSH Server
services.openssh = { services.openssh = {
enable = true; enable = true;

39
k8s/config/openebs.yaml Normal file
View File

@ -0,0 +1,39 @@
---
apiVersion: v1
kind: Namespace
metadata:
labels:
name: openebs
name: openebs
---
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: openebs
namespace: kube-system
spec:
repo: https://openebs.github.io/openebs
chart: openebs
targetNamespace: openebs
valuesContent: |-
mayastor:
etcd:
replicaCount: 1
engines:
local:
lvm:
enabled: false
zfs:
enabled: false
replicated:
mayastor:
enabled: true
---
apiVersion: "openebs.io/v1beta2"
kind: DiskPool
metadata:
name: pool-on-@nodeName@
namespace: openebs
spec:
node: @nodeName@
disks: ["aio://@diskPoolID@"]

29
k8s/default.nix Normal file
View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
{
options.k8s = {
diskPoolID = lib.mkOption {
type = lib.types.str;
description = "Disk Pool ID for OpenEBS";
};
manifestsDir = lib.mkOption {
type = lib.types.path;
description = "Directory for Kubernetes manifests";
};
};
config = {
system.activationScripts.k8s-manifests = {
deps = [ ];
text = ''
mkdir -p ${config.k8s.manifestsDir}
cp ${pkgs.substituteAll {
src = ./config/openebs.yaml;
nodeName = config.networking.hostName;
diskPoolID = config.k8s.diskPoolID;
}} ${config.k8s.manifestsDir}/openebs.yaml
'';
};
};
}