feat(legacy): refactor legacy kubenix support

This commit is contained in:
Jaka Hudoklin 2019-10-06 21:39:10 +02:00
parent a8dcc69d54
commit 9f05cd56b1
No known key found for this signature in database
GPG key ID: D1F18234B07BD6E2
8 changed files with 139 additions and 98 deletions

58
tests/k8s/legacy.nix Normal file
View file

@ -0,0 +1,58 @@
{ config, lib, kubenix, pkgs, k8sVersion, ... }:
with lib;
{
imports = with kubenix.modules; [ test k8s legacy ];
test = {
name = "k8s-legacy";
description = "Simple test tesing kubenix legacy support";
assertions = [];
};
kubernetes.version = k8sVersion;
kubernetes.moduleDefinitions.app.module = { config, k8s, ... }: {
options = {
replicas = mkOption {
description = "Number of replicas to run";
type = types.int;
default = 2;
};
};
config.kubernetes.defaults = {
all = [{
metadata.labels.default = "value";
}];
deployments = [{
metadata.labels.default2 = "value2";
} {
metadata.labels.default3 = "value3";
}];
};
config.kubernetes.resources.deployments.app = {
spec = {
replicas = config.replicas;
selector = {
matchLabels.app = "app";
};
template.spec = {
containers.app = {
image = "hello-world";
};
};
};
};
};
kubernetes.modules.myapp = {
module = "app";
namespace = "test";
configuration.replicas = 3;
};
}

View file

@ -1,33 +0,0 @@
{ config, lib, kubenix, pkgs, k8sVersion, ... }: {
imports = with kubenix.modules; [ test k8s v1.modules ];
test = {
name = "k8s-v1-modules";
description = "Simple test tesing CRD";
assertions = [];
};
kubernetes.version = k8sVersion;
kubernetes.moduleDefinitions.app.module = { config, k8s, ... }: {
kubernetes.resources.deployments.app = {
spec = {
replicas = 2;
selector = {
matchLabels.app = "app";
};
template.spec = {
containers.app = {
image = "hello-world";
};
};
};
};
};
kubernetes.modules.myapp = {
module = "app";
namespace = "test";
};
}