Skip to content

Commit

Permalink
docs: Add testdrive example for Elasticsearch setup (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Jan 13, 2022
1 parent e9b88b9 commit 8b65cc4
Show file tree
Hide file tree
Showing 7 changed files with 440 additions and 0 deletions.
1 change: 1 addition & 0 deletions testdrive/cardano2elastic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.env
43 changes: 43 additions & 0 deletions testdrive/cardano2elastic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Cardano => Elasticsearch Testdrive

## Introduction

This is a reference implementation to show how _Oura_ can be leveradged to build read from a Cardano relay node into an Elasticsearch cluster.

## Prerequisites

- K8s Cluster
- kubectl
- Skaffold

## Deployment

Install Elasticsearch official Kubernetes operator:

```
kubectl create -f https://download.elastic.co/downloads/eck/1.9.1/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/1.9.1/operator.yaml
```

Create a k8s namespace for the testdrive:

```
kubectl create namespace cardano2elastic
```

Deploy the Elasticsearch + Kibana resources:

```
skaffold run --module elastic --namespace cardano2elastic
```

Setup an index template to store _Oura_ events:

```
export ELASTIC_AUTH=user:pass
cd scripts && ./setup-index.sh
```

```
skaffold run --namespace cardano2elastic
```
41 changes: 41 additions & 0 deletions testdrive/cardano2elastic/k8s/elastic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: sink
spec:
version: 7.16.1
nodeSets:
- name: default
count: 1
volumeClaimTemplates:
- metadata:
name: elasticsearch-data # Do not change this name unless you set up a volume mount for the data path.
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
podTemplate:
spec:
containers:
- name: elasticsearch
env:
- name: ES_JAVA_OPTS
value: -Xms2g -Xmx2g
resources:
requests:
memory: 4Gi
cpu: 1
limits:
memory: 4Gi
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: sink
spec:
version: 7.16.1
count: 1
elasticsearchRef:
name: sink
71 changes: 71 additions & 0 deletions testdrive/cardano2elastic/k8s/oura.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: oura
data:
daemon.toml: |-
[source]
type = "N2N"
address = ["Tcp", "relays-new.cardano-mainnet.iohk.io:3001"]
magic = "mainnet"
# it will start from way back, so we get a lot of data
since = [4492799, "f8084c61b6a238acec985b59310b6ecec49c0ab8352249afd7268da5cff2a457"]
[[filters]]
type = "Fingerprint"
[sink]
type = "Elastic"
url = "https://sink-es-http:9200"
index = "oura.sink.v0.mainnet"
idempotency = true
[sink.credentials]
type = "Basic"
username = "elastic"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: oura
labels:
app: oura
spec:
replicas: 1
selector:
matchLabels:
app: oura
template:
metadata:
labels:
app: oura
spec:
containers:
- name: main
image: ghcr.io/txpipe/oura:v0.3.10
env:
- name: "RUST_LOG"
value: "info"
- name: "OURA_SINK_CREDENTIALS_PASSWORD"
valueFrom:
secretKeyRef:
key: elastic
name: sink-es-elastic-user
resources:
requests:
memory: 100Mi
cpu: 50m
limits:
memory: 500Mi
cpu: 200m
args:
- "daemon"
volumeMounts:
- mountPath: /etc/oura
name: oura-config
volumes:
- name: oura-config
configMap:
name: oura
Loading

0 comments on commit 8b65cc4

Please sign in to comment.