mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
feat(modules/docker): improvements
This commit is contained in:
parent
fbaed4ec00
commit
a6cea15f34
3 changed files with 25 additions and 9 deletions
|
|
@ -64,8 +64,8 @@ in {
|
||||||
submodule.config.kubernetes.objects
|
submodule.config.kubernetes.objects
|
||||||
) config.submodules.instances);
|
) config.submodules.instances);
|
||||||
|
|
||||||
docker.push = mkMerge (mapAttrsToList (_: submodule:
|
docker.export = mkMerge (mapAttrsToList (_: submodule:
|
||||||
submodule.config.docker.push
|
submodule.config.docker.export
|
||||||
) config.submodules.instances);
|
) config.submodules.instances);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,13 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
{
|
let
|
||||||
|
globalConfig = config;
|
||||||
|
in {
|
||||||
options.docker.registry.url = mkOption {
|
options.docker.registry.url = mkOption {
|
||||||
description = "Default registry url where images are published";
|
description = "Default registry url where images are published";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
default = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
options.docker.images = mkOption {
|
options.docker.images = mkOption {
|
||||||
|
|
@ -33,19 +36,28 @@ with lib;
|
||||||
registry = mkOption {
|
registry = mkOption {
|
||||||
description = "Docker registry url where image is published";
|
description = "Docker registry url where image is published";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = config.docker.registry.url;
|
default = globalConfig.docker.registry.url;
|
||||||
|
};
|
||||||
|
|
||||||
|
path = mkOption {
|
||||||
|
description = "Full docker image path";
|
||||||
|
type = types.str;
|
||||||
|
default =
|
||||||
|
if config.registry != ""
|
||||||
|
then "${config.registry}/${config.name}:${config.tag}"
|
||||||
|
else "${config.name}:${config.tag}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
options.docker.push = mkOption {
|
options.docker.export = mkOption {
|
||||||
description = "List of images to push";
|
description = "List of images to export";
|
||||||
type = types.listOf (types.package);
|
type = types.listOf (types.package);
|
||||||
default = [];
|
default = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
config.docker.push = mapAttrsToList (_: i: i.image)
|
config.docker.export = mapAttrsToList (_: i: i.image)
|
||||||
(filterAttrs (_: i: i.registry != null)config.docker.images);
|
(filterAttrs (_: i: i.registry != null)config.docker.images);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.submodules.instances.test.config;
|
cfg = config.submodules.instances.test.config;
|
||||||
deployment = cfg.kubernetes.api.deployments.nginx;
|
deployment = cfg.kubernetes.api.deployments.nginx;
|
||||||
image = images.nginx;
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
kubenix.all
|
kubenix.all
|
||||||
|
|
@ -20,6 +19,9 @@ in {
|
||||||
} {
|
} {
|
||||||
message = "Version not propagated";
|
message = "Version not propagated";
|
||||||
assertion = cfg.kubernetes.version == config.kubernetes.version;
|
assertion = cfg.kubernetes.version == config.kubernetes.version;
|
||||||
|
} {
|
||||||
|
message = "docker image should be added to exported images";
|
||||||
|
assertion = (head config.docker.export) == images.nginx;
|
||||||
}];
|
}];
|
||||||
testScript = ''
|
testScript = ''
|
||||||
$kube->waitUntilSucceeds("docker load < ${image}");
|
$kube->waitUntilSucceeds("docker load < ${image}");
|
||||||
|
|
@ -44,12 +46,14 @@ in {
|
||||||
template.metadata.labels.app = "nginx";
|
template.metadata.labels.app = "nginx";
|
||||||
template.spec = {
|
template.spec = {
|
||||||
containers.nginx = {
|
containers.nginx = {
|
||||||
image = "${image.imageName}:${image.imageTag}";
|
image = config.docker.images.nginx.path;
|
||||||
imagePullPolicy = "Never";
|
imagePullPolicy = "Never";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
docker.images.nginx.image = images.nginx;
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue