Created
December 11, 2025 00:55
-
-
Save maxsei/79ab6de971add5d420fe562c01231525 to your computer and use it in GitHub Desktop.
kind is not kind on nixos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| config, | |
| lib, | |
| pkgs, | |
| modulesPath, | |
| ... | |
| }: | |
| { | |
| environment.systemPackages = with pkgs; [ | |
| kind | |
| podman | |
| kubectl | |
| ]; | |
| virtualisation.podman.enable = true; | |
| virtualisation.oci-containers = { | |
| containers = { | |
| kind = { | |
| image = "docker.io/kindest/node:v1.34.0@sha256:7416a61b42b1662ca6ca89f02028ac133a309a2a30ba309614e8ec94d976dc5a"; | |
| ports = [ | |
| "6443:6443" | |
| "30000-30100:30000-30100" | |
| ]; | |
| privileged = true; | |
| # volumes = [ | |
| # "/var/run/docker.sock:/var/run/docker.sock" | |
| # "/tmp/kind:/tmp/kind" | |
| # ]; | |
| extraOptions = [ | |
| "--name=kind-control-plane" | |
| ]; | |
| }; | |
| }; | |
| }; | |
| systemd.services.kind-setup = { | |
| description = "Create kind cluster after kind runtime starts"; | |
| after = [ "podman-kind.service" ]; | |
| requires = [ "podman-kind.service" ]; | |
| serviceConfig = | |
| let | |
| kind-config = (pkgs.formats.yaml { }).generate "kind-config.yaml" { | |
| kind = "Cluster"; | |
| apiVersion = "kind.x-k8s.io/v1alpha4"; | |
| nodes = [ | |
| { | |
| role = "control-plane"; | |
| extraPortMappings = [ | |
| { | |
| containerPort = 6443; | |
| hostPort = 6443; | |
| protocol = "TCP"; | |
| } | |
| { | |
| containerPort = 30080; | |
| hostPort = 30080; | |
| protocol = "TCP"; | |
| } | |
| ]; | |
| } | |
| { | |
| role = "worker"; | |
| } | |
| ]; | |
| networking.disableDefaultCNI = false; | |
| }; | |
| script = | |
| with pkgs; | |
| writeShellApplication { | |
| name = "script"; | |
| runtimeInputs = [ | |
| podman | |
| kind | |
| ]; | |
| text = '' | |
| export KIND_EXPERIMENTAL_PROVIDER=podman | |
| kind delete clusters --all | |
| kind create cluster --config ${kind-config} | |
| ''; | |
| }; | |
| in | |
| { | |
| Type = "oneshot"; | |
| ExecStart = "${script}/bin/script"; | |
| RemainAfterExit = true; | |
| }; | |
| wantedBy = [ "multi-user.target" ]; | |
| }; | |
| # networking.firewall.interfaces."enp4s0".allowedTCPPorts = [ | |
| # 6443 | |
| # ]; | |
| # networking.firewall.allowedTCPPorts = [ | |
| # 30080 | |
| # ]; | |
| networking.firewall.allowedTCPPorts = [ | |
| 30080 | |
| 6443 | |
| ]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment