2018-02-20 23:07:47 +01:00
|
|
|
{lib, k8s, config, ...}:
|
2017-11-11 11:52:17 +01:00
|
|
|
|
2017-11-11 13:42:15 +01:00
|
|
|
with k8s;
|
2017-11-11 11:52:17 +01:00
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
config = {
|
|
|
|
|
kubernetes.moduleDefinitions.nginx.module = {name, config, ...}: {
|
|
|
|
|
options = {
|
|
|
|
|
port = mkOption {
|
|
|
|
|
description = "Port for nginx to listen on";
|
|
|
|
|
type = types.int;
|
|
|
|
|
default = 80;
|
|
|
|
|
};
|
2017-11-11 13:42:15 +01:00
|
|
|
|
2017-12-18 12:22:18 +01:00
|
|
|
password = mkSecretOption {
|
2017-11-11 13:42:15 +01:00
|
|
|
description = "Nginx simple auth credentials";
|
2017-12-29 10:20:19 +01:00
|
|
|
default = null;
|
2017-11-11 13:42:15 +01:00
|
|
|
};
|
2017-11-11 11:52:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
kubernetes.resources.deployments.nginx = mkMerge [
|
2017-11-11 13:42:15 +01:00
|
|
|
(loadJSON ./deployment.json)
|
2017-11-11 11:52:17 +01:00
|
|
|
{
|
|
|
|
|
metadata.name = "${name}-nginx";
|
|
|
|
|
|
|
|
|
|
spec.template.spec.containers.nginx.ports."80" = {
|
|
|
|
|
containerPort = config.port;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-29 10:20:19 +01:00
|
|
|
spec.template.spec.containers.nginx.env.name =
|
|
|
|
|
mkIf (config.password != null) (secretToEnv config.password);
|
2017-11-11 11:52:17 +01:00
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
kubernetes.resources.configMaps.nginx = mkMerge [
|
2017-11-11 13:42:15 +01:00
|
|
|
(loadJSON ./configMap.json)
|
2017-11-11 11:52:17 +01:00
|
|
|
{
|
|
|
|
|
metadata.name = mkForce "${name}-nginx";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-18 12:22:18 +01:00
|
|
|
kubernetes.modules.app-v1 = {
|
|
|
|
|
module = "nginx";
|
|
|
|
|
configuration.password.name = "test2";
|
2017-12-18 12:33:16 +01:00
|
|
|
configuration.password.key = "password";
|
2018-02-20 23:07:47 +01:00
|
|
|
|
|
|
|
|
configuration.kubernetes.resources.customResourceDefinitions.secret-claims = {
|
|
|
|
|
kind = "CustomResourceDefinition";
|
|
|
|
|
apiVersion = "apiextensions.k8s.io/v1beta1";
|
|
|
|
|
metadata.name = "secretclaims.vaultproject.io";
|
|
|
|
|
spec = {
|
|
|
|
|
group = "vaultproject.io";
|
|
|
|
|
version = "v1";
|
|
|
|
|
scope = "Namespaced";
|
|
|
|
|
names = {
|
|
|
|
|
plural = "secretclaims";
|
|
|
|
|
kind = "SecretClaim";
|
|
|
|
|
shortNames = ["scl"];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
configuration.kubernetes.customResources.secret-claims.claim = {
|
|
|
|
|
metadata.name = "test";
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-18 12:22:18 +01:00
|
|
|
};
|
2017-11-11 11:52:17 +01:00
|
|
|
kubernetes.modules.app-v2 = {
|
|
|
|
|
module = "nginx";
|
|
|
|
|
configuration.port = 8080;
|
2018-02-20 23:07:47 +01:00
|
|
|
|
|
|
|
|
configuration.kubernetes.modules.subsubmodule = {
|
|
|
|
|
module = "nginx";
|
|
|
|
|
configuration.kubernetes.resources.customResourceDefinitions.secret-claims = {
|
|
|
|
|
kind = "CustomResourceDefinition";
|
|
|
|
|
apiVersion = "apiextensions.k8s.io/v1beta1";
|
|
|
|
|
metadata.name = "secretclaims.vaultproject.io";
|
|
|
|
|
spec = {
|
|
|
|
|
group = "vaultproject.io";
|
|
|
|
|
version = "v1";
|
|
|
|
|
scope = "Namespaced";
|
|
|
|
|
names = {
|
|
|
|
|
plural = "secretclaims";
|
|
|
|
|
kind = "SecretClaim";
|
|
|
|
|
shortNames = ["scl"];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
configuration.kubernetes.customResources.secret-claims.claim = {
|
|
|
|
|
metadata.name = "test";
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-11-11 11:52:17 +01:00
|
|
|
};
|
|
|
|
|
|
2017-11-11 13:42:15 +01:00
|
|
|
kubernetes.resources.services.nginx = loadJSON ./service.json;
|
2017-11-11 11:52:17 +01:00
|
|
|
|
2018-03-21 00:05:42 +01:00
|
|
|
kubernetes.defaultModuleConfiguration.all = [{
|
|
|
|
|
config.kubernetes.defaults.deployments.spec.replicas = mkDefault 3;
|
|
|
|
|
}];
|
2017-11-24 12:51:38 +01:00
|
|
|
|
2018-03-21 00:05:42 +01:00
|
|
|
kubernetes.defaultModuleConfiguration.nginx = {config, name, ...}: {
|
|
|
|
|
kubernetes.defaults.deployments.spec.replicas = 4;
|
2017-12-23 20:13:55 +01:00
|
|
|
};
|
2017-11-11 11:52:17 +01:00
|
|
|
};
|
|
|
|
|
}
|