mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
57 lines
1.3 KiB
Nix
57 lines
1.3 KiB
Nix
{lib, k8s, ...}:
|
|
|
|
with k8s;
|
|
with lib;
|
|
|
|
{
|
|
config = {
|
|
kubernetes.moduleDefinitions.nginx.module = {name, config, ...}: {
|
|
options = {
|
|
port = mkOption {
|
|
description = "Port for nginx to listen on";
|
|
type = types.int;
|
|
default = 80;
|
|
};
|
|
|
|
password = mkValueOrSecretOption {
|
|
description = "Nginx simple auth credentials";
|
|
default.secret = "test";
|
|
};
|
|
};
|
|
|
|
config = {
|
|
kubernetes.resources.deployments.nginx = mkMerge [
|
|
(loadJSON ./deployment.json)
|
|
{
|
|
metadata.name = "${name}-nginx";
|
|
|
|
spec.template.spec.containers.nginx.ports."80" = {
|
|
containerPort = config.port;
|
|
};
|
|
|
|
spec.template.spec.containers.nginx.env.name = config.password;
|
|
}
|
|
];
|
|
|
|
kubernetes.resources.configMaps.nginx = mkMerge [
|
|
(loadJSON ./configMap.json)
|
|
{
|
|
metadata.name = mkForce "${name}-nginx";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
kubernetes.modules.app-v1.module = "nginx";
|
|
kubernetes.modules.app-v2 = {
|
|
module = "nginx";
|
|
configuration.port = 8080;
|
|
};
|
|
|
|
kubernetes.resources.services.nginx = loadJSON ./service.json;
|
|
|
|
kubernetes.defaultModuleConfiguration = [{
|
|
kubernetes.defaults.deployments.spec.replicas = 3;
|
|
}];
|
|
};
|
|
}
|