feat(gs/mugwump): Run xanthous server
Add a nixos module for running the xanthous server in a docker container, and install it on mugwump including a prometheus scrape config. Change-Id: Ifeb315845b7eef2ee33af98fa3f71acdd3d9fe6b Reviewed-on: https://cl.tvl.fyi/c/depot/+/3812 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									5327d238e3
								
							
						
					
					
						commit
						e9c3d2f6d9
					
				
					 3 changed files with 50 additions and 2 deletions
				
			
		|  | @ -7,6 +7,7 @@ with lib; | |||
|     ../modules/common.nix | ||||
|     (modulesPath + "/installer/scan/not-detected.nix") | ||||
|     "${depot.path}/ops/modules/prometheus-fail2ban-exporter.nix" | ||||
|     "${depot.path}/users/grfn/xanthous/server/module.nix" | ||||
|   ]; | ||||
| 
 | ||||
|   networking.hostName = "mugwump"; | ||||
|  | @ -200,6 +201,12 @@ with lib; | |||
|       static_configs = [{ | ||||
|         targets = ["localhost:${toString config.services.prometheus.exporters.nginx.port}"]; | ||||
|       }]; | ||||
|     } { | ||||
|       job_name = "xanthous_server"; | ||||
|       scrape_interval = "1s"; | ||||
|       static_configs = [{ | ||||
|         targets = ["localhost:${toString config.services.xanthous-server.metricsPort}"]; | ||||
|       }]; | ||||
|     } { | ||||
|       job_name = "blackbox"; | ||||
|       metrics_path = "/probe"; | ||||
|  | @ -226,6 +233,8 @@ with lib; | |||
|     }]; | ||||
|   }; | ||||
| 
 | ||||
|   services.xanthous-server.enable = true; | ||||
| 
 | ||||
|   virtualisation.docker.enable = true; | ||||
| 
 | ||||
|   services.buildkite-agents = listToAttrs (map (n: rec { | ||||
|  |  | |||
|  | @ -6,7 +6,6 @@ | |||
| let | ||||
|   inherit (depot.users.grfn) xanthous; | ||||
|   xanthous-server = xanthous.server; | ||||
| 
 | ||||
| in pkgs.dockerTools.buildLayeredImage { | ||||
|   name = "xanthous-server"; | ||||
|   tag = "latest"; | ||||
|  | @ -17,5 +16,4 @@ in pkgs.dockerTools.buildLayeredImage { | |||
|       "--xanthous-binary-path" "${xanthous}/bin/xanthous" | ||||
|     ]; | ||||
|   }; | ||||
|   ci = false; | ||||
| } | ||||
|  |  | |||
							
								
								
									
										41
									
								
								users/grfn/xanthous/server/module.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								users/grfn/xanthous/server/module.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| { config, lib, pkgs, depot, ... }: | ||||
| 
 | ||||
| let | ||||
|   cfg = config.services.xanthous-server; | ||||
| in { | ||||
|   options = with lib; { | ||||
|     services.xanthous-server = { | ||||
|       enable = mkEnableOption "xanthous server"; | ||||
| 
 | ||||
|       port = mkOption { | ||||
|         type = types.int; | ||||
|         default = 2222; | ||||
|         description = "Port to listen to for SSH connections"; | ||||
|       }; | ||||
| 
 | ||||
|       metricsPort = mkOption { | ||||
|         type = types.int; | ||||
|         default = 9000; | ||||
|         description = "Port to listen to for prometheus metrics"; | ||||
|       }; | ||||
| 
 | ||||
|       image = mkOption { | ||||
|         type = types.package; | ||||
|         default = depot.users.grfn.xanthous.server.docker; | ||||
|         description = "OCI image file to run"; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkIf cfg.enable { | ||||
|     virtualisation.oci-containers.containers."xanthous-server" = { | ||||
|       autoStart = true; | ||||
|       image = "${cfg.image.imageName}:${cfg.image.imageTag}"; | ||||
|       imageFile = cfg.image; | ||||
|       ports = [ | ||||
|         "${toString cfg.port}:22" | ||||
|         "${toString cfg.metricsPort}:9000" | ||||
|       ]; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue