-
Notifications
You must be signed in to change notification settings - Fork 41
initial version of wireguard on the monitoring-devops deployment #595
Changes from 1 commit
953378b
757b445
e7204ac
b4cf1aa
6d5446e
92a3cf1
61b7c9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ globals, IOHKaccessKeyId, ... }: | ||
|
||
with import ../lib.nix; | ||
let | ||
accessKeyId = IOHKaccessKeyId; | ||
nodeMap = { inherit (globals.fullMap) monitoring; }; | ||
monitoring = nodeMap.monitoring; | ||
region = monitoring.region; | ||
org = monitoring.org; | ||
in { | ||
resources = { | ||
ec2SecurityGroups = { | ||
"allow-wireguard-in-${region}-${org}" = { | ||
inherit region accessKeyId; | ||
description = "wireguard"; | ||
rules = [{ | ||
protocol = "udp"; | ||
fromPort = 51820; toPort = 51820; | ||
sourceIp = "0.0.0.0/0"; | ||
}]; | ||
}; | ||
}; | ||
}; | ||
monitoring = { resources, ... }: { | ||
deployment.ec2 = { | ||
securityGroups = [ | ||
resources.ec2SecurityGroups."allow-wireguard-in-${region}-${org}" | ||
resources.ec2SecurityGroups."allow-to-monitoring-${region}" | ||
resources.ec2SecurityGroups."allow-monitoring-static-peers-${region}-${org}" | ||
]; | ||
region = mkForce monitoring.region; | ||
accessKeyId = monitoring.accessKeyId; | ||
keyPair = resources.ec2KeyPairs.${monitoring.keyPairName}; | ||
}; | ||
}; | ||
|
||
resources.elasticIPs = nodesElasticIPs nodeMap; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,42 @@ | ||
{ | ||
{ IOHKaccessKeyId, ... }: | ||
let | ||
iohklib = import ../lib.nix; | ||
mkUplink = iohklib.mkMkUplink { | ||
central = "192.168.20.1"; | ||
subnet = "192.168.20"; | ||
# TODO, `monitoring-ip` will be wrong if monitoring isnt using an elastic ip by that name | ||
endpoint = "monitoring-ip:51820"; | ||
}; | ||
in { | ||
require = [ ./monitoring.nix ]; | ||
monitoring = { ... }: | ||
a1 = mkUplink 10 ../static/a1.wgprivate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this stuff needs to be undone and moved to infra for all packet.net servers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was mainly a testing ground for the concept, and matching code has now been put into the infra deployments |
||
b1 = mkUplink 11 ../static/b1.wgprivate; | ||
c1 = mkUplink 12 ../static/c1.wgprivate; | ||
monitoring = { lib, resources, ... }: | ||
{ | ||
imports = [ | ||
../modules/devops.nix | ||
]; | ||
networking.wireguard.interfaces.wg0 = { | ||
peers = let | ||
genPeer = n: path: { | ||
allowedIPs = [ "192.168.20.${toString n}/32" ]; | ||
publicKey = lib.strings.removeSuffix "\n" (builtins.readFile path); | ||
}; | ||
in [ | ||
(genPeer 10 ../static/a1.wgpublic) | ||
(genPeer 11 ../static/b1.wgpublic) | ||
(genPeer 12 ../static/c1.wgpublic) | ||
{ allowedIPs = [ "192.168.20.20/32" ]; publicKey = "Iv+pHGJ6uGYfrSeF3PMSlN4v6YPZF52Xr5f8teH8OEE="; } # sams mac | ||
{ allowedIPs = [ "192.168.21.1/32" ]; publicKey = "oycbQ1DhtRh0hhD5gpyiKTUh0USkAwbjMer6/h/aHg8="; } # michaels desktop | ||
]; | ||
}; | ||
|
||
services.monitoring-services.enableWireguard = true; | ||
deployment.keys."monitoring.wgprivate" = { | ||
destDir = "/etc/wireguard"; | ||
keyFile = ../static/monitoring.wgprivate; | ||
}; | ||
services.monitoring-services.applicationDashboards = ../modules/grafana/cardano; | ||
services.monitoring-services.applicationRules = [ | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ hosts ? [ "monitoring" ] }: | ||
|
||
let | ||
pkgs = import (import ../fetch-nixpkgs.nix) {}; | ||
in pkgs.stdenv.mkDerivation { | ||
name = "gen-wireguard-keys"; | ||
buildInputs = [ pkgs.wireguard ]; | ||
shellHook = '' | ||
cd ${toString ../static} | ||
umask 077 | ||
for host in ${toString hosts}; do | ||
wg genkey > ''${host}.wgprivate | ||
wg pubkey < ''${host}.wgprivate > ''${host}.wgpublic | ||
done | ||
exit 0 | ||
''; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this. Maybe it would be good to add similar for graylog and grafana initial cred creation to save new cluster spin up time. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,11 @@ in { | |
Enable papertrail. | ||
''; | ||
}; | ||
|
||
ownIp = mkOption { | ||
type = types.str; | ||
description = "the address a remote prometheus node will use to contact this machine"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could also mention wireguard IP will be used preferentially if enabled. |
||
}; | ||
}; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let | ||
pkgsSrc = import ../fetch-nixpkgs.nix; | ||
eval = import (pkgsSrc + "/nixos") { | ||
configuration = cfg; | ||
}; | ||
cfg = { lib, ... }: { | ||
imports = [ | ||
./hydra-master-main.nix | ||
./common.nix | ||
./hydra-slave.nix | ||
./hydra-master-common.nix | ||
]; | ||
virtualisation = { | ||
memorySize = 2 * 1024; | ||
graphics = false; | ||
qemu.networkingOptions = [ | ||
"-net nic,netdev=user.0,model=virtio" | ||
"-netdev user,id=user.0,hostfwd=tcp:127.0.0.1:8080-:80" | ||
]; | ||
}; | ||
services = { | ||
mingetty.autologinUser = "root"; | ||
grafana.extraOptions.AUTH_GOOGLE_CLIENT_SECRET = lib.mkForce ""; | ||
nginx.virtualHosts."hydra.iohk.io" = { | ||
forceSSL = lib.mkForce false; | ||
enableACME = lib.mkForce false; | ||
}; | ||
}; | ||
nixpkgs.overlays = [ | ||
(import ../overlays/monitoring-exporters.nix) | ||
]; | ||
}; | ||
in eval.vm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wireguard SG replaces the need for this SG.