Skip to content

Commit

Permalink
feat: charts (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
philanton authored Mar 13, 2024
1 parent 92f7763 commit bc8392e
Show file tree
Hide file tree
Showing 57 changed files with 2,457 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: pipeline
type: docker

steps:
- name: publish
- name: Publish
image: otwld/drone-chart-releaser-github-pages
settings:
cr_token:
Expand Down
21 changes: 21 additions & 0 deletions charts/clearport/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
6 changes: 6 additions & 0 deletions charts/clearport/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
appVersion: '1.0'
description: Yellow Clearport Chart
name: clearport
version: 1.1.0
19 changes: 19 additions & 0 deletions charts/clearport/config/postgres-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
secrets:
DATABASE_DRIVER: postgres
DATABASE_HOST: <DATABASE_HOST>
DATABASE_PORT: <DATABASE_PORT>
DATABASE_USER: <DATABASE_USER>
DATABASE_PASS: <DATABASE_PASS>
DATABASE_NAME: <DATABASE_NAME>
DATABASE_SCHEMA: <DATABASE_SCHEMA>

persistentVolume:
enabled: false

hooks:
createDb:
enabled: true
createDbUser:
enabled: true
createDbSchema:
enabled: true
8 changes: 8 additions & 0 deletions charts/clearport/config/sqlite-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
secrets:
DATABASE_DRIVER: sqlite
DATABASE_NAME: /data/sqlite.db

persistentVolume:
enabled: true
mountPath: /data
size: 10Gi
34 changes: 34 additions & 0 deletions charts/clearport/config/testnet-kayen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
externalHostname: kayen-clearport.v4.uat.opendax.app
externalSecret: clearport-sec

services:
peerGrpc:
nodePort: 31551

secrets:
TARGET_NETWORK: testnet
MARKET_PRICE_SOURCE: finex
DATABASE_DRIVER: postgres
DATABASE_HOST: postgresql.kayen-core
DATABASE_PORT: "5432"
DATABASE_USER: kayen_clearport
DATABASE_PASS: YzU1Yzc5MGNhMzcx
DATABASE_NAME: kayen_clearport
DATABASE_SCHEMA: public

persistentVolume:
enabled: false

hooks:
createDb:
enabled: true
createDbUser:
enabled: true
createDbSchema:
enabled: true
addOperator:
enabled: true

responderMode:
enabled: true
name: Kayen
28 changes: 28 additions & 0 deletions charts/clearport/config/testnet-terminal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
externalHostname: terminal-clearport.v4.uat.opendax.app
externalSecret: clearport-sec

services:
peerGrpc:
nodePort: 31561

secrets:
TARGET_NETWORK: testnet
MARKET_PRICE_SOURCE: finex
DATABASE_DRIVER: postgres
DATABASE_HOST: postgresql.kayen-core
DATABASE_PORT: "5432"
DATABASE_USER: terminal_clearport
DATABASE_PASS: YTU3ZDhmZjNjYzZk
DATABASE_NAME: terminal_clearport
DATABASE_SCHEMA: public

persistentVolume:
enabled: false

hooks:
createDb:
enabled: true
createDbUser:
enabled: true
createDbSchema:
enabled: true
13 changes: 13 additions & 0 deletions charts/clearport/templates/config-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "component.fullname" . }}-config
labels:
{{- include "component.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
"helm.sh/hook-weight": "-1"
data:
config.yaml: |-
{{- .Values.config | nindent 4 }}
78 changes: 78 additions & 0 deletions charts/clearport/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "component.fullname" . }}
labels:
{{- include "component.labels" . | nindent 4 }}
spec:
{{- include "component.replicaCount" . | nindent 2 }}
strategy:
type: Recreate
selector:
matchLabels:
{{- include "component.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "component.metricsAnnotations" .Values.metrics | nindent 8 }}
checksum/config: {{ include (print $.Template.BasePath "/config-cm.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
labels:
{{- include "component.selectorLabels" . | nindent 8 }}
{{- if .Values.extraLabels }}
{{- toYaml .Values.extraLabels | nindent 8 }}
{{- end }}
spec:
containers:
- name: clearport
image: {{ include "component.image" .Values.image }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["clearport", "start", "app"]
env:
{{- with .Values.services.operatorWs }}
- name: OPERATOR_WS_ADDR
value: {{ default .port .internalPort | print | printf ":%s" }}
{{- end }}
{{- with .Values.services.operatorGrpc }}
- name: OPERATOR_GRPC_PORT
value: {{ default .port .internalPort | print | printf ":%s" }}
{{- end }}
{{- with .Values.services.peerGrpc }}
- name: PEER_URL
value: {{ default .port .internalPort | print | printf "http://%s:%s" $.Values.externalHostname }}
{{- end }}
- name: CHANNEL_SEND_TRANSACTIONS
value: {{ .Values.responderMode.enabled | quote }}
{{- if or .Values.secrets .Values.externalSecret }}
envFrom:
{{- if .Values.secrets }}
- secretRef:
name: {{ include "component.fullname" . }}-opt-env
{{- end }}
{{- if .Values.externalSecret }}
- secretRef:
name: {{ .Values.externalSecret }}
{{- end }}
{{- end }}
volumeMounts:
- name: config
mountPath: /config
{{- if .Values.persistentVolume.enabled }}
- name: pv
mountPath: {{ .Values.persistentVolume.mountPath }}
{{- end }}
{{- include "component.resources" . | nindent 10 }}
volumes:
- name: config
configMap:
name: {{ include "component.fullname" . }}-config
{{- with .Values.persistentVolume.enabled }}
- name: pv
persistentVolumeClaim:
claimName: {{ include "component.fullname" $ }}
{{- end }}
{{- include "component.imagePullSecrets" . | nindent 6 }}
{{- include "component.nodeSelectorLabels" . | nindent 6 }}
{{- include "component.affinity" . | nindent 6 }}
{{- include "component.tolerations" . | nindent 6 }}
169 changes: 169 additions & 0 deletions charts/clearport/templates/helpers/component.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "component.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "component.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "component.selectorLabels" -}}
app: {{ include "component.name" . }}
app.kubernetes.io/name: {{ include "component.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "component.labels" -}}
helm.sh/chart: {{ include "component.chart" . }}
{{ include "component.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "component.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Returns Prometheus metrics' annotations depending on input Values
*/}}
{{- define "component.metricsAnnotations" -}}
prometheus.io/scrape: {{ default false .enabled | print | quote }}
prometheus.io/port: {{ default 4242 .port | print | quote }}
prometheus.io/path: {{ default "/metrics" .endpoint | print | quote }}
{{- end }}
{{/*
Returns replica count depending on global Values and HPA settings
*/}}
{{- define "component.replicaCount" -}}
{{- if not (and .Values.autoscaling .Values.autoscaling.enabled) }}
{{- if and .Values.profile.enabled }}
replicas: {{ get .Values.profile.replicas .Chart.Name }}
{{- else }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Returns full docker image name
*/}}
{{- define "component.image" -}}
{{ printf "%s:%s" (print .repository) (print .tag) }}
{{- end }}
{{/*
Returns container ports configuration depending on input service
*/}}
{{- define "component.port" -}}
- name: {{ .name }}
containerPort: {{ default .port .internalPort }}
protocol: TCP
{{- end }}
{{/*
Returns component's resource consumption
*/}}
{{- define "component.resources" -}}
{{- if .Values.profile.enabled }}
{{- with .Values.profile }}
resources:
{{- with .requests }}
requests:
cpu: {{ .cpu }}
memory: {{ .memory }}
{{- end }}
{{- with .limits }}
limits:
cpu: {{ .cpu }}
memory: {{ .memory }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Returns component's probes
*/}}
{{- define "component.probes" -}}
{{- $svc := get .Values.services .subservice }}
{{- $port := default $svc.port $svc.internalPort }}
{{- range $name, $probe := .Values.probes }}
{{ printf "%sProbe" $name }}:
httpGet:
path: {{ default "/health" $probe.path }}
port: {{ default $port $probe.port }}
initialDelaySeconds: {{ default 5 $probe.initialDelaySeconds }}
timeoutSeconds: {{ default 10 $probe.timeoutSeconds }}
periodSeconds: {{ default 10 $probe.periodSeconds }}
{{- end }}
{{- end }}
{{/*
Returns personal and global component's image pull secrets
*/}}
{{- define "component.imagePullSecrets" -}}
imagePullSecrets:
{{- if .Values.image.pullSecret }}
- name: {{ .Values.image.pullSecret }}
{{- end }}
{{- end }}

{{/*
Returns personal and global component's node selector labels
*/}}
{{- define "component.nodeSelectorLabels" -}}
nodeSelector:
{{- if .Values.nodeSelector }}
{{ toYaml .Values.nodeSelector | nindent 2 }}
{{- end }}
{{- end }}
{{/*
Returns personal and global component's tolerations
*/}}
{{- define "component.tolerations" -}}
tolerations:
{{- if .Values.tolerations }}
{{ toYaml .Values.tolerations }}
{{- end }}
{{- end }}

{{/*
Returns component pod's affinity
*/}}
{{- define "component.affinity" -}}
affinity:
{{- if .Values.affinity }}
{{ toYaml .Values.affinity | nindent 2 }}
{{- end }}
{{- end }}
Loading

0 comments on commit bc8392e

Please sign in to comment.