Skip to content

Commit d0a60e5

Browse files
author
RoRu
committed
test: use helm
1 parent 5fcb2af commit d0a60e5

File tree

12 files changed

+489
-21
lines changed

12 files changed

+489
-21
lines changed

.github/workflows/production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
IMAGE: ${{ needs.build.outputs.image_name }}
5656
COMMIT_SHA: "${{ github.sha }}"
5757
NAMESPACE: cache-${{ matrix.CHAIN_ID }}
58-
ENV_NAME: production
58+
ENV_NAME: 'cache-production-${{ matrix.CHAIN_ID }}'
5959
run: |
6060
cd k8s/
6161
kubectl config set-context --current --namespace=${{ env.NAMESPACE }}

.github/workflows/pull-request.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,47 +33,49 @@ jobs:
3333
environment: preview
3434
needs: build
3535
container:
36-
image: qwolphin/kdsl:1.21.8
36+
image: ghcr.io/helmfile/helmfile-ubuntu:v0.145.3
3737
strategy:
3838
fail-fast: false
3939
matrix:
4040
CHAIN_ID: ["1", "137", "43114"]
4141
steps:
4242
- uses: actions/checkout@v2
4343

44+
- name: 'Debug: check user'
45+
shell: bash
46+
run: |
47+
id
48+
which helm
49+
ls -la ~/.local/share/helm/plugins/
50+
helm plugin list
51+
4452
- name: Set k8s namespace
4553
shell: bash
4654
run: |
47-
echo -e "NAMESPACE=cache-${NS_SUFFIX,,}\nENV_NAME=${{ github.head_ref }}" | tr -c '[:alnum:]-=\n_' '-' >> ${GITHUB_ENV}
55+
cat <<EOF | tr -c '[:alnum:]-=\n_' '-' >> ${GITHUB_ENV}
56+
NAMESPACE=cache-${NS_SUFFIX,,}
57+
ENV_NAME=${{ github.head_ref }}
4858
env:
4959
NS_SUFFIX: "${{ github.head_ref }}-${{ matrix.CHAIN_ID }}"
5060

51-
- name: Render kdsl resources into yaml
52-
env:
53-
MAINNET_RPC: "${{ secrets.MAINNET_RPC }}"
54-
POLYGON_RPC: "${{ secrets.POLYGON_RPC }}"
55-
RECIPE: "chain${{ matrix.CHAIN_ID }}"
56-
DOMAIN: "${{ env.NAMESPACE }}.aaw.fi"
57-
CHAIN_ID: "${{ matrix.CHAIN_ID }}"
58-
IMAGE: "${{ needs.build.outputs.image_name }}"
59-
COMMIT_SHA: "${{ github.sha }}"
60-
run: |
61-
cd k8s/
62-
python3 main.py > ../rendered.yml
63-
6461
- name: Set up kubeconfig
6562
run: |
6663
mkdir -p ~/.kube
6764
echo "${{ secrets.DEV_KUBECONFIG }}" > ~/.kube/config
68-
kubectl config set-context --current --namespace="${{ env.NAMESPACE }}"
6965
7066
- name: Apply k8s resources
7167
shell: bash
68+
env:
69+
MAINNET_RPC: "${{ secrets.MAINNET_RPC }}"
70+
POLYGON_RPC: "${{ secrets.POLYGON_RPC }}"
71+
DOMAIN: "${{ env.NAMESPACE }}.aaw.fi"
72+
CHAIN_ID: "${{ matrix.CHAIN_ID }}"
73+
IMAGE: "${{ needs.build.outputs.image_name }}"
74+
COMMIT_SHA: "${{ github.sha }}"
7275
run: |
73-
kubectl apply -f rendered.yml
74-
sleep 3
75-
kubectl wait --for condition=ready --timeout 90s pods -l "commit_sha=${{ github.sha }}" || \
76-
{ kubectl get pods && exit 1; }
76+
helmfile apply --suppress-diff || \
77+
{ helmfile template | kubectl -n '${{ env.NAMESPACE }}' delete -f- && \
78+
helmfile apply --suppress-diff; }
7779
7880
- uses: actions/github-script@v5
7981
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}

helm/chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

helm/chart/Chart.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: aave-caching-server
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0

helm/chart/templates/_helpers.tpl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{- define "common.env" -}}
34+
{{- with .Values.common.env }}
35+
{{ toYaml . }}
36+
{{- end }}
37+
{{- end }}
38+
39+
{{/*
40+
Common labels
41+
*/}}
42+
{{- define "common.labels" -}}
43+
{{- with .Values.common.labels }}
44+
{{- toYaml . }}
45+
{{- end }}
46+
app.kubernetes.io/managed-by: {{ .Release.Service }}
47+
{{- end }}
48+
49+
{{/*
50+
Common annotations
51+
*/}}
52+
{{- define "common.annotations" -}}
53+
{{- with .Values.common.annotations }}
54+
{{- toYaml . }}
55+
{{- end }}
56+
{{- end }}

