mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
collect kube versions into a single file
This commit is contained in:
parent
f251d55857
commit
7fb2bf9578
10 changed files with 25023 additions and 16805 deletions
|
|
@ -9,7 +9,7 @@ This project uses [flakes](https://nixos.wiki/wiki/Flakes) so a development envi
|
|||
|
||||
nix develop
|
||||
|
||||
where you will find a [devshell](https://numtide.github.io/devshell) prompt (which supports [direnv](https://direnv.net/) so a one-time `direnv allow` at the base of the repo should automate the dev shell process).
|
||||
> **NOTE**: there's also support for [direnv](https://direnv.net/) to automate the dev shell process
|
||||
|
||||
## Commits
|
||||
|
||||
|
|
@ -23,15 +23,11 @@ Do try to format the repo with [treefmt](https://github.com/numtide/treefmt) bef
|
|||
|
||||
To support a new Kubernetes version:
|
||||
|
||||
- Edit [`./jobs/generators/default.nix`](./jobs/generators/default.nix) and add a block for the version under `k8s`; for example:
|
||||
- Edit [`./versions.nix`](./versions.nix) and add a new attribute for the version; for example:
|
||||
|
||||
```nix
|
||||
{
|
||||
name = "v1.23.nix";
|
||||
path = generateK8S "v1.23" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v1.23.0/api/openapi-spec/swagger.json";
|
||||
sha256 = "0jivg8nlxka1y7gzqpcxkmbvhcbxynyrxmjn0blky30q5064wx2a";
|
||||
});
|
||||
"1.23.0" = "sha256:0jivg8nlxka1y7gzqpcxkmbvhcbxynyrxmjn0blky30q5064wx2a";
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -40,9 +36,6 @@ To support a new Kubernetes version:
|
|||
nix build '.#jobs.x86_64-linux.generators.k8s'
|
||||
cp ./result/* modules/generated/
|
||||
|
||||
- Add the version in [`./modules/k8s.nix`](./modules/k8s.nix) under `options.kubernetes.version.type`
|
||||
- Add a new check in [`./flake.nix`](./flake.nix) (e.g., `tests-k8s-1_23`)
|
||||
|
||||
## Tests
|
||||
|
||||
Tests are executed through GitHub actions; see the [workflow definition](../kubenix/.github/workflows/ci.yml) for commands.
|
||||
|
|
|
|||
15
flake.nix
15
flake.nix
|
|
@ -118,15 +118,16 @@
|
|||
mkK8STests = attrs:
|
||||
(import ./tests {inherit evalModules;})
|
||||
({registry = "docker.io/gatehub";} // attrs);
|
||||
in {
|
||||
in
|
||||
{
|
||||
# TODO: access "success" derivation with nice testing utils for nice output
|
||||
nginx-example = wasSuccess (mkExamples {}).nginx-deployment.config.testing;
|
||||
tests-k8s-1_19 = wasSuccess (mkK8STests {k8sVersion = "1.19";});
|
||||
tests-k8s-1_20 = wasSuccess (mkK8STests {k8sVersion = "1.20";});
|
||||
tests-k8s-1_21 = wasSuccess (mkK8STests {k8sVersion = "1.21";});
|
||||
tests-k8s-1_23 = wasSuccess (mkK8STests {k8sVersion = "1.23";});
|
||||
tests-k8s-1_24 = wasSuccess (mkK8STests {k8sVersion = "1.24";});
|
||||
};
|
||||
}
|
||||
// builtins.listToAttrs (builtins.map (v: {
|
||||
name = "test-k8s-${builtins.replaceStrings ["."] ["_"] v}";
|
||||
value = wasSuccess (mkK8STests {k8sVersion = v;});
|
||||
})
|
||||
(import ./versions.nix).versions);
|
||||
}
|
||||
))
|
||||
// {
|
||||
|
|
|
|||
|
|
@ -26,43 +26,20 @@ in {
|
|||
}
|
||||
];
|
||||
|
||||
k8s = pkgs.linkFarm "k8s-generated" [
|
||||
{
|
||||
name = "v1.19.nix";
|
||||
path = generateK8S "v1.19" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v1.19.10/api/openapi-spec/swagger.json";
|
||||
sha256 = "sha256-ZXxonUAUxRK6rhTgK62ytTdDKCuOoWPwxJmktiKgcJc=";
|
||||
k8s = pkgs.linkFarm "k8s-generated" (
|
||||
builtins.attrValues (
|
||||
builtins.mapAttrs (
|
||||
version: sha: let
|
||||
short = builtins.concatStringsSep "." (lib.lists.sublist 0 2 (builtins.splitVersion version));
|
||||
in {
|
||||
name = "v${short}.nix";
|
||||
path = generateK8S "v${short}" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v${version}/api/openapi-spec/swagger.json";
|
||||
sha256 = sha;
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
name = "v1.20.nix";
|
||||
path = generateK8S "v1.20" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v1.20.6/api/openapi-spec/swagger.json";
|
||||
sha256 = "sha256-xzVOarQDSomHMimpt8H6MfpiQrLl9am2fDvk/GfLkDw=";
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
name = "v1.21.nix";
|
||||
path = generateK8S "v1.21" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v1.21.0/api/openapi-spec/swagger.json";
|
||||
sha256 = "sha256-EoqYTbtaTlzs7vneoNtXUmdnjTM/U+1gYwCiEy0lOcw=";
|
||||
});
|
||||
}
|
||||
{
|
||||
name = "v1.23.nix";
|
||||
path = generateK8S "v1.23" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v1.23.0/api/openapi-spec/swagger.json";
|
||||
sha256 = "sha256:0jivg8nlxka1y7gzqpcxkmbvhcbxynyrxmjn0blky30q5064wx2a";
|
||||
});
|
||||
}
|
||||
{
|
||||
name = "v1.24.nix";
|
||||
path = generateK8S "v1.24" (builtins.fetchurl {
|
||||
url = "https://github.com/kubernetes/kubernetes/raw/v1.24.0/api/openapi-spec/swagger.json";
|
||||
sha256 = "sha256:0fp5hbqk2q0imrfi4mwp1ia0bmn0xnl6hcr07y52q2cp41pmfhqd";
|
||||
});
|
||||
}
|
||||
];
|
||||
)
|
||||
(import ../../versions.nix).full
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -8,6 +8,7 @@
|
|||
...
|
||||
}:
|
||||
with lib; let
|
||||
versions = (import ../versions.nix).versions;
|
||||
cfg = config.kubernetes;
|
||||
|
||||
gvkKeyFn = type: "${type.group}/${type.version}/${type.kind}";
|
||||
|
|
@ -272,8 +273,8 @@ in {
|
|||
options.kubernetes = {
|
||||
version = mkOption {
|
||||
description = "Kubernetes version to use";
|
||||
type = types.enum ["1.19" "1.20" "1.21" "1.23" "1.24"];
|
||||
default = "1.24";
|
||||
type = types.enum versions;
|
||||
default = lib.lists.last versions;
|
||||
};
|
||||
|
||||
namespace = mkOption {
|
||||
|
|
|
|||
24
versions.nix
Normal file
24
versions.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
let
|
||||
full = {
|
||||
"1.19.10" = "sha256-ZXxonUAUxRK6rhTgK62ytTdDKCuOoWPwxJmktiKgcJc=";
|
||||
"1.20.6" = "sha256-xzVOarQDSomHMimpt8H6MfpiQrLl9am2fDvk/GfLkDw=";
|
||||
"1.21.0" = "sha256-EoqYTbtaTlzs7vneoNtXUmdnjTM/U+1gYwCiEy0lOcw=";
|
||||
"1.23.0" = "sha256:0jivg8nlxka1y7gzqpcxkmbvhcbxynyrxmjn0blky30q5064wx2a";
|
||||
"1.24.0" = "sha256:0fp5hbqk2q0imrfi4mwp1ia0bmn0xnl6hcr07y52q2cp41pmfhqd";
|
||||
};
|
||||
in {
|
||||
inherit full;
|
||||
# sorted list of major.minor version numbers
|
||||
# NOTE: avoiding pulling in lib here (not for any good reason)
|
||||
versions =
|
||||
map (v: let
|
||||
arr = builtins.splitVersion v;
|
||||
in (
|
||||
builtins.concatStringsSep "."
|
||||
[
|
||||
(builtins.elemAt arr 0)
|
||||
(builtins.elemAt arr 1)
|
||||
]
|
||||
))
|
||||
(builtins.attrNames full);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue