Skip to content

feat: add k8s helm charts for indexer deployment #272

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions docker/fetch-node.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM fetchai/fetchd:0.10.6

WORKDIR /app

COPY /scripts/fetch-node-entrypoint.sh /app/entrypoint.sh
RUN ["chmod", "+x", "/app/entrypoint.sh"]

ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]
44 changes: 44 additions & 0 deletions docker/subql-node.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM node:18-slim AS builder

ENV NODE_ENV=development
WORKDIR /app

# Add build dependencies
ADD ./package.json yarn.lock /app/
RUN apt-get update && apt-get install -y tree
RUN yarn install --frozen-lockfile

# Copy files & build
COPY . /app
RUN yarn codegen && yarn build

WORKDIR /app/subql-cosmos/packages/node/

RUN yarn install && yarn build

FROM node:18-slim

WORKDIR /app

RUN set -ex \
&& apt-get update -y \
&& apt-get install -y postgresql postgresql-contrib # && npm install -g clinic # Profiler

ADD https://github.com/mikefarah/yq/releases/download/v4.26.1/yq_linux_amd64 /usr/local/bin/yq
RUN chmod +x /usr/local/bin/yq

COPY --from=builder /app/subql-cosmos/packages/node/package.json /app/node/
COPY --from=builder /app/subql-cosmos/packages/node/dist /app/node/dist
COPY --from=builder /app/dist /app/dist
RUN yarn install

ADD ./proto /app/proto/
ADD ./project.yaml schema.graphql package.json /app/

WORKDIR /app/node
RUN yarn install

ADD ./scripts/subql-entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/app/entrypoint.sh"]
12 changes: 12 additions & 0 deletions docker/transaction.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.9-slim-buster

# Install pipenv and compilation dependencies
RUN pip3 install cosmpy
ENV PYTHONUNBUFFERED=1
WORKDIR /app

# add the remaining parts of the produce the build
COPY ./scripts/tx-entrypoint.py /app/tx-entrypoint.py

ENTRYPOINT ["python3"]
CMD ["/app/tx-entrypoint.py"]
File renamed without changes.
24 changes: 24 additions & 0 deletions k8s/indexer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: indexer
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
23 changes: 23 additions & 0 deletions k8s/indexer/charts/fetch-node/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions k8s/indexer/charts/fetch-node/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: fetchd-node-chart
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
25 changes: 25 additions & 0 deletions k8s/indexer/charts/fetch-node/templates/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: fetch-node
labels:
app: fetch-node
spec:
ports:
- name: p2p
port: 26656
targetPort: 26656
- name: tcp
port: 26657
targetPort: 26657
- name: prometheus
port: 26660
targetPort: 26660
- name: api
port: 1317
targetPort: 1317
- name: grpc
port: 9090
targetPort: 9090
selector:
app: fetch-node
39 changes: 39 additions & 0 deletions k8s/indexer/charts/fetch-node/templates/statefulSet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: fetch-node
spec:
selector:
matchLabels:
app: fetch-node # has to match .spec.template.metadata.labels
serviceName: "fetch-node"
replicas: 1
minReadySeconds: 10 # by default is 0
template:
metadata:
labels:
app: fetch-node # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
containers:
- name: fetch-node
image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
ports:
- containerPort: 26656
- containerPort: 26657
- containerPort: 26660
- containerPort: 1317
- containerPort: 9090

volumeMounts:
- name: data
mountPath: /root/.fetchd

volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.storage.size | quote }}
6 changes: 6 additions & 0 deletions k8s/indexer/charts/fetch-node/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image:
repo: jonathansumner/fetch-node
tag: v6

storage:
size: 5Gi
23 changes: 23 additions & 0 deletions k8s/indexer/charts/graphql-api/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions k8s/indexer/charts/graphql-api/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: graphql-api
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
82 changes: 82 additions & 0 deletions k8s/indexer/charts/graphql-api/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Default values for graphql-api.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 80

ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}
23 changes: 23 additions & 0 deletions k8s/indexer/charts/postgres-db/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions k8s/indexer/charts/postgres-db/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: postgres-db
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
Loading