helm/chart/templates/api.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: api
5+
labels:
6+
{{- include "common.labels" . | nindent 4 }}
7+
component: api
8+
annotations:
9+
{{- include "common.annotations" . | nindent 4 }}
10+
spec:
11+
strategy:
12+
type: RollingUpdate
13+
rollingUpdate:
14+
maxSurge: 1
15+
maxUnavailable: 0
16+
replicas: 1
17+
selector:
18+
matchLabels:
19+
component: api
20+
template:
21+
metadata:
22+
annotations:
23+
{{- with .Values.api.podAnnotations }}
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
{{- include "common.annotations" . | nindent 8 }}
27+
labels:
28+
{{- include "common.labels" . | nindent 8 }}
29+
component: api
30+
spec:
31+
automountServiceAccountToken: false
32+
enableServiceLinks: false
33+
containers:
34+
- name: api
35+
env:
36+
- name: REDIS_HOST
37+
value: redis
38+
{{- include "common.env" . | nindent 12 }}
39+
image: "{{ .Values.common.image }}"
40+
imagePullPolicy: Always
41+
ports:
42+
- name: http
43+
containerPort: 3000
44+
protocol: TCP
45+
livenessProbe:
46+
httpGet:
47+
path: '/.well-known/apollo/server-health'
48+
port: http
49+
initialDelaySeconds: 5
50+
periodSeconds: 10
51+
successThreshold: 1
52+
timeoutSeconds: 3
53+
failureThreshold: 5
54+
readinessProbe:
55+
httpGet:
56+
path: '/.well-known/apollo/server-health'
57+
port: http
58+
initialDelaySeconds: 5
59+
periodSeconds: 10
60+
successThreshold: 1
61+
timeoutSeconds: 3
62+
failureThreshold: 5
63+
resources:
64+
{{- toYaml .Values.api.resources | nindent 12 }}
65+
securityContext:
66+
capabilities:
67+
drop:
68+
- ALL
69+
---
70+
apiVersion: v1
71+
kind: Service
72+
metadata:
73+
name: api
74+
labels:
75+
{{- include "common.labels" . | nindent 4 }}
76+
component: api
77+
annotations:
78+
{{- include "common.annotations" . | nindent 4 }}
79+
spec:
80+
type: ClusterIP
81+
ports:
82+
- port: 3000
83+
targetPort: http
84+
protocol: TCP
85+
name: http-3000
86+
selector:
87+
component: api

helm/chart/templates/ingress.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: main
5+
labels:
6+
{{- include "common.labels" . | nindent 4 }}
7+
annotations:
8+
{{- with .Values.ingress.annotations }}
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
{{- include "common.annotations" . | nindent 4 }}
12+
spec:
13+
ingressClassName: nginx
14+
tls:
15+
- hosts:
16+
- {{ .Values.ingress.domain | quote }}
17+
rules:
18+
- host: {{ .Values.ingress.domain | quote }}
19+
http:
20+
paths:
21+
- path: /
22+
pathType: Prefix
23+
backend:
24+
service:
25+
name: api
26+
port:
27+
name: http-3000

helm/chart/templates/redis.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: redis
5+
labels:
6+
{{- include "common.labels" . | nindent 4 }}
7+
component: redis
8+
annotations:
9+
{{- include "common.annotations" . | nindent 4 }}
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
component: redis
15+
template:
16+
metadata:
17+
annotations:
18+
{{- with .Values.redis.podAnnotations }}
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
{{- include "common.annotations" . | nindent 8 }}
22+
labels:
23+
{{- include "common.labels" . | nindent 8 }}
24+
component: redis
25+
spec:
26+
automountServiceAccountToken: false
27+
enableServiceLinks: false
28+
containers:
29+
- name: redis
30+
image: "{{ .Values.redis.image }}"
31+
imagePullPolicy: Always
32+
ports:
33+
- name: redis
34+
containerPort: 6379
35+
protocol: TCP
36+
resources:
37+
{{- toYaml .Values.redis.resources | nindent 12 }}
38+
---
39+
apiVersion: v1
40+
kind: Service
41+
metadata:
42+
name: redis
43+
labels:
44+
{{- include "common.labels" . | nindent 4 }}
45+
component: redis
46+
annotations:
47+
{{- include "common.annotations" . | nindent 4 }}
48+
spec:
49+
type: ClusterIP
50+
ports:
51+
- port: 6379
52+
targetPort: redis
53+
protocol: TCP
54+
name: redis
55+
selector:
56+
component: redis

0 commit comments

Comments
 (0)