kubenix/docs/content/examples/deployment/module.nix

69 lines
1.4 KiB
Nix
Raw Normal View History

2021-05-13 17:27:08 -04:00
{
2022-04-02 12:40:35 -07:00
config,
lib,
pkgs,
kubenix,
...
2022-08-29 02:04:47 -04:00
}: {
imports = with kubenix.modules; [k8s];
2019-03-07 18:03:51 +01:00
kubernetes.resources = {
deployments.nginx.spec = {
2019-03-07 18:03:51 +01:00
replicas = 10;
selector.matchLabels.app = "nginx";
template = {
metadata.labels.app = "nginx";
spec = {
securityContext.fsGroup = 1000;
containers.nginx = {
2022-08-29 02:04:47 -04:00
image = "nginx";
2019-03-07 18:03:51 +01:00
imagePullPolicy = "IfNotPresent";
volumeMounts = {
"/etc/nginx".name = "config";
"/var/lib/html".name = "static";
};
};
volumes = {
config.configMap.name = "nginx-config";
static.configMap.name = "nginx-static";
2019-03-07 18:03:51 +01:00
};
};
};
};
configMaps = {
nginx-config.data."nginx.conf" = ''
user nginx nginx;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
access_log /dev/stdout;
server {
listen 80;
index index.html;
location / {
root /var/lib/html;
}
}
2019-03-07 18:03:51 +01:00
}
'';
2019-03-07 18:03:51 +01:00
nginx-static.data."index.html" = ''
<html><body><h1>Hello from NGINX</h1></body></html>
'';
};
2019-03-07 18:03:51 +01:00
services.nginx.spec = {
2022-04-02 12:40:35 -07:00
ports = [
{
name = "http";
port = 80;
}
];
2019-03-07 18:03:51 +01:00
selector.app = "nginx";
};
};
}