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

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
46 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
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
2 changes: 2 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ keychains
Keyhash
keyserver
keyspace
keyspaces
KUBECONFIG
kubernetescrd
kubetail
Expand Down Expand Up @@ -298,6 +299,7 @@ Toastify
todos
toggleable
tojunit
tolerations
tomjs
Traceback
traefik
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
ci:
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.5.0
with:
forge_version: 0.8.0
forge_version: 0.8.1

test_reporting:
if: always()
Expand Down
13 changes: 10 additions & 3 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 Expand Up @@ -139,4 +146,4 @@ test:
--service event-db-is-running
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \
cargo nextest run --release --run-ignored=only signed_docs
END
END
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
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
191 changes: 184 additions & 7 deletions catalyst-gateway/blueprint.cue
Original file line number Diff line number Diff line change
@@ -1,20 +1,197 @@
version: "1.0.0"
project: {
name: "gateway"
ci: {
targets: {
test: privileged: true
}
}
deployment: {
on: {
always: {}
}
environment: "dev"
modules: main: {
container: "blueprint-deployment"
version: "0.2.4"
values: {
app: {
environment: "dev"

image: {
repository: "332405224602.dkr.ecr.eu-central-1.amazonaws.com/gateway"
tag: _ @forge(name="GIT_HASH_OR_TAG")
}

containerPort: 8080
strategy: "Recreate"

persistentVolumeClaims: [
{
name: "pvc"
storageClassName: "ebs-io1"
storage: "250Gi"
},
]

volumes: [
{
name: "data"
persistentVolumeClaim: {
claimName: "pvc"
}
},
]

volumeMounts: [
{
name: "data"
mountPath: "/root/.local/share/cat-gateway"
readOnly: false
},
]

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

{
name: "CASSANDRA_VOLATILE_DEPLOYMENT"
valueFrom: {
secretKeyRef: {
key: "cassandra-volatile-deployment"
}
}
},
{
name: "CASSANDRA_PERSISTENT_URL"
valueFrom: {
secretKeyRef: {
key: "cassandra-persistent-url"
}
}
},
{
name: "CASSANDRA_PERSISTENT_USERNAME"
valueFrom: {
secretKeyRef: {
key: "cassandra-persistent-username"
}
}
},
// TODO: Re-enable when we have SSL working
// {
// name: "CASSANDRA_VOLATILE_TLS_CERT"
// value: "/tmp/keyspaces.crt"
// },
// {
// name: "CASSANDRA_PERSISTENT_TLS_CERT"
// value: "/tmp/keyspaces.crt"
// },
{
name: "CASSANDRA_PERSISTENT_PASSWORD"
valueFrom: {
secretKeyRef: {
key: "cassandra-persistent-password"
}
}
},

{
name: "CASSANDRA_PERSISTENT_DEPLOYMENT"
valueFrom: {
secretKeyRef: {
key: "cassandra-persistent-deployment"
}
}
},
]

resources: {
requests: {
cpu: "1"
memory: "16Gi"
}
limits: {
memory: "20Gi"
}
}

// TODO: Re-enable when deployment is working
// readinessProbe: {
// httpGet: {
// path: "/v1/health/ready"
// port: 8080
// }
// }

// livenessProbe: {
// httpGet: {
// path: "/v1/health/live"
// port: 8080
// }
// }

nodeSelector: {
"node-group": "catalyst-gateway"
}

tolerations: [
{
key: "app"
operator: "Equal"
value: "catalyst-gateway"
effect: "NoSchedule"
},
]

serviceAccount: "catalyst-gateway"
replicas: 1

externalSecret: {
secretStore: "cluster-secret-store"
refreshInterval: "30m"
dataFrom: ["dev/gateway"]
}
}
}
}
}

release: {
docker: {
on: {
merge: {}
tag: {}
always: {}
}
config: {
tag: _ @forge(name="GIT_COMMIT_HASH")
}
}
}
ci: {
targets: {
test: privileged: true
}
}
}
20 changes: 20 additions & 0 deletions catalyst-gateway/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

if [[ -n "${DEBUG_SLEEP}" ]]; then
echo "Sleeping for ${DEBUG_SLEEP} seconds..."
sleep "${DEBUG_SLEEP}"
fi

args+=()
args+=("run" "--log-level" "debug")

echo "Starting gateway node..."
"/app/cat-gateway" "${args[@]}"
exit_code=$?

if [[ $exit_code -ne 0 && -n "${DEBUG_SLEEP_ERR}" ]]; then
echo "Process exited with code $exit_code. Sleeping for ${DEBUG_SLEEP_ERR} seconds..."
sleep "${DEBUG_SLEEP_ERR}"
fi

exit $exit_code
Loading