Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
avatxus committed Dec 10, 2023
0 parents commit 3ea48c4
Show file tree
Hide file tree
Showing 41 changed files with 6,361 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Images

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

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


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

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- 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,linux/arm64
push: true
tags: ghcr.io/${{ matrix.endpoint }},ghcr.io/${{ matrix.endpoint }}:${{ github.sha }}
116 changes: 116 additions & 0 deletions bootstrap/crds/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
resource "kubernetes_manifest" "customresourcedefinition_kupoports_demeter_run" {
manifest = {
"apiVersion" = "apiextensions.k8s.io/v1"
"kind" = "CustomResourceDefinition"
"metadata" = {
"name" = "kupoports.demeter.run"
}
"spec" = {
"group" = "demeter.run"
"names" = {
"categories" = []
"kind" = "KupoPort"
"plural" = "kupoports"
"shortNames" = [
"kp",
]
"singular" = "kupoport"
}
"scope" = "Namespaced"
"versions" = [
{
"additionalPrinterColumns" = [
{
"jsonPath" = ".spec.network"
"name" = "Network"
"type" = "string"
},
{
"jsonPath" = ".spec.pruneUtxo"
"name" = "Pruned"
"type" = "boolean"
},
{
"jsonPath" = "spec.throughputTier"
"name" = "Throughput Tier"
"type" = "string"
},
{
"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 KupoPortSpec via `CustomResource`"
"properties" = {
"spec" = {
"properties" = {
"network" = {
"enum" = [
"mainnet",
"preprod",
"preview",
"sanchonet",
]
"type" = "string"
}
"operatorVersion" = {
"type" = "string"
}
"pruneUtxo" = {
"type" = "boolean"
}
"throughputTier" = {
"type" = "string"
}
}
"required" = [
"network",
"operatorVersion",
"pruneUtxo",
"throughputTier",
]
"type" = "object"
}
"status" = {
"nullable" = true
"properties" = {
"authToken" = {
"type" = "string"
}
"endpointUrl" = {
"type" = "string"
}
}
"required" = [
"authToken",
"endpointUrl",
]
"type" = "object"
}
}
"required" = [
"spec",
]
"title" = "KupoPort"
"type" = "object"
}
}
"served" = true
"storage" = true
"subresources" = {
"status" = {}
}
},
]
}
}
}
39 changes: 39 additions & 0 deletions bootstrap/feature/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
variable "namespace" {
default = "ftr-kupo-v1"
}

variable "operator_image_tag" {}


variable "scrape_interval" {
description = "the inverval for polling metrics data (in seconds)"
default = "30"
}

variable "per_min_dcus" {
default = {
"mainnet" : 36,
"default" : 16,
}
}

variable "track_dcu_usage" {
default = "true"
}

variable "api_key_salt" {
type = string
}

variable "ingress_class" {
type = string
}

variable "dns_zone" {
default = "demeter.run"
}

output "namespace" {
value = var.namespace
}

27 changes: 27 additions & 0 deletions bootstrap/feature/monitor.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
resource "kubernetes_manifest" "monitor" {
manifest = {
apiVersion = "monitoring.coreos.com/v1"
kind = "PodMonitor"
metadata = {
labels = {
"app.kubernetes.io/component" = "o11y"
"app.kubernetes.io/part-of" = "demeter"
}
name = "operator"
namespace = var.namespace
}
spec = {
selector = {
matchLabels = {
role = "operator"
}
}
podMetricsEndpoints = [
{
port = "metrics",
path = "/metrics"
}
]
}
}
}
6 changes: 6 additions & 0 deletions bootstrap/feature/namespace.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

resource "kubernetes_namespace" "namespace" {
metadata {
name = var.namespace
}
}
129 changes: 129 additions & 0 deletions bootstrap/feature/operator.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
resource "kubernetes_deployment_v1" "operator" {
wait_for_rollout = false

metadata {
namespace = var.namespace
name = "operator"
labels = {
role = "operator"
}
}

spec {
replicas = 1

selector {
match_labels = {
role = "operator"
}
}

template {
metadata {
labels = {
role = "operator"
}
}

spec {
container {
image = "ghcr.io/demeter-run/cardano-kupo-v1-operator:${var.operator_image_tag}"
name = "main"
command = ["npm", "run", "start"]

env {
name = "PORT"
value = 9946
}

env {
name = "K8S_IN_CLUSTER"
value = "true"
}

env {
name = "PROMETHEUS_QUERY_ENDPOINT"
value = "http://prometheus-operated.default.svc.cluster.local:9090"
}

env {
name = "SCRAPE_INTERVAL_S"
value = var.scrape_interval
}

env {
name = "PER_MIN_DCUS_MAINNET"
value = var.per_min_dcus["mainnet"]
}

env {
name = "PER_MIN_DCUS_DEFAULT"
value = var.per_min_dcus["default"]
}

env {
name = "TRACK_DCU_USAGE"
value = var.track_dcu_usage
}

env {
name = "API_KEY_SALT"
value = var.api_key_salt
}

env {
name = "NAMESPACE"
value = var.namespace
}

env {
name = "INGRESS_CLASS"
value = var.ingress_class
}

env {
name = "DNS_ZONE"
value = var.dns_zone
}

resources {
limits = {
memory = "256Mi"
}
requests = {
cpu = "50m"
memory = "256Mi"
}
}

port {
name = "metrics"
container_port = 9946
protocol = "TCP"
}
}

toleration {
effect = "NoSchedule"
key = "demeter.run/compute-profile"
operator = "Equal"
value = "general-purpose"
}

toleration {
effect = "NoSchedule"
key = "demeter.run/compute-arch"
operator = "Exists"
}

toleration {
effect = "NoSchedule"
key = "demeter.run/availability-sla"
operator = "Equal"
value = "consistent"
}
}
}
}
}

Loading

0 comments on commit 3ea48c4

Please sign in to comment.