kubenix/tests/k8s/crd.nix

58 lines
1.5 KiB
Nix
Raw Normal View History

{ config, lib, kubenix, pkgs, k8sVersion, ... }:
2019-02-13 17:05:18 +01:00
with lib;
let
cfg = config.kubernetes.api.customresourcedefinitions.crontabs;
in {
imports = with kubenix.modules; [ test k8s ];
2019-02-13 17:05:18 +01:00
test = {
name = "k8s-crd";
2019-02-13 17:05:18 +01:00
description = "Simple test tesing CRD";
2019-02-16 14:02:13 +01:00
enable = builtins.compareVersions config.kubernetes.version "1.8" >= 0;
2019-02-13 17:05:18 +01:00
assertions = [{
message = "should have group set";
assertion = cfg.spec.group == "stable.example.com";
}];
2019-02-25 17:16:24 +01:00
testScript = ''
2019-02-20 09:34:15 +01:00
$kube->waitUntilSucceeds("kubectl apply -f ${toYAML config.kubernetes.generated}");
$kube->succeed("kubectl get crds | grep -i crontabs");
$kube->succeed("kubectl get crontabs | grep -i crontab");
'';
2019-02-13 17:05:18 +01:00
};
kubernetes.version = k8sVersion;
2019-02-13 17:05:18 +01:00
kubernetes.api.customresourcedefinitions.crontabs = {
metadata.name = "crontabs.stable.example.com";
spec = {
group = "stable.example.com";
version = "v1";
scope = "Namespaced";
names = {
plural = "crontabs";
singular = "crontab";
kind = "CronTab";
shortNames = ["ct"];
};
};
};
2019-02-20 09:34:15 +01:00
kubernetes.customResources = [{
group = "stable.example.com";
version = "v1";
kind = "CronTab";
2019-02-26 21:22:03 +01:00
resource = "crontabs";
2019-02-20 09:34:15 +01:00
description = "CronTabs resources";
module = {
options.schedule = mkOption {
description = "Crontab schedule script";
type = types.str;
};
};
}];
kubernetes.api."stable.example.com"."v1".CronTab.crontab.spec.schedule = "* * * * *";
2019-02-13 17:05:18 +01:00
}