Skip to content

Commit 4b40510

Browse files
committed
imp: add postgrest job in perf ns
1 parent 79c6ef2 commit 4b40510

File tree

13 files changed

+356
-5
lines changed

13 files changed

+356
-5
lines changed

flake.lock

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
inputs.bitte.follows = "bitte";
2525
};
2626
nix-inclusive.url = "github:input-output-hk/nix-inclusive";
27+
nixpkgs-postgrest.url = "github:NixOS/nixpkgs/haskell-updates";
2728
nixpkgs-vector.url = "github:NixOS/nixpkgs/30d3d79b7d3607d56546dd2a6b49e156ba0ec634";
2829
nomad-driver-nix.url = "github:input-output-hk/nomad-driver-nix";
2930
spongix.url = "github:input-output-hk/spongix/extract-gc";
@@ -56,7 +57,7 @@
5657
(data "dashboards")
5758
(runnables "entrypoints")
5859
(functions "bitteProfile")
59-
(functions "oci-images")
60+
(containers "oci-images")
6061
(functions "library")
6162
(installables "packages")
6263
(functions "hydrationProfile")
@@ -86,6 +87,7 @@
8687
)
8788
{
8889
prod = bitte.lib.mkNomadJobs "prod" nomadEnvs;
90+
perf = bitte.lib.mkNomadJobs "perf" nomadEnvs;
8991
}
9092
(inputs.tullia.fromStd {
9193
actions = inputs.std.harvest inputs.self ["cloud" "actions"];

nix/cloud/hydrationProfile.nix

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
inputs,
33
cell,
44
}: let
5-
inherit (inputs) bitte-cells;
5+
inherit (inputs) bitte-cells cells;
66
in {
77
# Bitte Hydrate Module
88
# -----------------------------------------------------------------------
@@ -15,6 +15,7 @@ in {
1515
imports = [
1616
(bitte-cells.patroni.hydrationProfiles.hydrate-cluster ["prod"])
1717
(bitte-cells.tempo.hydrationProfiles.hydrate-cluster ["prod"])
18+
(cells.perf.hydrationProfile.workload-policies-postgrest)
1819
];
1920

2021
# NixOS-level hydration
@@ -37,6 +38,7 @@ in {
3738
nomad.namespaces = {
3839
prod = {description = "CI Prod";};
3940
baremetal = {description = "CI Baremetal Builders";};
41+
perf = {description = "CI Performance Benchmarking";};
4042
};
4143
};
4244

@@ -55,6 +57,12 @@ in {
5557
policies = ["cicero"];
5658
};
5759

60+
resource.vault_github_team.performance-tracing = {
61+
backend = "\${vault_github_auth_backend.employee.path}";
62+
team = "performance-tracing";
63+
policies = ["perf"];
64+
};
65+
5866
locals.policies = {
5967
consul.developer.servicePrefix."marlowe-" = {
6068
policy = "write";
@@ -119,6 +127,20 @@ in {
119127
"pki/roles/client" = [r];
120128
"sys/capabilities-self" = [u];
121129
};
130+
131+
perf.path = caps {
132+
"auth/token/lookup" = [u];
133+
"auth/token/lookup-self" = [r];
134+
"auth/token/renew-self" = [u];
135+
"sys/capabilities-self" = [u];
136+
"kv/data/perf/*" = [r l];
137+
"kv/metadata/perf/*" = [r l];
138+
"nomad/creds/perf" = [r u];
139+
"consul/creds/developer" = [r u];
140+
"sops/keys/dev" = [r l];
141+
"sops/decrypt/dev" = [r u l];
142+
"sops/encrypt/dev" = [r u l];
143+
};
122144
};
123145

124146
nomad = {
@@ -204,6 +226,31 @@ in {
204226
};
205227
host_volume."marlowe".policy = "write";
206228
};
229+
230+
perf = {
231+
description = "Performance tracing and benchmarking policies";
232+
233+
namespace."*".policy = "deny";
234+
235+
namespace."perf" = {
236+
policy = "write";
237+
capabilities = [
238+
"alloc-exec"
239+
"alloc-lifecycle"
240+
"dispatch-job"
241+
"list-jobs"
242+
"list-scaling-policies"
243+
"read-fs"
244+
"read-job"
245+
"read-job-scaling"
246+
"read-logs"
247+
"read-scaling-policy"
248+
"scale-job"
249+
"submit-job"
250+
];
251+
};
252+
node.policy = "read";
253+
};
207254
};
208255
};
209256
};

nix/cloud/kv/vault/.sops.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ creation_rules:
33
hc_vault_transit_uri: "https://vault.ci.iog.io/v1/sops/keys/ops"
44
- path_regex: patroni/prod*
55
hc_vault_transit_uri: "https://vault.ci.iog.io/v1/sops/keys/ops"
6+
- path_regex: postgrest/*
7+
hc_vault_transit_uri: "https://vault.ci.iog.io/v1/sops/keys/dev"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ENC[AES256_GCM,data:WEjMvMIDqX1Jg92hCgva,iv:/sjGqs654JqWI/3vhVyrrAJRakuAd70t4YfKfr8Y628=,tag:4MLQGlbNZ/v7vAYoQjAgoQ==,type:comment]
2+
#ENC[AES256_GCM,data:WB+AqjTDkX90Xw5XywAiHfpJrRwNZrM8em8bEUNS54GAbQOTwz27dWY1HQ78KU0=,iv:83KYwq8C1PtkhQS30+b+SiARvBJLPe7zt5WVkD4uFAo=,tag:i26bNOjnfjulcfBoGcm6Aw==,type:comment]
3+
postgrestDbUser: ENC[AES256_GCM,data:csX7Xg==,iv:mipRz6MZmAAtOHtnQpgRyg40i2eXPK9m8DdddJSdM1o=,tag:fHt8gUz36M+DNvJGl6irDQ==,type:str]
4+
postgrestDbPass: ENC[AES256_GCM,data:CNFO2xcWmsrj0oIw3JXH3XO1rsNGfq3ZEgfopetFWeE=,iv:tdO+Udiz10NARYrLmd8AOiu3LMdZQPXset9vRTZiUn8=,tag:uxClRN3xqIPOsCJAd1u2qQ==,type:str]
5+
jwtSecret: ENC[AES256_GCM,data:21V7Vvcuv517K2oIoqwxApp3riZOCKVePWoyCyN4X1Y=,iv:eIp0vD+8WXnsBnPf8OKlvUsSHaFwB19ev0UQrLNjfPw=,tag:acS2HFFqesh/Yw0fah2Mww==,type:str]
6+
sops:
7+
kms: []
8+
gcp_kms: []
9+
azure_kv: []
10+
hc_vault:
11+
- vault_address: https://vault.ci.iog.io
12+
engine_path: sops
13+
key_name: dev
14+
created_at: "2022-12-16T19:26:21Z"
15+
enc: vault:v1:0LluEnlsU4wV7x9VdY+rfGlu//vo5ryHki7sCg3dUVsxVEU6WQlrtAxDlhjZtP98bTjSzRl68jW9y+jF
16+
age: []
17+
lastmodified: "2022-12-16T22:34:13Z"
18+
mac: ENC[AES256_GCM,data:idB9gqRKoFOAakkKHXMDp7gKPf1E+O90l3cibBJGpreiB9FBu0fcBw/Vz6hPIMN020gfToASziGrAIal6rUQHWSf5s5+uJ3LAsKS+S68m0NLDhu622AoJjExeHFIZJ/WV+XHUjy1E2Iyqxfpx7vsCoeDXx9jN3SNmbYq/d/GBrA=,iv:tjumEcugyoADxXbZGnA+fyVORoxgltSY/TA0FjDr9ZA=,tag:LoafwGKNEjvbn9TCpuVU+A==,type:str]
19+
pgp: []
20+
unencrypted_suffix: _unencrypted
21+
version: 3.7.3

nix/cloud/nomadEnvs/default.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,20 @@ in {
6262
inherit inputs cell;
6363
inherit (constants.args.prod) domain namespace;
6464
};
65+
66+
postgrest = inputs.cells.perf.jobs.default;
67+
};
68+
69+
perf = let
70+
# inherit
71+
# (constants.perf)
72+
# # App constants
73+
# WALG_S3_PREFIX
74+
# # Job mod constants
75+
# patroniMods
76+
# tempoMods
77+
# ;
78+
in {
79+
postgrest = inputs.cells.perf.jobs.default inputs.cells.perf.constants.args.perf;
6580
};
6681
}

nix/metal/bitteProfile/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ in {
110110
(mkAsgs "eu-central-1" 10 "m5.8xlarge" 500 "prod" "prod" {withPatroni = true;} {})
111111
(mkAsgs "eu-central-1" 0 "m5.metal" 1000 "baremetal" "baremetal" {} {primaryInterface = "enp125s0";})
112112
(mkAsgs "eu-central-1" 1 "t3a.medium" 100 "test" "test" {} {})
113+
(mkAsgs "eu-central-1" 1 "t3a.medium" 100 "perf" "perf" {} {})
113114
]
114115
(args: let
115116
attrs =

nix/perf/constants.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
inputs,
3+
cell,
4+
}: let
5+
# Metadata
6+
# -----------------------------------------------------------------------
7+
baseDomain = "ci.iog.io";
8+
in rec {
9+
# App Component Import Parameterization
10+
# -----------------------------------------------------------------------
11+
args = {
12+
perf = {
13+
namespace = "perf";
14+
domain = "${baseDomain}";
15+
nodeClass = "perf";
16+
datacenters = ["eu-central-1"];
17+
};
18+
};
19+
20+
perf = let
21+
inherit (args.perf) namespace;
22+
in rec {
23+
# App constants
24+
25+
# Job mod constants
26+
};
27+
}

nix/perf/entrypoints.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
inputs,
3+
cell,
4+
}: let
5+
inherit (inputs) nixpkgs;
6+
inherit (inputs.bitte-cells._writers.library) writeShellApplication;
7+
inherit (cell) packages;
8+
in {
9+
postgrest = writeShellApplication {
10+
debugInputs = with nixpkgs; [postgresql_12];
11+
runtimeInputs = [packages.postgrest];
12+
name = "entrypoint";
13+
text = ''
14+
exec postgrest /secrets/postgrest.conf
15+
'';
16+
};
17+
}

nix/perf/hydrationProfile.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
inputs,
3+
cell,
4+
}: {
5+
# Postgrest
6+
workload-policies-postgrest = {
7+
tf.hydrate-cluster.configuration.locals.policies = {
8+
vault.postgrest = {
9+
path."kv/data/postgrest/*".capabilities = ["read" "list"];
10+
path."kv/metadata/postgrest/*".capabilities = ["read" "list"];
11+
};
12+
};
13+
14+
# FIXME: consolidate policy reconciliation loop with TF
15+
# PROBLEM: requires bootstrapper reconciliation loop
16+
# clients need the capability to impersonate the `postgrest` role
17+
services.vault.policies.client = {
18+
path."auth/token/roles/postgrest".capabilities = ["read"];
19+
};
20+
};
21+
}

0 commit comments

Comments
 (0)