Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy PgHero & connect to Neon.tech Postgres #507

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
direnv 2.32.3
direnv 2.34.0
elixir 1.14.5
erlang 26.2
golang 1.20.12
nodejs 20.10.0
erlang 26.2.3
golang 1.22.1
nodejs 20.11.1
yarn 1.22.19
postgres 16.1
flyctl 0.1.135
1password-cli 2.24.0
postgres 16.2
flyctl 0.2.25
1password-cli 2.26.1
dagger 0.6.4
48 changes: 27 additions & 21 deletions INFRASTRUCTURE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![shields.io](https://img.shields.io/badge/Last%20updated%20on-Jan.%2012%2C%202024-success?style=for-the-badge)](https://shipit.show/80)
[![shields.io](https://img.shields.io/badge/Last%20updated%20on-Mar.%2027%2C%202024-success?style=for-the-badge)](https://shipit.show/80)

This diagram shows the current changelog.com setup:

Expand Down Expand Up @@ -33,35 +33,40 @@ graph TD
repo -.- |fly.io/changelog-2024-01-12| app

registry --> |ghcr.io/changelog/changelog-prod| app
container --> |flyctl deploy| app
dagger --> |flyctl deploy| app

repo -.- |fly.io/dagger-engine-2023-05-20| container
repo -.- |fly.io/dagger-engine-2023-05-20| dagger

repo -.- |fly.io/pghero-2024-03-27| pghero

%% PaaS - https://fly.io/dashboard/changelog
subgraph Fly.io
proxy{fa:fa-globe Proxy}
proxy ==> |https| app

container([ fa:fa-project-diagram Dagger Engine 2023-05-20 ]):::link
click container "https://fly.io/apps/dagger-engine-2023-05-20"
dagger([ fa:fa-project-diagram Dagger Engine 2023-05-20 ]):::link
click dagger "https://fly.io/apps/dagger-engine-2023-05-20"

app(( fab:fa-phoenix-framework App changelog-2024-01-12.fly.dev )):::link
style app fill:#488969;
click app "https://fly.io/apps/changelog-2024-01-12"

automation --> |wireguard| container
container --> |ghcr.io/changelog/changelog-runtime| registry
container --> |ghcr.io/changelog/changelog-prod| registry
pghero([ fa:fa-gem PgHero 2024-03-27 ]):::link
click pghero "https://fly.io/apps/pghero-2024-03-27"

automation --> |wireguard| dagger
dagger --> |ghcr.io/changelog/changelog-runtime| registry
dagger --> |ghcr.io/changelog/changelog-prod| registry

metricsdb([ fa:fa-chart-line Prometheus ])
metrics[ fa:fa-columns Grafana fly-metrics.net ]:::link
click metrics "https://fly-metrics.net"
metrics --- |promql| metricsdb
metricsdb -.- |metrics| app
metricsdb -.- |metrics| container
grafana[ fa:fa-columns Grafana fly-metrics.net ]:::link
click grafana "https://fly-metrics.net"
grafana -.- |metrics| app
grafana -.- |metrics| dagger
grafana -.- |metrics| pghero
end

app <==> |Postgres| dbrw
app <===> |Postgres| dbrw
pghero --> dbrw

subgraph Neon.tech
dbrw([ fa:fa-database main branch primary ]):::link
Expand All @@ -79,12 +84,12 @@ graph TD

%% Search
search(( fa:fa-magnifying-glass Typesense ))
app -...-> |search| search
app -..-> |search| search

%% Exceptions
exceptions(( fa:fa-car-crash Sentry )):::link
click exceptions "https://sentry.io/organizations/changelog-media/issues/?project=5668962"
app -...-> |exceptions| exceptions
app -..-> |exceptions| exceptions

%% CDN - https://manage.fastly.com/configure/services/7gKbcKSKGDyqU7IuDr43eG
subgraph Fastly
Expand All @@ -104,15 +109,16 @@ graph TD
%% Observability
observability(( fa:fa-bug Honeycomb )):::link
click observability "https://ui.honeycomb.io/changelog/datasets/changelog_opentelemetry/home"
app -....-> |traces| observability
app -.-> |traces| observability
logs -.-> |logs| observability

%% Object storage
apex ==> |https| proxy
subgraph Cloudflare.R2
assets[ fab:fa-cloudflare changelog-assets changelog.place ]
feeds[ fab:fa-cloudflare changelog-feeds feeds.changelog.place ]
end
cdn ==> |https| assets
cdn ==> |https| assets & feeds

%% Monitoring
subgraph BetterStack
Expand All @@ -128,8 +134,8 @@ graph TD
end
```

> **Note**
> [Continue live editing this Mermaid diagram](https://mermaid.live/edit#pako:eNqdWHlv2zYU_yqEihYNEEk-4rPrhizu0iJoF8ztBiwuBkqiZS4SqZJUHTfOd98jdVGO3GP-w9bx7vd7B33vhDwiztx5-hRtlMrk3PfXnCm8JZKnxAt56kuCRbhZsVjgbIPeL1YMwSdMsJQLskYJZbdIKsFvyfzJaBYMppPT4tbd0kht5sPs7kXBU3yDqgtQip4hkECULJ7KPCgUXFL1Og-Kh_ojSMbv79EaB_M1dmOqNnmA1IaEG8xikvDYr6-0uejhYT6fa6MaEWFCw1sjCK2cys1CkvHwuLSVs2KWHBpGNz6Yoi0JqQgT4obAe1sajc5DRTlDLlpuaIbeKLRafTxijZb1o9b42MiX_paL23XCt9KXoOgfqrxdmmhbKx3NFc4VT7Fmu1mt6ijyBMSiBY5jItAlR8vFFfKPmdqI-GGDg4QHfoqlIgJ-YrKmCZHNlRfzdoQFiSmAZ_f8-UHC400oPMrRycnR7Bac3SZyEcu2nRkOb8EMeZDhDVaNbpkAEVqa76OKNYultPHfcBdpg_qhn8Hxi95weT7989Xg0GtApuu5P6O9VxjdneG9QU0bj8jVbN2x3Vup68JGwy_zMCRSoicR-bw3LhVUhEV26VaGov062UE6Gm_dQW8wdPsDtz8BrVnW5ipTY1SVmfQ7IONmgkcWe6g7EWUAUcMJOkOVoIhkCd9ZZF-xLzIIdwmLQUxhY28Ev_tGdpUIaEvXGC-heOtGWMmQm4BjETWGHrSs3wxhYwy4cbe7L9pEDBVA0LV-8nBAgV6-BK-MttIbKzWVec9vyn4DLP-SULkRxaA1rYr3lXENNa6hj0eRWoezgWvpI2iXR4NlN5aD5pJlTbVkG04YvXPXYB3R-EXnWYa6EOJprYC0rqKSapcQLRgBipP5k7PpdDaevXjUk4Cg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TWWKrq9yfwR2jYh5Oa76CzkfIOyCKMFAefUSYmAGRs5c-dev1g5sILpepjDZYTFrXbsAej00rncsdCZK5GTUyfPoLDIoljmHYh3IuFphtnfnLfunfm9c-fM3clw7I0nvd5sejYYTUb96amzc-azvtc_G02Gg0kPHo-Go4dT54uR0Pcmw9Fwdtbr9Xu9SQ_IYUCAH2-LP3zM_z4P_wG9QNng)
> [!TIP]
> [Continue live editing this Mermaid diagram](https://mermaid.live/edit#pako:eNqVWHlv2zYU_yqEihYtEEk-4iPusiFrurQI2gVzuwGLi4GSaJmLRGok1cSN8933SOqgHLlH_nBk6t3v9w763ot5QryF9_Qp2ihVyEUYrjlT-JZInpMg5nkoCRbxZsVSgYsN-nC-Ygj-4gxLeU7WKKPsBkkl-A1ZPJmcRKP57Mh-9W9pojaLcXH30vLYT1D1CpSiZwgkECXtqSwjq-CCqjdlZA_1nyAFv79Haxwt1thPqdqUEVIbEm8wS0nG07B50uaih4fFYqGNakXEGY1vjCC08mo3rSTj4WFpK2_FHDk0Tq5DMEVbElMRZ8SPgfemMhqdxYpyhny03NACvVVotfp0wBot60etCbGRL8NbLm7WGb-VoQRF_1AVbPNM21rraJ9wqXiONdv1atVEkWcgFp3jNCUCXXC0PL9E4SFTWxE_bHCU8SjMsVREwL-UrGlGZPsUpLwbYUFSCuDZPn--l_B0E4uAcvTixcHsWs5-E7lIZdfOAsc3YIbcy_AGq1a3zIAILc3nQcWaxVHa-m-4bdqgfuhncPzVYLw8m__5erTvNSDTD_yf0S6wRvdneGdQ08Uj8jVbf2x3Tur6sNHyyzKOiZToSUI-74xLloqwxC3d2lC0W2dbSEfrrT8ajI79wdAfjkBrUXS5qtQYVVUmwx7I-IXgicOeWHwaNlAYqwwlpMj41qH5inGW3ScspYxoA8f-YAL_d5XgOgWPGIt0QwSvXBr7o9kO2aOaA1rYFcZLKPSmadYq5SbiWCStU3vt7TdD2NoOLt9t721LSaFaCLrSJw97FOj0FIJgtFXOtwTWm-fXVWMC-n9JrP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5KFNzolgouOO5OhlUp64mQ4S1siangZVG9Cb6v5iyx24t6uLuzKG_sbMAJ4wgu54owRiX6WOjl5_AVruV3MWqYgsi4KlV9l1ME5-FwPB4PRmHFJ91W4MiCzmd7X023M1g6QNslhBx9F52DxW9Q2jA6UPCOvJwIGNiJt_Du9YuVB1dkXV4LeEywuNGOPQCd3kiXWxZ7CyVKcuSVBdQpObcXDA_inUk4LTDzFvfenbfwZ-NpMJ0NBifz49FkNhnOj7yttzgZBsPjyWw8mg3geDKePBx5XzgHCcNgNp6MT44Hg-FgMBsAOYwXsPud_XXK_EhlFPxtyI3Ch_8BRPIPhw)

Let's dig into how all the above pieces fit together.

Expand Down
35 changes: 35 additions & 0 deletions fly.io/pghero-2024-03-27/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# A Performance Dashboard for Postgres

This sets up [PgHero](https://github.com/ankane/pghero) (a performance
dashboard) for our Neon.tech Postgres instance.

It runs on Fly.io and is only available on our private network (requires a
running Wireguard Tunnel).

## Deploy

1. `flyctl apps create pghero-2024-03-27 --org changelog`
2. `flyctl secrets set DATABASE_URL="$(op read op://changelog/neon/url --account changelog.1password.com --cache)"`
3. `flyctl deploy --ha=false --vm-memory=512`

## Connect

> [!NOTE]
> Skip if you already have a WireGuard Tunnel configured.

Now connect to this PgHero instance running on Fly.io:

1. Create a Wireguard peer: `flyctl wireguard create changelog lhr gerhard-2024-03-27`
2. Save it to e.g. `~/Desktop/fly.io-changelog-lhr-gerhard-2024-03-27.conf`
3. **Import Tunnel(s) from File...** it in WireGuard - [install](https://www.wireguard.com/install/) if needed
4. Activate new Tunnel
5. Connect to PgHero: <http://pghero-2024-03-27.internal:8080>

## Delete

`flyctl destroy pghero-2024-03-27`

## Shout-out

- @ankane for [PgHero](https://github.com/ankane/pghero) 🦸
- @brendan-stephens for [the pairing session](https://github.com/thechangelog/changelog.com/pull/492#issuecomment-1885586669) 🍐
23 changes: 23 additions & 0 deletions fly.io/pghero-2024-03-27/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://fly.io/docs/reference/configuration/

app = "pghero-2024-03-27"
primary_region = "iad"

[build]
# https://hub.docker.com/r/ankane/pghero/tags
image = "ankane/pghero:v3.4.1@sha256:bbf82670a228c3df4a3198a1aa2db4e0a66e110d08d7b12e4de49cabcf451052"

[env]
BIND = 'tcp://[::]:8080'

[[services]]
internal_port = 8080
protocol = "tcp"

[[services.http_checks]]
grace_period = "10s"
interval = "15s"
method = "get"
path = "/health"
protocol = "http"
timeout = "10s"
2 changes: 1 addition & 1 deletion magefiles/tools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func CurrentVersions() *Versions {
toolVersions: toolVersions(),
Ubuntu: Ubuntu{
// https://hub.docker.com/r/hexpm/elixir/tags?page=1&ordering=last_updated&name=ubuntu-jammy
Short: "jammy-20231004",
Short: "jammy-20240125",
Long: "22.04 LTS (Jammy Jellyfish)",
},
}
Expand Down
Loading