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

feat(cat-gateway): adds deployment #1422

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ea4a1db
feat(gateway): adds deployment
jmgilman Dec 18, 2024
0b0fbb3
chore: bumps forge
jmgilman Dec 18, 2024
3fe475b
wip: fixes spelling
jmgilman Dec 18, 2024
3e3bcbf
wip: adds missing privilege
jmgilman Dec 18, 2024
0734e50
build(update follower): dependency
cong-or Dec 19, 2024
4c8af86
build(update follower): dependency
cong-or Dec 19, 2024
2069116
feat(replication factor): env var
cong-or Dec 19, 2024
5c0660d
chore: turn off debug logging and drop debug sleep
jmgilman Dec 19, 2024
bc47aff
wip: sets limit on gateway memory usage
jmgilman Jan 2, 2025
e3e34ab
Merge branch 'main' into gateway-deployment
jmgilman Jan 2, 2025
697e187
chore: sets cpu limit to avoid defaulting
jmgilman Jan 2, 2025
f585267
Merge branch 'main' into gateway-deployment
stevenj Jan 3, 2025
1179dfd
Merge branch 'main' into gateway-deployment
stevenj Jan 3, 2025
39b8142
Create Ingress resources
benbooth493 Jan 7, 2025
4d8f828
Remove whitespace
benbooth493 Jan 7, 2025
94be18a
Change container port
benbooth493 Jan 7, 2025
1ca6ecc
Merge branch 'main' into gateway-deployment
benbooth493 Jan 7, 2025
4f944a1
Merge branch 'main' into gateway-deployment
cong-or Jan 8, 2025
aa47ae3
Merge branch 'main' into gateway-deployment
jmgilman Jan 8, 2025
2e3ad22
wip: comments out test target
jmgilman Jan 8, 2025
c49bb75
chore: reduces resource requirements
jmgilman Jan 8, 2025
3ffe4bc
Bump blueprint version and set servicePort value
benbooth493 Jan 9, 2025
f9e623f
Fix domain name and enable readiness healthcheck
benbooth493 Jan 9, 2025
121fdce
Enable readiness probe
benbooth493 Jan 9, 2025
1120dbe
Fix health endpoints
benbooth493 Jan 9, 2025
688307d
refactor(rm auth ): healthcheck
cong-or Jan 9, 2025
a0e990f
Merge branch 'main' into gateway-deployment
cong-or Jan 9, 2025
040b614
refactor(rm auth ): healthcheck
cong-or Jan 9, 2025
1ead5c9
rm schema version check
cong-or Jan 10, 2025
061a5b8
Merge branch 'main' into gateway-deployment
cong-or Jan 10, 2025
d9744e1
rm schema version check
cong-or Jan 10, 2025
584f46c
rm schema version check
cong-or Jan 10, 2025
f726dff
is live
cong-or Jan 10, 2025
44f1bb4
is live
cong-or Jan 10, 2025
58c6e9d
Merge branch 'main' into gateway-deployment
cong-or Jan 17, 2025
a3b0412
Merge branch 'main' into gateway-deployment
jmgilman Jan 18, 2025
5383d33
chore: updates deployment to use new app model
jmgilman Jan 18, 2025
04c3e79
wip: adds docker release for migrations container
jmgilman Jan 21, 2025
f1cc75e
chore: adds job for migrations
jmgilman Jan 22, 2025
1918558
wip: fixes spelling
jmgilman Jan 22, 2025
b924153
Merge branch 'main' into gateway-deployment
jmgilman Jan 22, 2025
2135a28
wip: fixing migrations build
jmgilman Jan 22, 2025
facbebb
wip: more migration fixes
jmgilman Jan 22, 2025
5a58c2d
wip: fixes spelling
jmgilman Jan 22, 2025
852a845
Merge branch 'main' into gateway-deployment
cong-or Jan 23, 2025
fb926e2
Merge branch 'main' into gateway-deployment
jmgilman Jan 23, 2025
58784ca
wip: enables scraping
jmgilman Jan 23, 2025
c036eab
wip: fixes scrape config
jmgilman Jan 23, 2025
7f93ef6
chore: adds internal API key
jmgilman Jan 28, 2025
c8bf9fd
Merge branch 'main' into gateway-deployment
jmgilman Jan 28, 2025
56f6b21
wip: cleanup
jmgilman Jan 28, 2025
7277b32
wip: cleanup
jmgilman Jan 28, 2025
8bb7146
refactor(schema version check): reintroduce
cong-or Jan 29, 2025
5bb9e1b
Merge branch 'main' into gateway-deployment
cong-or Jan 29, 2025
5db9b03
Merge branch 'main' into gateway-deployment
cong-or Jan 29, 2025
5557272
Merge branch 'main' into gateway-deployment
cong-or Jan 30, 2025
7fd4702
Set env var
benbooth493 Jan 30, 2025
99ddcd6
psql ci version
cong-or Jan 30, 2025
0702561
fix psql
cong-or Jan 30, 2025
132fa48
Merge branch 'main' into gateway-deployment
cong-or Jan 30, 2025
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
4 changes: 4 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ endfunction
Eternl
EUTXO
extn
eventdb
fetchval
Filecoin
fmtchk
Expand Down Expand Up @@ -152,6 +153,7 @@ keychains
Keyhash
keyserver
keyspace
keyspaces
KUBECONFIG
kubernetescrd
kubetail
Expand Down Expand Up @@ -254,6 +256,7 @@ ripgrep
ristretto
rlib
rngs
rolname
RPATH
ruleset
rustc
Expand Down Expand Up @@ -306,6 +309,7 @@ Toastify
todos
toggleable
tojunit
tolerations
tomjs
topbar
Traceback
Expand Down
11 changes: 9 additions & 2 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ all-hosts-build:
# package : Create a deployable container for catalyst-gateway
package:
FROM debian:12.7-slim
WORKDIR /cat-gateway

