Skip to content

Commit e6233f9

Browse files
authored
feat: add ext-tx-submit-api-operator (#231)
Signed-off-by: Ales Verbic <[email protected]>
1 parent a56818a commit e6233f9

File tree

9 files changed

+323
-0
lines changed

9 files changed

+323
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: publish-ext-tx-submit-api-helm-chart
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
paths: ['charts/ext-tx-submit-api/**','.github/workflows/publish-ext-tx-submit-api-helm-chart.yml']
7+
8+
jobs:
9+
build-and-push-ext-tx-submit-api-helm-chart:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v5
16+
- name: Install Helm
17+
uses: azure/setup-helm@v4
18+
- name: Package and upload chart
19+
shell: bash
20+
env:
21+
REGISTRY: "ghcr.io"
22+
REPOSITORY: "${{ github.repository }}"
23+
TOKEN: "${{ secrets.GITHUB_TOKEN }}"
24+
USER: "${{ github.repository_owner }}"
25+
run: |
26+
rm -rf dist
27+
mkdir dist
28+
helm package charts/ext-tx-submit-api/ -d dist/
29+
echo "${TOKEN}" | helm registry login "${REGISTRY}" -u "${USER}" --password-stdin
30+
for file in dist/*; do
31+
helm push "$file" "oci://${REGISTRY}/${REPOSITORY,,}/charts"
32+
done
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: ext-tx-submit-api-operator
3+
description: Ext Tx Submit API operator
4+
version: 0.0.1
5+
appVersion: "0.0.1"
6+
7+
sources:
8+
- https://github.com/demeter-run/ext-cardano-submitapi
9+
10+
maintainers:
11+
- name: aurora
12+
13+
- name: overcookedpanda
14+
15+
- name: verbotenj
16+
17+
- name: wolf31o2
18+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: submitapiports.demeter.run
5+
spec:
6+
group: demeter.run
7+
names:
8+
categories:
9+
- demeter-port
10+
kind: SubmitApiPort
11+
plural: submitapiports
12+
shortNames:
13+
- sapts
14+
singular: submitapiport
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
served: true
19+
storage: true
20+
additionalPrinterColumns:
21+
- jsonPath: .spec.network
22+
name: Network
23+
type: string
24+
- jsonPath: .spec.throughputTier
25+
name: Throughput Tier
26+
type: string
27+
- jsonPath: .status.endpointUrl
28+
name: Endpoint URL
29+
type: string
30+
- jsonPath: .status.authenticatedEndpointUrl
31+
name: Authenticated Endpoint URL
32+
type: string
33+
- jsonPath: .status.authToken
34+
name: Auth Token
35+
type: string
36+
schema:
37+
openAPIV3Schema:
38+
title: SubmitApiPort
39+
description: Auto-generated derived type for SubmitApiPortSpec via `CustomResource`
40+
type: object
41+
required:
42+
- spec
43+
properties:
44+
spec:
45+
type: object
46+
required:
47+
- network
48+
- operatorVersion
49+
- throughputTier
50+
properties:
51+
authToken:
52+
type: string
53+
nullable: true
54+
network:
55+
type: string
56+
operatorVersion:
57+
type: string
58+
submitapiVersion:
59+
type: string
60+
nullable: true
61+
throughputTier:
62+
type: string
63+
status:
64+
type: object
65+
nullable: true
66+
required:
67+
- authToken
68+
- endpointUrl
69+
properties:
70+
authToken:
71+
type: string
72+
authenticatedEndpointUrl:
73+
type: string
74+
nullable: true
75+
endpointUrl:
76+
type: string
77+
subresources:
78+
status: {}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{/*
2+
Expand the name of the chart.
3+
If .Values.nameOverride is not set, use .Chart.Name.
4+
*/}}
5+
{{- define "txSubmitApiOperator.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a fully qualified app name.
11+
If .Values.fullnameOverride is set, use it.
12+
Otherwise, combine .Release.Name and chart name (or nameOverride).
13+
*/}}
14+
{{- define "txSubmitApiOperator.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" | lower -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" | lower -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" | lower -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Chart name and version for the chart label.
29+
*/}}
30+
{{- define "txSubmitApiOperator.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels.
36+
*/}}
37+
{{- define "txSubmitApiOperator.labels" -}}
38+
helm.sh/chart: {{ include "txSubmitApiOperator.chart" . }}
39+
{{ include "txSubmitApiOperator.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end -}}
45+
46+
{{/*
47+
Selector labels.
48+
*/}}
49+
{{- define "txSubmitApiOperator.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "txSubmitApiOperator.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end -}}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}
5+
namespace: {{ .Release.Namespace }}
6+
labels: {{ include "txSubmitApiOperator.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels: {{ include "txSubmitApiOperator.selectorLabels" . | nindent 6 }}
11+
template:
12+
metadata:
13+
labels: {{ include "txSubmitApiOperator.selectorLabels" . | nindent 8 }}
14+
spec:
15+
serviceAccountName: {{ .Values.serviceAccount.name | default .Release.Name }}
16+
containers:
17+
- name: main
18+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
19+
imagePullPolicy: {{ .Values.image.pullPolicy }}
20+
env:
21+
- name: ADDR
22+
value: "0.0.0.0:{{ .Values.metricsPort }}"
23+
- name: K8S_IN_CLUSTER
24+
value: "true"
25+
- name: PROMETHEUS_URL
26+
value: "{{ .Values.prometheusUrl }}"
27+
- name: METRICS_DELAY
28+
value: {{ .Values.metricsDelay | quote }}
29+
- name: DCU_PER_REQUEST
30+
value: "mainnet={{ .Values.dcuPerRequest.mainnet }},preprod={{ .Values.dcuPerRequest.preprod }},preview={{ .Values.dcuPerRequest.preview }},vector-testnet={{ .Values.dcuPerRequest.vectorTestnet }}"
31+
- name: DEFAULT_SUBMITAPI_VERSION
32+
value: {{ .Values.defaultSubmitApiVersion }}
33+
- name: API_KEY_SALT
34+
value: {{ .Values.apiKeySalt | quote }}
35+
- name: DNS_ZONE
36+
value: {{ .Values.dnsZone }}
37+
{{- range .Values.extraEnv }}
38+
- name: {{ .name }}
39+
value: {{ .value | quote }}
40+
{{- end }}
41+
resources: {{ toYaml .Values.resources | nindent 12 }}
42+
ports:
43+
- name: metrics
44+
containerPort: {{ .Values.metricsPort }}
45+
protocol: TCP
46+
{{- if .Values.tolerations }}
47+
tolerations: {{ toYaml .Values.tolerations | nindent 8 }}
48+
{{- end }}
49+
{{- if .Values.affinity }}
50+
affinity: {{ toYaml .Values.affinity | nindent 8 }}
51+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{ if .Values.podMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PodMonitor
4+
metadata:
5+
name: {{ .Release.Name }}
6+
namespace: {{ .Release.Namespace }}
7+
labels: {{ include "txSubmitApiOperator.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels: {{ include "txSubmitApiOperator.selectorLabels" . | nindent 6 }}
11+
podMetricsEndpoints:
12+
- port: metrics
13+
path: /metrics
14+
{{ end }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ .Values.serviceAccount.name | default .Release.Name }}
5+
rules:
6+
- apiGroups: ["", "demeter.run", "networking.k8s.io", "gateway.networking.k8s.io", "configuration.konghq.com", "coordination.k8s.io"]
7+
resources: ["*"]
8+
verbs: ["*"]
9+
---
10+
apiVersion: rbac.authorization.k8s.io/v1
11+
kind: ClusterRoleBinding
12+
metadata:
13+
name: {{ .Values.serviceAccount.name | default .Release.Name }}
14+
subjects:
15+
- kind: ServiceAccount
16+
name: {{ .Values.serviceAccount.name | default .Release.Name }}
17+
namespace: {{ .Release.Namespace }}
18+
roleRef:
19+
kind: ClusterRole
20+
name: {{ .Values.serviceAccount.name | default .Release.Name }}
21+
apiGroup: rbac.authorization.k8s.io
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ .Values.serviceAccount.name | default .Release.Name }}
5+
labels: {{ include "txSubmitApiOperator.labels" . | nindent 4 }}
6+
{{- with .Values.serviceAccount.annotations }}
7+
annotations:
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Ext Tx Submit API Operator values
2+
replicaCount: 1
3+
image:
4+
repository: ghcr.io/demeter-run/ext-cardano-submitapi-operator
5+
tag: 414d79bfa36292404bb5ed93f6750fa5d43e434f
6+
pullPolicy: IfNotPresent
7+
8+
# Configuration variables
9+
metricsDelay: 40
10+
metricsPort: 9946
11+
prometheusUrl: "http://prometheus-operated.mynamspace.svc.cluster.local:9090/api/v1"
12+
defaultSubmitApiVersion: v3
13+
apiKeySalt: "tx-api-key-salt"
14+
dnsZone: "example.com"
15+
16+
# extraEnv:
17+
# - name: EXRTRA_VAR
18+
# value: extraVarValue
19+
20+
# DCU per request configuration
21+
dcuPerRequest:
22+
mainnet: "0"
23+
preprod: "0"
24+
preview: "0"
25+
vectorTestnet: "0"
26+
27+
resources:
28+
limits:
29+
cpu: "100m"
30+
memory: "128Mi"
31+
requests:
32+
cpu: "50m"
33+
memory: "64Mi"
34+
35+
tolerations: []
36+
# Example tolerations:
37+
# - key: "key"
38+
# operator: "Equal"
39+
# value: "value"
40+
# effect: "NoSchedule"
41+
affinity: {}
42+
43+
podMonitor:
44+
enabled: false
45+
46+
serviceAccount:
47+
annotations: {}
48+
name: "txsubmitapi-operator"

0 commit comments

Comments
 (0)