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

Create operator + crd for Ogmios #2

Merged
merged 16 commits into from
Jan 2, 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
22 changes: 22 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Clippy

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./operator
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Clippy check lints
run: cargo clippy -- -D warnings
40 changes: 40 additions & 0 deletions .github/workflows/controller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Controller

on:
push:
branches:
- "main"
paths:
- ".github/workflows/controller.yml"
- "operator/**"

jobs:
build-images:
strategy:
fail-fast: false
matrix:
include:
- context: operator
file: operator/Dockerfile
endpoint: demeter-run/ext-cardano-ogmios

continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
platforms: linux/amd64
push: true
tags: ghcr.io/${{ matrix.endpoint }},ghcr.io/${{ matrix.endpoint }}:${{ github.sha }}
33 changes: 5 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
# Ext Cardano Ogmios

This project allow demeter to run and expose ogmios
The approach of this project is to allow a CRD to Ogmios on the K8S cluster and an operator will enable the required resources to expose an Ogmios port.

## Environment
## Folder structure

| Key | Value |
| ---- | ------------ |
| ADDR | 0.0.0.0:5000 |


## Commands

To generate the CRD will need to execute crdgen

```bash
cargo run --bin=crdgen
```

and execute the controller

```bash
cargo run
```

## Metrics

to collect metrics for Prometheus, an http api will enable with the route /metrics.

```
/metrics
```
* bootstrap: contains terraform resources
* operator: rust application integrated with the cluster
* scripts: useful scripts
101 changes: 101 additions & 0 deletions bootstrap/crds/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
resource "kubernetes_manifest" "customresourcedefinition_ogmiosports_demeter_run" {
manifest = {
"apiVersion" = "apiextensions.k8s.io/v1"
"kind" = "CustomResourceDefinition"
"metadata" = {
"name" = "ogmiosports.demeter.run"
}
"spec" = {
"group" = "demeter.run"
"names" = {
"categories" = []
"kind" = "OgmiosPort"
"plural" = "ogmiosports"
"shortNames" = []
"singular" = "ogmiosport"
}
"scope" = "Namespaced"
"versions" = [
{
"additionalPrinterColumns" = [
{
"jsonPath" = ".spec.network"
"name" = "Network"
"type" = "string"
},
{
"jsonPath" = ".spec.version"
"name" = "Version"
"type" = "number"
},
{
"jsonPath" = ".status.endpointUrl"
"name" = "Endpoint URL"
"type" = "string"
},
{
"jsonPath" = ".status.authToken"
"name" = "Auth Token"
"type" = "string"
},
]
"name" = "v1alpha1"
"schema" = {
"openAPIV3Schema" = {
"description" = "Auto-generated derived type for OgmiosPortSpec via `CustomResource`"
"properties" = {
"spec" = {
"properties" = {
"network" = {
"enum" = [
"mainnet",
"preprod",
"preview",
"sanchonet",
]
"type" = "string"
}
"version" = {
"format" = "uint8"
"minimum" = 0
"type" = "integer"
}
}
"required" = [
"network",
"version",
]
"type" = "object"
}
"status" = {
"nullable" = true
"properties" = {
"authToken" = {
"nullable" = true
"type" = "string"
}
"endpointUrl" = {
"nullable" = true
"type" = "string"
}
}
"type" = "object"
}
}
"required" = [
"spec",
]
"title" = "OgmiosPort"
"type" = "object"
}
}
"served" = true
"storage" = true
"subresources" = {
"status" = {}
}
},
]
}
}
}
1 change: 1 addition & 0 deletions operator/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
.env
55 changes: 55 additions & 0 deletions operator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
name = "ext-cardano-ogmios"
version = "0.1.0"
edition = "2021"
default-run = "controller"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-web = "4.4.0"
argon2 = "0.5.2"
base64 = "0.21.5"
bech32 = "0.9.1"
dotenv = "0.15.0"
futures = "0.3.29"
k8s-openapi = { version = "0.20.0", features = ["latest"] }
kube = { version = "0.87.1", features = ["runtime", "client", "derive"] }
lazy_static = "1.4.0"
prometheus = "0.13.3"
schemars = "0.8.16"
serde = { version = "1.0.193", features = ["derive"] }
Expand Down
15 changes: 15 additions & 0 deletions operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM rust:1.74-slim-buster as build

WORKDIR /app

COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./src ./src

RUN cargo build --release

FROM rust:1.74-slim-buster

COPY --from=build /app/target/release/controller .

CMD ["./controller"]
Loading