WORKDIR /app
RUN apt-get update && apt-get install -y curl python3 python3-pip
RUN pip3 install --break-system-packages cqlsh
RUN curl https://certs.secureserver.net/repository/sf-class2-root.crt -o /tmp/keyspaces.crt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this cert anymore?

Copy link
Contributor

@benbooth493 benbooth493 Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't. We can remove that and clean up the volumes and mounts associated with it.
Yes we can ditch :91


COPY +build/cat-gateway .
ENTRYPOINT [ "./cat-gateway", "run" ]
COPY entrypoint.sh .

ENTRYPOINT [ "/bin/bash", "entrypoint.sh" ]

# Publish cat-gateway
docker:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-- Create the namespace in the DB.
-- Template.
CREATE KEYSPACE IF NOT EXISTS {{keyspace}}
With replication = {'class': 'NetworkTopologyStrategy','replication_factor': 1};
CREATE KEYSPACE IF NOT EXISTS {{keyspace}} WITH REPLICATION = {{options}};
5 changes: 4 additions & 1 deletion catalyst-gateway/bin/src/db/index/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ async fn create_namespace(
// which transforms `<`, `>` symbols to `&lt`, `&gt`
reg.register_escape_fn(|s| s.into());
let query = reg
.render_template(CREATE_NAMESPACE_CQL, &json!({"keyspace": keyspace}))
.render_template(
CREATE_NAMESPACE_CQL,
&json!({"keyspace": keyspace,"options": cfg.deployment.clone().to_string()}),
)
.context(format!("Keyspace: {keyspace}"))?;

// Create the Keyspace if it doesn't exist already.
Expand Down
13 changes: 8 additions & 5 deletions catalyst-gateway/bin/src/service/api/health/live_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn is_live() -> bool {

/// Endpoint responses.
#[derive(ApiResponse)]
#[allow(dead_code)]
pub(crate) enum Responses {
/// Service is OK and can keep running.
#[oai(status = 204)]
Expand All @@ -45,9 +46,11 @@ pub(crate) type AllResponses = WithErrorResponses<Responses>;
/// by an endpoint in a short window.
#[allow(clippy::unused_async)]
pub(crate) async fn endpoint() -> AllResponses {
if is_live() {
Responses::NoContent.into()
} else {
Responses::ServiceUnavailable.into()
}
// TODO: Needs engineering discussion
// if is_live() {
// Responses::NoContent.into()
// } else {
// Responses::ServiceUnavailable.into()
// }
Responses::NoContent.into()
}
11 changes: 7 additions & 4 deletions catalyst-gateway/bin/src/service/api/health/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! Health Endpoints
use poem_openapi::{param::Query, OpenApi};

use crate::service::common::{auth::api_key::InternalApiKeyAuthorization, tags::ApiTags};
use crate::service::common::{
auth::{api_key::InternalApiKeyAuthorization, none::NoAuthorization},
tags::ApiTags,
};

mod inspection_get;
mod live_get;
Expand All @@ -28,7 +31,7 @@ impl HealthApi {
method = "get",
operation_id = "healthStarted"
)]
async fn started_get(&self, _auth: InternalApiKeyAuthorization) -> started_get::AllResponses {
async fn started_get(&self, _auth: NoAuthorization) -> started_get::AllResponses {
started_get::endpoint().await
}

Expand All @@ -46,7 +49,7 @@ impl HealthApi {
method = "get",
operation_id = "healthReady"
)]
async fn ready_get(&self, _auth: InternalApiKeyAuthorization) -> ready_get::AllResponses {
async fn ready_get(&self, _auth: NoAuthorization) -> ready_get::AllResponses {
ready_get::endpoint().await
}

Expand All @@ -59,7 +62,7 @@ impl HealthApi {
/// *This endpoint is for internal use of the service deployment infrastructure.
/// It may not be exposed publicly. Refer to []*
#[oai(path = "/v1/health/live", method = "get", operation_id = "healthLive")]
async fn live_get(&self, _auth: InternalApiKeyAuthorization) -> live_get::AllResponses {
async fn live_get(&self, _auth: NoAuthorization) -> live_get::AllResponses {
live_get::endpoint().await
}

Expand Down
7 changes: 7 additions & 0 deletions catalyst-gateway/bin/src/settings/cassandra_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub(crate) struct EnvVars {

/// Maximum Configured Batch size.
pub(crate) max_batch_size: i64,

/// Config options for deployment i.e replication strategy
pub(crate) deployment: StringEnvVar,
}

impl EnvVars {
Expand Down Expand Up @@ -91,6 +94,10 @@ impl EnvVars {
MIN_BATCH_SIZE,
MAX_BATCH_SIZE,
),
deployment: StringEnvVar::new(
&format!("CASSANDRA_{name}_DEPLOYMENT"),
"{'class': 'NetworkTopologyStrategy','replication_factor': 1}".into(),
),
}
}

Expand Down
218 changes: 218 additions & 0 deletions catalyst-gateway/blueprint.cue
Original file line number Diff line number Diff line change
@@ -1,6 +1,224 @@
version: "1.0.0"
project: {
name: "gateway"
ci: {
targets: {
test: privileged: true
}
}
deployment: {
on: {
merge: {}
}
environment: "dev"
modules: main: {
name: "app"
version: "0.3.2"
values: {
deployment: {
containers: gateway: {
image: {
name: _ @forge(name="CONTAINER_IMAGE")
tag: _ @forge(name="GIT_HASH_OR_TAG")
}

env: {
"RUST_LOG": {
value: "error,cat_gateway=info,cardano_chain_follower=info"
}
"CASSANDRA_VOLATILE_URL": {
secret: {
name: "gateway"
key: "cassandra-volatile-url"
}
}
"CASSANDRA_VOLATILE_USERNAME": {
secret: {
name: "gateway"
key: "cassandra-volatile-username"
}
}
"CASSANDRA_VOLATILE_PASSWORD": {
secret: {
name: "gateway"
key: "cassandra-volatile-password"
}
}

"CASSANDRA_VOLATILE_DEPLOYMENT": {
secret: {
name: "gateway"
key: "cassandra-volatile-deployment"
}
}
"CASSANDRA_PERSISTENT_URL": {
secret: {
name: "gateway"
key: "cassandra-persistent-url"
}
}
"CASSANDRA_PERSISTENT_USERNAME": {
secret: {
name: "gateway"
key: "cassandra-persistent-username"
}
}
"CASSANDRA_PERSISTENT_PASSWORD": {
secret: {
name: "gateway"
key: "cassandra-persistent-password"
}
}
"CASSANDRA_PERSISTENT_DEPLOYMENT": {
secret: {
name: "gateway"
key: "cassandra-persistent-deployment"
}
}
"INTERNAL_API_KEY": {
secret: {
name: "gateway"
key: "api-key"
}
}
"EVENT_DB_URL": {
secret: {
name: "db-url"
key: "url"
}
}

"RBAC_OFF": {
value: "true"
}
}

port: 3030
probes: {
liveness: path: "/api/v1/health/live"
readiness: path: "/api/v1/health/ready"
}
mounts: data: {
ref: volume: name: "data"
path: "/root/.local/share/cat-gateway"
readOnly: false
}
resources: {
requests: {
cpu: "1"
memory: "8Gi"
}
limits: {
cpu: "8"
memory: "12Gi"
}
}
}

nodeSelector: {
"node-group": "catalyst-gateway"
}
serviceAccount: "catalyst-gateway"
strategy: "Recreate"
tolerations: [
{
key: "app"
operator: "Equal"
value: "catalyst-gateway"
effect: "NoSchedule"
},
]
}

jobs: migration: containers: main: {
image: {
name: "332405224602.dkr.ecr.eu-central-1.amazonaws.com/catalyst-voices/gateway-event-db"
tag: _ @forge(name="GIT_HASH_OR_TAG")
}

env: {
DB_HOST: {
secret: {
name: "db"
key: "host"
}
}
DB_PORT: {
secret: {
name: "db"
key: "port"
}
}
DB_NAME: {
value: "gateway"
}
DB_DESCRIPTION: {
value: "Gateway Event Database"
}
DB_SUPERUSER: {
secret: {
name: "db-root"
key: "username"
}
}
DB_SUPERUSER_PASSWORD: {
secret: {
name: "db-root"
key: "password"
}
}
DB_USER: {
secret: {
name: "db"
key: "username"
}
}
DB_USER_PASSWORD: {
secret: {
name: "db"
key: "password"
}
}
INIT_AND_DROP_DB: {
value: "true"
}
WITH_MIGRATIONS: {
value: "true"
}
}
}

ingress: subdomain: "gateway"

secrets: {
db: {
ref: "db/gateway"
}
"db-root": {
ref: "db/root_account"
}
"db-url": {
ref: "db/gateway"
template: url: "postgres://{{ .username }}:{{ .password }}@{{ .host }}:{{ .port }}/gateway"
}
gateway: {
ref: "gateway"
}
}

service: {
port: 80
scrape: {}
}

volumes: data: {
class: "ebs-io1"
size: "250Gi"
}
}
}
}

release: {
docker: {
on: {
Expand Down
Loading
Loading