mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
fmt
This commit is contained in:
parent
c3fa598922
commit
db6d83c61e
53 changed files with 1916 additions and 1599 deletions
|
|
@ -1,10 +1,10 @@
|
|||
{ config, lib, kubenix, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
latestCrontab = config.kubernetes.api.resources.cronTabs.latest;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = with kubenix.modules; [ test k8s ];
|
||||
|
||||
test = {
|
||||
|
|
@ -37,7 +37,8 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
} {
|
||||
}
|
||||
{
|
||||
group = "stable.example.com";
|
||||
version = "v2";
|
||||
kind = "CronTab";
|
||||
|
|
@ -56,7 +57,8 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
} {
|
||||
}
|
||||
{
|
||||
group = "stable.example.com";
|
||||
version = "v3";
|
||||
kind = "CronTab";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{ config, lib, kubenix, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
pod1 = config.kubernetes.api.resources.pods.pod1;
|
||||
pod2 = config.kubernetes.api.resources.pods.pod2;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = with kubenix.modules; [ test k8s ];
|
||||
|
||||
test = {
|
||||
|
|
@ -14,16 +14,18 @@ in {
|
|||
assertions = [{
|
||||
message = "Should have label set with resource";
|
||||
assertion = pod1.metadata.labels.resource-label == "value";
|
||||
} {
|
||||
message = "Should have default label set with group, version, kind";
|
||||
assertion = pod1.metadata.labels.gvk-label == "value";
|
||||
} {
|
||||
message = "Should have conditional annotation set";
|
||||
assertion = pod2.metadata.annotations.conditional-annotation == "value";
|
||||
}];
|
||||
}
|
||||
{
|
||||
message = "Should have default label set with group, version, kind";
|
||||
assertion = pod1.metadata.labels.gvk-label == "value";
|
||||
}
|
||||
{
|
||||
message = "Should have conditional annotation set";
|
||||
assertion = pod2.metadata.annotations.conditional-annotation == "value";
|
||||
}];
|
||||
};
|
||||
|
||||
kubernetes.resources.pods.pod1 = {};
|
||||
kubernetes.resources.pods.pod1 = { };
|
||||
|
||||
kubernetes.resources.pods.pod2 = {
|
||||
metadata.labels.custom-label = "value";
|
||||
|
|
@ -32,17 +34,19 @@ in {
|
|||
kubernetes.api.defaults = [{
|
||||
resource = "pods";
|
||||
default.metadata.labels.resource-label = "value";
|
||||
} {
|
||||
group = "core";
|
||||
kind = "Pod";
|
||||
version = "v1";
|
||||
default.metadata.labels.gvk-label = "value";
|
||||
} {
|
||||
resource = "pods";
|
||||
default = { config, ... }: {
|
||||
config.metadata.annotations = mkIf (config.metadata.labels ? "custom-label") {
|
||||
conditional-annotation = "value";
|
||||
}
|
||||
{
|
||||
group = "core";
|
||||
kind = "Pod";
|
||||
version = "v1";
|
||||
default.metadata.labels.gvk-label = "value";
|
||||
}
|
||||
{
|
||||
resource = "pods";
|
||||
default = { config, ... }: {
|
||||
config.metadata.annotations = mkIf (config.metadata.labels ? "custom-label") {
|
||||
conditional-annotation = "value";
|
||||
};
|
||||
};
|
||||
};
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{ config, lib, pkgs, kubenix, images, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.kubernetes.api.resources.deployments.nginx;
|
||||
image = images.nginx;
|
||||
|
|
@ -16,12 +15,13 @@ let
|
|||
spec.containers = [{
|
||||
name = "curl";
|
||||
image = config.docker.images.curl.path;
|
||||
args = ["curl" "--retry" "20" "--retry-connrefused" "http://nginx"];
|
||||
args = [ "curl" "--retry" "20" "--retry-connrefused" "http://nginx" ];
|
||||
}];
|
||||
spec.restartPolicy = "Never";
|
||||
});
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [ kubenix.modules.test kubenix.modules.k8s kubenix.modules.docker ];
|
||||
|
||||
test = {
|
||||
|
|
@ -35,13 +35,15 @@ in {
|
|||
else if ((builtins.compareVersions config.kubernetes.version "1.8") <= 0)
|
||||
then cfg.apiVersion == "apps/v1beta2"
|
||||
else cfg.apiVersion == "apps/v1";
|
||||
} {
|
||||
message = "should have corrent kind set";
|
||||
assertion = cfg.kind == "Deployment";
|
||||
} {
|
||||
message = "should have replicas set";
|
||||
assertion = cfg.spec.replicas == 3;
|
||||
}];
|
||||
}
|
||||
{
|
||||
message = "should have corrent kind set";
|
||||
assertion = cfg.kind == "Deployment";
|
||||
}
|
||||
{
|
||||
message = "should have replicas set";
|
||||
assertion = cfg.spec.replicas == 3;
|
||||
}];
|
||||
script = ''
|
||||
import time
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{ config, lib, kubenix, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
pod = config.kubernetes.api.resources.core.v1.Pod.test;
|
||||
deployment = config.kubernetes.api.resources.apps.v1.Deployment.nginx-deployment;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = with kubenix.modules; [ test k8s ];
|
||||
|
||||
test = {
|
||||
|
|
@ -15,10 +15,11 @@ in {
|
|||
assertions = [{
|
||||
message = "Pod should have name set";
|
||||
assertion = pod.metadata.name == "test";
|
||||
} {
|
||||
message = "Deployment should have name set";
|
||||
assertion = deployment.metadata.name == "nginx-deployment";
|
||||
}];
|
||||
}
|
||||
{
|
||||
message = "Deployment should have name set";
|
||||
assertion = deployment.metadata.name == "nginx-deployment";
|
||||
}];
|
||||
};
|
||||
|
||||
kubernetes.imports = [
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
{ config, lib, kubenix, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.kubernetes.api.resources.customResourceDefinitions.crontabs;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = with kubenix.modules; [ test k8s ];
|
||||
|
||||
test = {
|
||||
|
|
@ -34,7 +34,7 @@ in {
|
|||
plural = "crontabs";
|
||||
singular = "crontab";
|
||||
kind = "CronTab";
|
||||
shortNames = ["ct"];
|
||||
shortNames = [ "ct" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -55,7 +55,7 @@ in {
|
|||
};
|
||||
}];
|
||||
|
||||
kubernetes.resources.namespaces.test = {};
|
||||
kubernetes.resources.namespaces.test = { };
|
||||
|
||||
kubernetes.resources."stable.example.com"."v1".CronTab.crontab.spec.schedule = "* * * * *";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{ config, kubenix, ... }:
|
||||
|
||||
let
|
||||
cfg = config.kubernetes.api.resources.pods.nginx;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [ kubenix.modules.test kubenix.modules.k8s ];
|
||||
|
||||
test = {
|
||||
|
|
@ -11,11 +11,12 @@ in {
|
|||
assertions = [{
|
||||
message = "should have apiVersion and kind set";
|
||||
assertion = cfg.apiVersion == "v1" && cfg.kind == "Pod";
|
||||
} {
|
||||
message = "should have name set";
|
||||
assertion = cfg.metadata.name == "nginx";
|
||||
}];
|
||||
}
|
||||
{
|
||||
message = "should have name set";
|
||||
assertion = cfg.metadata.name == "nginx";
|
||||
}];
|
||||
};
|
||||
|
||||
kubernetes.resources.pods.nginx = {};
|
||||
kubernetes.resources.pods.nginx = { };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
{ name, config, lib, kubenix, images, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.submodules.instances.passthru;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = with kubenix.modules; [ test submodules k8s docker ];
|
||||
|
||||
test = {
|
||||
|
|
@ -13,16 +13,17 @@ in {
|
|||
assertions = [{
|
||||
message = "Submodule has correct name set";
|
||||
assertion = (head config.kubernetes.objects).metadata.name == "passthru";
|
||||
} {
|
||||
message = "Should expose docker image";
|
||||
assertion = (head config.docker.export).imageName == "xtruder/nginx";
|
||||
}];
|
||||
}
|
||||
{
|
||||
message = "Should expose docker image";
|
||||
assertion = (head config.docker.export).imageName == "xtruder/nginx";
|
||||
}];
|
||||
};
|
||||
|
||||
kubernetes.namespace = "test-namespace";
|
||||
|
||||
submodules.imports = [{
|
||||
module = {name, config, ...}: {
|
||||
module = { name, config, ... }: {
|
||||
imports = with kubenix.modules; [ submodule k8s docker ];
|
||||
|
||||
config = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue