Skip to content
Snippets Groups Projects
Verified Commit c3a97ff0 authored by Peer Wipprecht's avatar Peer Wipprecht
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
result
### Instructions
To generate the Kubernetes YAML manifests run `nix run .#nixidy -- switch .#dev`.
{
nixidy.target = {
repository = "https://code.fbi.h-da.de/peer.wipprecht/2425WS_kubernetes_nixidy.git";
branch = "main";
rootPath = "./manifests";
};
}
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"kubenix": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixidy",
"nixpkgs"
],
"systems": "systems_3",
"treefmt": "treefmt"
},
"locked": {
"lastModified": 1718110643,
"narHash": "sha256-KrEOCx/bpN++sySOEL5EO5AhYsqRZZk+CXacueUeSl4=",
"owner": "hall",
"repo": "kubenix",
"rev": "a04066c45526c6d8410ba998134f692ff991b4f3",
"type": "github"
},
"original": {
"owner": "hall",
"repo": "kubenix",
"type": "github"
}
},
"nix-kube-generators": {
"locked": {
"lastModified": 1729269463,
"narHash": "sha256-8jDDpC99fYl5CSHjZyPwb5PK7nQSknhkpfe8+DXI910=",
"owner": "farcaller",
"repo": "nix-kube-generators",
"rev": "2be4f3cb99e179d9f94e6c8723862421437f8efb",
"type": "github"
},
"original": {
"owner": "farcaller",
"repo": "nix-kube-generators",
"type": "github"
}
},
"nixidy": {
"inputs": {
"flake-utils": "flake-utils_2",
"kubenix": "kubenix",
"nix-kube-generators": "nix-kube-generators",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1740741867,
"narHash": "sha256-46tlBRJoQD5CdSYA2pQLPXkw+nwGynZfBGN/LmftpOU=",
"owner": "arnarg",
"repo": "nixidy",
"rev": "a2ba79112187a6e7b1a5b4ca41bb30a8ef9c5a65",
"type": "github"
},
"original": {
"owner": "arnarg",
"repo": "nixidy",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1742069588,
"narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixidy": "nixidy",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"id": "systems",
"type": "indirect"
}
},
"treefmt": {
"inputs": {
"nixpkgs": [
"nixidy",
"kubenix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688026376,
"narHash": "sha256-qJmkr9BWDpqblk4E9/rCsAEl39y2n4Ycw6KRopvpUcY=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "df3f32b0cc253dfc7009b7317e8f0e7ccd70b1cf",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixidy = {
url = "github:arnarg/nixidy";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
flake-utils,
nixidy,
nixpkgs,
self,
}: (flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {
nixidyEnvs.dev = nixidy.lib.mkEnv {
inherit pkgs;
modules = [
./configuration.nix
./modules
];
};
packages.nixidy = nixidy.packages.${system}.default;
devShells.default = pkgs.mkShell {
buildInputs = [nixidy.packages.${system}.default];
};
}));
}
{...}: let
readinessProbe = {
httpGet = {
path = "/";
port = 80;
};
initialDelaySeconds = 3;
periodSeconds = 5;
};
in {
imports = [
./myapp
];
myapp.instances = {
"a" = {};
"b" = {
deployments.myapp.spec = {
replicas = 3;
template.spec.containers.whoami = {
imagePullPolicy = "Always";
inherit readinessProbe;
};
};
configMaps.myapp.data = {
"LOG_LEVEL" = "info";
"FEATURE_FLAGS" = "new-ui=true,beta-features=false";
"CACHE_SIZE" = "1024m";
};
};
"c" = {
deployments.myapp.spec = {
replicas = 5;
template.spec.containers.whoami = {
imagePullPolicy = "IfNotPresent";
};
};
configMaps.myapp.data = {
"LOG_LEVEL" = "warn";
"FEATURE_FLAGS" = "new-ui=false,beta-features=false";
"CACHE_SIZE" = "4096m";
};
};
};
}
{
config,
lib,
...
}: let
cfg = config.myapp;
in {
options.myapp = with lib; {
instances = mkOption {
type = types.attrsOf types.attrs;
default = {};
};
};
config = {
applications =
lib.mapAttrs (namespace: overrides: {
inherit namespace;
createNamespace = true;
resources = let
labels = {
"app" = "whoami";
"environment" = namespace;
};
defaultConfig = {
deployments.myapp.spec = {
replicas = 2;
selector.matchLabels = labels;
template = {
metadata.labels = labels;
spec = {
containers.whoami = {
image = "traefik/whoami:latest";
imagePullPolicy = "Always";
args = [
"--name=whoami-${namespace}"
];
resources = {
requests = {
memory = "64Mi";
cpu = "50m";
};
limits = {
memory = "128Mi";
cpu = "100m";
};
};
envFrom = [
{
configMapRef.name = "app-config";
}
];
};
};
};
};
configMaps.myapp.data = {
"WHOAMI_PORT_NUMBER" = "80";
"LOG_LEVEL" = "debug";
"FEATURE_FLAGS" = "new-ui=true,beta-features=true";
"CACHE_SIZE" = "512m";
};
services.myapp = {
spec = {
selector = labels;
ports.http = {
port = 80;
targetPort = 80;
};
};
};
};
in
lib.recursiveUpdate defaultConfig overrides;
})
cfg.instances;
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment