Skip to content

Commit 3f6c007

Browse files
committed
fix: revert to k3s
1 parent 1b90e30 commit 3f6c007

19 files changed

+96
-175
lines changed

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@ bootstrap-aarch64-linux:
1818

1919
bootstrap-x86_64-linux:
2020
@VARIANT=builder-x86 $(BUILDER_EXEC) echo "Started x86 environment"
21-
@echo "Waiting builder to"
21+
@echo "Waiting builder to start..."
2222
@sleep 15
2323

2424
bootstrap: bootstrap-$(SYSTEM)
2525

2626
nixos-local: bootstrap build
2727

2828
build:
29-
@nix build .#nixosConfigurations.default --system $(SYSTEM)
29+
@nix build .#nixosConfigurations.initial.config.formats.qcow --system $(SYSTEM)
3030

3131
TERRAGRUNT_FILES:=$(shell find terragrunt -type d -name '.*' -prune -o -name 'terragrunt.hcl' -exec dirname {} \;)
3232

3333
$(TERRAGRUNT_FILES):
34-
@sudo chmod -fR 755 $@/.terragrunt-cache/ && sudo chmod -fR 755 result
3534
@cd $@ && terragrunt $(TF_CMD)
3635

3736
release-stable:

flake.lock

+27-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+7-18
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
inputs.nixpkgs.follows = "srvos/nixpkgs";
2525
};
2626

27-
rke2 = {
28-
url = "github:numtide/nixos-rke2";
29-
inputs.nixpkgs.follows = "nixpkgs";
30-
};
31-
3227
# Flake utilities
3328
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
3429
flake-utils.url = "github:numtide/flake-utils";
@@ -90,13 +85,14 @@
9085
});
9186

9287
nixosModules = {
93-
rke2 = inputs.rke2.nixosModules.default;
9488
sops = inputs.sops-nix.nixosModules.sops;
9589
common = srvos.nixosModules.common;
9690
server = srvos.nixosModules.server;
9791
home-manager = inputs.home-manager.nixosModules.home-manager;
9892
os = ./nixos/configuration.nix;
9993
config = ./nixos-options/default.nix;
94+
qcowCompressed = ./nixos/qcow-compressed.nix;
95+
allFormats = nixos-generators.nixosModules.all-formats;
10096
};
10197

10298
nixosAllModules = rec {
@@ -142,26 +138,19 @@
142138
// flake-utils.lib.eachDefaultSystem (baseSystem:
143139
{
144140
packages.nixosConfigurations = let
145-
system = builtins.replaceStrings ["darwin"] ["linux"] baseSystem;
141+
rebuildSystem = (builtins.getEnv "NIXOS_REBUILD_SYSTEM");
142+
system = if rebuildSystem != "" then rebuildSystem else "x86_64-linux";
146143
oldLegacyPackages = import inputs.nixpkgs-legacy (nixpkgsDefaults // { inherit system; });
147144
specialArgs = {
148145
inherit oldLegacyPackages;
149146
};
150-
qcowSystemFormat = [
151-
({ ... }: {
152-
imports = [
153-
nixos-generators.nixosModules.all-formats
154-
./nixos/qcow-compressed.nix
155-
];
156-
nixpkgs.hostPlatform = system;
157-
})
158-
];
147+
159148
in {
160149
## Libvirt configurations
161150

162151
initial = nixosSystem {
163152
inherit system specialArgs;
164-
modules = qcowSystemFormat ++ self.nixosAllModules.default;
153+
modules = self.nixosAllModules.default;
165154
};
166155

167156
deploy = nixosSystem {
@@ -173,7 +162,7 @@
173162

174163
initial-contabo = nixosSystem {
175164
inherit system specialArgs;
176-
modules = qcowSystemFormat ++ self.nixosAllModules.contabo;
165+
modules = self.nixosAllModules.contabo;
177166
};
178167

179168
deploy-contabo = nixosSystem {

nixos-darwin/configuration-x86.nix

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
pkgs, lib, ...
33
}: {
4+
nix.settings.extra-platforms = [ "x86_64-linux" ];
45
nix.linux-builder = {
56
package = pkgs.darwin.linux-builder-x86_64;
67
ephemeral = lib.mkDefault true;

nixos-darwin/configuration.nix

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ with config.k3s-paas;
100100
keep-outputs = false;
101101
# https://github.com/NixOS/nix/issues/7273
102102
auto-optimise-store = false;
103+
extra-platforms = [ "x86_64-linux" ];
103104
};
104105
nix.gc = {
105106
automatic = true;

nixos-options/default.nix

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919

2020
dns.dest-ips = lib.mkOption {
2121
default = [
22-
"127.0.0.1" "192.168.205.2" "192.168.205.3"
23-
"192.168.205.4" "192.168.205.5" "192.168.205.6"
24-
"192.168.205.7" "192.168.205.8" "192.168.205.9"
22+
"127.0.0.1" "192.168.205.2" "192.168.205.3" "192.168.205.4" "192.168.205.5"
23+
"192.168.205.6" "192.168.205.7" "192.168.205.8" "192.168.205.9"
2524
];
2625
type = lib.types.listOf lib.types.str;
2726
description = "Target IP address for dns.name (only in local dev)";
@@ -46,7 +45,7 @@
4645
};
4746

4847
k3s.disableServices = lib.mkOption {
49-
default = ["traefik" "rke2-ingress-nginx" "servicelb" ];
48+
default = ["traefik" "servicelb" ];
5049
type = lib.types.listOf lib.types.str;
5150
description = "Disable k8s services eg: traefik,servicelb";
5251
};

nixos/configuration.nix

+30-6
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,40 @@ in {
101101
'';
102102
};
103103

104-
systemd.services.numtide-rke2.serviceConfig.Environment = "PATH=${pkgs.tailscale}/bin:${pkgs.coreutils}/bin";
105-
services.numtide-rke2 = {
104+
systemd.services.k3s.serviceConfig.Environment = "PATH=${pkgs.tailscale}/bin:${pkgs.coreutils}/bin";
105+
services.k3s = {
106106
enable = lib.mkDefault false;
107107
role = "server";
108-
extraFlags = (
109-
builtins.concatMap (service: ["--disable" service]) k3s.disableServices
108+
package = k3sPkg;
109+
extraFlags = lib.strings.concatStringsSep " " (
110+
map (service: "--disable=${service}") k3s.disableServices
110111
++ k3s.serverExtraArgs
112+
++ [
113+
"--flannel-backend=none"
114+
"--disable-kube-proxy"
115+
"--disable-network-policy"
116+
"--egress-selector-mode=disabled"
117+
]
111118
);
112-
};
119+
# manifests = {
120+
# certManager = {
121+
# name = "cert-manager";
122+
# namespace = certManagerNamespace;
123+
# createNamespace = true;
124+
# repository = "https://charts.jetstack.io";
125+
# chart = "cert-manager";
126+
# version = "1.15.2";
127+
# waitForJobs = true;
128+
# atomic = true;
129+
# timeout = 120;
113130

131+
# values = ''
132+
# crds:
133+
# enabled = true
134+
# '';
135+
# };
136+
# };
137+
};
114138
services.fail2ban.enable = true;
115139

116140
security.pki.certificateFiles = certs;
@@ -121,7 +145,7 @@ in {
121145
xdg.enable = true;
122146
home.stateVersion = "24.05";
123147
home.sessionVariables = {
124-
KUBECONFIG = "/etc/rancher/rke2/rke2.yaml";
148+
KUBECONFIG = "/etc/rancher/k3s/k3s.yaml";
125149
};
126150
home.shellAliases = {
127151
kubectl = "sudo -E kubectl";

0 commit comments

Comments
 (0)