2019-03-12 20:33:56 +01:00
|
|
|
{ config, lib, kubenix, pkgs, k8sVersion, ... }:
|
2019-02-13 17:05:18 +01:00
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
cfg = config.kubernetes.api.customresourcedefinitions.crontabs;
|
|
|
|
|
in {
|
2019-03-07 23:23:07 +01:00
|
|
|
imports = with kubenix.modules; [ test k8s ];
|
2019-02-13 17:05:18 +01:00
|
|
|
|
|
|
|
|
test = {
|
2019-02-20 23:09:08 +01:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
2019-03-12 20:33:56 +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
|
|
|
}
|