diff --git a/README.md b/README.md index 2b71292..d9e9414 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ scp -r * nixos@10.10.10.10:/tmp/ ```bash # Validate Disk -sudo fdisk -l +ls -l /dev/disk/by-id # Partition Disk sudo nix \ diff --git a/flake.nix b/flake.nix index 20ab350..d95044d 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,7 @@ ./hosts/llama-server.nix { networking.hostName = "lin-va-llama1"; + disko.devices.disk.main.device = "/dev/sda"; } ]; }; @@ -27,6 +28,7 @@ ./hosts/k3s.nix { networking.hostName = "lin-va-k3s1"; + disko.devices.disk.main.device = "/dev/sda"; } ]; }; @@ -39,6 +41,8 @@ ./hosts/rke2.nix { networking.hostName = "lin-va-rke1"; + disko.devices.disk.main.device = "/dev/nvme0n1"; + k8s.diskPoolID = "/dev/disk/by-id/ata-INTEL_SSDSC2BW240A4_CVDA418201Z42403GN"; } ]; }; diff --git a/hosts/k3s.nix b/hosts/k3s.nix index f1a1e01..21c66ab 100644 --- a/hosts/k3s.nix +++ b/hosts/k3s.nix @@ -16,9 +16,8 @@ # Disk Configuration disko.devices = { disk = { - sda = { + main = { type = "disk"; - device = "/dev/sda"; content = { type = "gpt"; partitions = { diff --git a/hosts/llama-server.nix b/hosts/llama-server.nix index 59d5c94..7342412 100644 --- a/hosts/llama-server.nix +++ b/hosts/llama-server.nix @@ -58,9 +58,8 @@ in # Disk Configuration disko.devices = { disk = { - sda = { + main = { type = "disk"; - device = "/dev/sda"; content = { type = "gpt"; partitions = { diff --git a/hosts/rke2.nix b/hosts/rke2.nix index fe57692..ee26d54 100644 --- a/hosts/rke2.nix +++ b/hosts/rke2.nix @@ -1,6 +1,11 @@ { config, pkgs, ... }: { + imports = [ + ../k8s + ]; + k8s.manifestsDir = "/var/lib/rancher/rke2/server/manifests"; + # Enable Flakes nix.settings.experimental-features = [ "nix-command" "flakes" ]; @@ -16,9 +21,8 @@ # Disk Configuration disko.devices = { disk = { - nvme0n1 = { + main = { type = "disk"; - device = "/dev/nvme0n1"; content = { type = "gpt"; partitions = { @@ -79,7 +83,17 @@ enable = true; disable = [ + # Utilize Traefik "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 = ""; }; - # Enable SSH Server services.openssh = { enable = true; diff --git a/k8s/config/openebs.yaml b/k8s/config/openebs.yaml new file mode 100644 index 0000000..2db8407 --- /dev/null +++ b/k8s/config/openebs.yaml @@ -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@"] diff --git a/k8s/default.nix b/k8s/default.nix new file mode 100644 index 0000000..ba63255 --- /dev/null +++ b/k8s/default.nix @@ -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 + ''; + }; + }; +}