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

docs: Add testdrive example for webhook setup #55

Merged
merged 1 commit into from
Jan 13, 2022
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
31 changes: 31 additions & 0 deletions testdrive/cardano2webhook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Cardano => Webhook Testdrive

## Introduction

This is a reference implementation to show how _Oura_ can be leveradged to read from a Cardano relay node into an output events via HTTP to a remote endpoint.

## Prerequisites

- K8s Cluster
- kubectl
- Skaffold

## Deployment

Create a k8s namespace for the testdrive:

```
kubectl create namespace cardano2webhook
```

Deploy the resources:

```
skaffold run --namespace cardano2webhook --tail
```

Check the logs:

```
skaffold run --module oura --namespace cardano2webhook
```
59 changes: 59 additions & 0 deletions testdrive/cardano2webhook/k8s/endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: endpoint
data:
mock.yaml: |-
when:
method: POST
path: /events
header:
- name: content-type
value: application/json
then:
status: 200
header:
- name: content-type
value: application/json
delay: 50
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: endpoint
labels:
app: endpoint
spec:
replicas: 1
selector:
matchLabels:
app: endpoint
template:
metadata:
labels:
app: endpoint
spec:
containers:
- name: main
image: alexliesenfeld/httpmock:0.6.2
ports:
- containerPort: 5000
env:
- name: "RUST_LOG"
value: "info"
- name: "HTTPMOCK_MOCK_FILES_DIR"
value: "/etc/httpmock"
resources:
requests:
memory: 100Mi
cpu: 50m
limits:
memory: 500Mi
cpu: 200m
volumeMounts:
- mountPath: /etc/httpmock
name: mock-config
volumes:
- name: mock-config
configMap:
name: endpoint
58 changes: 58 additions & 0 deletions testdrive/cardano2webhook/k8s/oura.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: oura
data:
daemon.toml: |-
[source]
type = "N2N"
address = ["Tcp", "relays-new.cardano-mainnet.iohk.io:3001"]
magic = "mainnet"
since = [4492799, "f8084c61b6a238acec985b59310b6ecec49c0ab8352249afd7268da5cff2a457"]

[[filters]]
type = "Fingerprint"

[sink]
type = "Webhook"
url = "https://endpoint:5000/events"
---
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.9
env:
- name: "RUST_LOG"
value: "info"
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
19 changes: 19 additions & 0 deletions testdrive/cardano2webhook/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: endpoint
deploy:
kubectl:
manifests:
- k8s/endpoint.yaml
---
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: oura
requires:
- configs: [elastic]
deploy:
kubectl:
manifests:
- k8s/oura.yaml