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

Chore/helm #28

Merged
merged 6 commits into from
Oct 29, 2024
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
108 changes: 61 additions & 47 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,42 @@ env:
IMAGE_NAME: sedaprotocol/seda-data-proxy

jobs:
build-and-push:
name: 🐳 Build and Push Docker Images
build-and-push-amd64:
name: 🐳 Build and Push Docker Image (amd64)
runs-on: ubuntu-latest
strategy:
matrix:
target_arch:
- bun-linux-x64-modern
- bun-linux-arm64
include:
- target_arch: bun-linux-x64-modern
platform: linux/amd64
- target_arch: bun-linux-arm64
platform: linux/arm64

steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: 🏷️ Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
- name: 🔐 Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🏗️ Build and push Docker image for amd64
run: |
docker build \
--build-arg TARGET_ARCH=bun-linux-x64-modern \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-bun-linux-x64-modern \
-f .build/docker/Dockerfile \
.
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-bun-linux-x64-modern

build-and-push-arm64:
name: 🐳 Build and Push Docker Image (arm64)
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: 🛠️ Set up QEMU for ARM64
uses: docker/setup-qemu-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=Data Proxy Service for Seda Protocol
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
org.opencontainers.image.architecture=${{ matrix.target_arch }}
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.url=https://github.com/${{ github.repository }}
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
platforms: arm64

- name: 🔐 Log in to the Container registry
uses: docker/login-action@v3
Expand All @@ -61,24 +57,41 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🏗️ Build and push Docker image for ${{ matrix.target_arch }}
uses: docker/build-push-action@v5
- name: 🏗️ Build and push Docker image for arm64
run: |
docker build \
--platform linux/arm64 \
--build-arg TARGET_ARCH=bun-linux-arm64 \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-bun-linux-arm64 \
-f .build/docker/Dockerfile \
.
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-bun-linux-arm64

create-manifest:
name: 📝 Create and Push Docker Manifest
needs:
- build-and-push-amd64
- build-and-push-arm64
runs-on: ubuntu-latest

steps:
- name: 🔐 Log in to the Container registry
uses: docker/login-action@v3
with:
context: .
file: .build/docker/Dockerfile
push: true
tags: |
${{ steps.meta.outputs.tags }}-${{ matrix.target_arch }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TARGET_ARCH=${{ matrix.target_arch }}
platforms: ${{ matrix.platform }}
cache-from: type=gha
cache-to: type=gha,mode=max
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 📝 Create and Push Manifest
run: |
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} \
--amend ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-bun-linux-x64-modern \
--amend ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-bun-linux-arm64
docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}

create-release:
name: 📦 Create GitHub Release
needs: build-and-push
needs: create-manifest
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -111,4 +124,5 @@ jobs:

- [ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-x64-modern](https://ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-x64-modern)
- [ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-arm64](https://ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-arm64)
- [ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}](https://ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }})
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,5 @@ dist
.DS_Store
config.json
data-proxy-private-key.json

ubuntu-dind*
23 changes: 23 additions & 0 deletions helm/.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/
5 changes: 5 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: seda-data-proxy
description: A Helm chart for Kubernetes to deploy the SEDA Data Proxy.
version: 0.1.0
appVersion: "1.0"
31 changes: 31 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{/*
Generate a full name for the resources, optionally including the release name.
*/}}
{{- define "seda-data-proxy.fullname" -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end }}

{{/*
Common labels
*/}}
{{- define "seda-data-proxy.labels" -}}
app.kubernetes.io/name: {{ include "seda-data-proxy.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{/*
Template for the name of the application
*/}}
{{- define "seda-data-proxy.name" -}}
{{- .Chart.Name -}}
{{- end }}
15 changes: 15 additions & 0 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "seda-data-proxy.fullname" . }}-config
data:
config.json: |
{
"routes": [
{
"path": "/*",
"upstreamUrl": "https://swapi.dev/api/",
"methods": ["GET"]
}
]
}
49 changes: 49 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "seda-data-proxy.fullname" . }}
labels:
{{- include "seda-data-proxy.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "seda-data-proxy.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "seda-data-proxy.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
env:
{{- range .Values.envVars }}
- name: {{ .name }}
value: {{ .value }}
{{- end }}
- name: SEDA_DATA_PROXY_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: {{ include "seda-data-proxy.fullname" . }}-secrets
key: SEDA_DATA_PROXY_PRIVATE_KEY
args: ["run", {{ .Values.sedaProxyFlags }} ]
readinessProbe:
httpGet:
path: /status/health
port: {{ .Values.service.port }}
livenessProbe:
httpGet:
path: /status/health
port: {{ .Values.service.port }}
volumeMounts:
- name: config-volume
mountPath: /app/config.json
subPath: config.json
volumes:
- name: config-volume
configMap:
name: {{ include "seda-data-proxy.fullname" . }}-config
9 changes: 9 additions & 0 deletions helm/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "seda-data-proxy.fullname" . }}-secrets
labels:
{{- include "seda-data-proxy.labels" . | nindent 4 }}
type: Opaque
data:
SEDA_DATA_PROXY_PRIVATE_KEY: {{ .Values.secret.sedaDataProxyPrivateKey | b64enc | quote }}
13 changes: 13 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "seda-data-proxy.fullname" . }}
labels:
{{- include "seda-data-proxy.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
selector:
{{- include "seda-data-proxy.selectorLabels" . | nindent 4 }}
23 changes: 23 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
imagePullSecrets: []

image:
repository: ghcr.io/sedaprotocol/seda-data-proxy
tag: "v0.0.3"
pullPolicy: IfNotPresent
pullSecrets: {}
os: linux
arch: amd64

service:
type: ClusterIP
port: 5384

replicaCount: 1

# export SEDA_PRIVATE_KEY=<KEY>
# helm install my-release ./chart-name --set secret.sedaDataProxyPrivateKey=$SEDA_PRIVATE_KEY
secret:
sedaDataProxyPrivateKey: ""

# Uncomment for testing (itdisables request verification)
# sedaProxyFlags: "--disable-proof"
2 changes: 1 addition & 1 deletion workspace/data-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@seda-protocol/data-proxy",
"main": "./src/index.ts",
"version": "0.0.2",
"version": "0.0.3",
"devDependencies": {
"@types/big.js": "^6.2.2",
"msw": "^2.3.5"
Expand Down
Loading