swadhinbiswas

[email protected]
2026-07-10 10:30:00 +0600 committed NaN years ago
f04bfef
commit f04bfef
17 files changed
+942 -0
▼Dockerfile
+52-0
1
+# =============================================================================
2
+# Stage 1: Build the Rust CLI binary and Python wheel
3
+# =============================================================================
4
+FROM rust:1.75-bookworm AS builder
5
+
6
+# Install dependencies including python for building maturin wheels
7
+RUN apt-get update && apt-get install -y --no-install-recommends \
8
+ libssl-dev pkg-config python3 python3-pip python3-venv \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+WORKDIR /app
12
+
13
+# Cache dependencies
14
+COPY Cargo.toml Cargo.lock ./
15
+COPY crates/ crates/
16
+COPY python/ python/
17
+
18
+RUN python3 -m venv /opt/venv
19
+ENV PATH="/opt/venv/bin:$PATH"
20
+
21
+RUN pip install maturin
22
+
23
+# Build the Rust CLI
24
+RUN cargo build --release -p justapi-cli --features tls,compression
25
+RUN strip target/release/justapi
26
+
27
+# Build the Python wheel
28
+RUN maturin build -m crates/justapi-py/Cargo.toml --release -o wheels/
29
+
30
+# =============================================================================
31
+# Stage 2: Minimal runtime image with Python
32
+# =============================================================================
33
+FROM python:3.12-slim-bookworm
34
+
35
+RUN apt-get update && apt-get install -y --no-install-recommends \
36
+ ca-certificates libssl3 \
37
+ && rm -rf /var/lib/apt/lists/*
38
+
39
+WORKDIR /app
40
+
41
+# Copy CLI binary
42
+COPY --from=builder /app/target/release/justapi /usr/local/bin/justapi
43
+
44
+# Copy and install the wheel
45
+COPY --from=builder /app/wheels /tmp/wheels
46
+RUN pip install --no-cache-dir /tmp/wheels/*.whl && rm -rf /tmp/wheels
47
+
48
+COPY demo_app.py /app/
49
+
50
+EXPOSE 8080
51
+
52
+ENTRYPOINT ["python", "demo_app.py"]
0
53
▼deploy/clouds/aks.md
+87-0
1
+# Deploy JustAPI to Azure Kubernetes Service (AKS)
2
+
3
+## Prerequisites
4
+
5
+- `az` CLI installed and authenticated
6
+- `kubectl` installed
7
+- `helm` installed (v3+)
8
+
9
+## 1. Create an AKS cluster
10
+
11
+```bash
12
+RESOURCE_GROUP="justapi-rg"
13
+CLUSTER_NAME="justapi-aks"
14
+
15
+az group create --name $RESOURCE_GROUP --location eastus
16
+
17
+az aks create \
18
+ --resource-group $RESOURCE_GROUP \
19
+ --name $CLUSTER_NAME \
20
+ --node-count 3 \
21
+ --enable-cluster-autoscaler \
22
+ --min-count 2 \
23
+ --max-count 10 \
24
+ --node-vm-size Standard_D2s_v3 \
25
+ --generate-ssh-keys
26
+```
27
+
28
+## 2. Get credentials
29
+
30
+```bash
31
+az aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME
32
+```
33
+
34
+## 3. Install NGINX Ingress Controller
35
+
36
+```bash
37
+helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
38
+helm repo update
39
+
40
+helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx \
41
+ --namespace ingress-nginx --create-namespace
42
+```
43
+
44
+## 4. Install cert-manager
45
+
46
+```bash
47
+helm repo add jetstack https://charts.jetstack.io
48
+helm repo update
49
+helm upgrade --install cert-manager jetstack/cert-manager \
50
+ --namespace cert-manager --create-namespace \
51
+ --set installCRDs=true
52
+```
53
+
54
+## 5. Build and push to Azure Container Registry
55
+
56
+```bash
57
+# Create ACR if needed
58
+az acr create --resource-group $RESOURCE_GROUP --name justapiacr --sku Basic
59
+az acr login --name justapiacr
60
+
61
+docker build -t justapiacr.azurecr.io/justapi:latest .
62
+docker push justapiacr.azurecr.io/justapi:latest
63
+```
64
+
65
+## 6. Attach ACR to AKS
66
+
67
+```bash
68
+az aks update --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --attach-acr justapiacr
69
+```
70
+
71
+## 7. Deploy with Helm
72
+
73
+```bash
74
+helm upgrade --install justapi ./helm/justapi \
75
+ --set image.repository=justapiacr.azurecr.io/justapi \
76
+ --set image.tag=latest \
77
+ --set secrets.db.url="postgres://..." \
78
+ --set secrets.redis.url="redis://..."
79
+```
80
+
81
+## Verification
82
+
83
+```bash
84
+kubectl get svc ingress-nginx-controller -n ingress-nginx
85
+# Get the external IP
86
+curl http://<external-ip>/health
87
+```
0
88
▼deploy/clouds/eks.md
+75-0
1
+# Deploy JustAPI to Amazon EKS
2
+
3
+## Prerequisites
4
+
5
+- `aws` CLI installed and configured
6
+- `eksctl` installed
7
+- `kubectl` installed
8
+- `helm` installed (v3+)
9
+
10
+## 1. Create an EKS cluster
11
+
12
+```bash
13
+CLUSTER_NAME="justapi-cluster"
14
+REGION="us-west-2"
15
+
16
+eksctl create cluster \
17
+ --name $CLUSTER_NAME \
18
+ --region $REGION \
19
+ --nodegroup-name standard-workers \
20
+ --node-type t3.medium \
21
+ --nodes 3 \
22
+ --nodes-min 2 \
23
+ --nodes-max 10 \
24
+ --managed
25
+```
26
+
27
+## 2. Configure kubectl
28
+
29
+```bash
30
+aws eks update-kubeconfig --region $REGION --name $CLUSTER_NAME
31
+```
32
+
33
+## 3. Install AWS Load Balancer Controller
34
+
35
+```bash
36
+helm repo add eks https://aws.github.io/eks-charts
37
+helm repo update
38
+
39
+helm upgrade --install aws-load-balancer-controller eks/aws-load-balancer-controller \
40
+ --namespace kube-system \
41
+ --set clusterName=$CLUSTER_NAME
42
+```
43
+
44
+## 4. Build and push to ECR
45
+
46
+```bash
47
+ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
48
+aws ecr create-repository --repository-name justapi --region $REGION || true
49
+
50
+docker build -t $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/justapi:latest .
51
+aws ecr get-login-password --region $REGION | \
52
+ docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com
53
+docker push $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/justapi:latest
54
+```
55
+
56
+## 5. Deploy with Helm
57
+
58
+```bash
59
+helm upgrade --install justapi ./helm/justapi \
60
+ --set image.repository=$ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/justapi \
61
+ --set image.tag=latest \
62
+ --set ingress.className=alb \
63
+ --set ingress.annotations."alb\.ingress\.kubernetes\.io/scheme"=internet-facing \
64
+ --set ingress.annotations."alb\.ingress\.kubernetes\.io/target-type"=ip \
65
+ --set secrets.db.url="postgres://..." \
66
+ --set secrets.redis.url="redis://..."
67
+```
68
+
69
+## Verification
70
+
71
+```bash
72
+kubectl get ingress
73
+# The ALB DNS name will appear in the ADDRESS field
74
+curl https://<alb-dns>/health
75
+```
0
76
▼deploy/clouds/flyio.md
+68-0
1
+# Deploy JustAPI to Fly.io
2
+
3
+## Prerequisites
4
+
5
+- `flyctl` CLI installed and authenticated
6
+
7
+## 1. Create a `fly.toml`
8
+
9
+```toml
10
+app = "justapi-app"
11
+primary_region = "iad"
12
+
13
+[build]
14
+ dockerfile = "Dockerfile"
15
+
16
+[http_service]
17
+ internal_port = 8080
18
+ force_https = true
19
+ auto_stop_machines = true
20
+ auto_start_machines = true
21
+ min_machines_running = 2
22
+
23
+[[services]]
24
+ port = 80
25
+ handlers = ["http"]
26
+ [services.concurrency]
27
+ type = "requests"
28
+ hard_limit = 1000
29
+ soft_limit = 500
30
+
31
+ [[services.ports]]
32
+ port = 443
33
+ handlers = ["tls"]
34
+
35
+[env]
36
+ RUST_LOG = "info"
37
+ DATABASE_URL = "postgres://..."
38
+ REDIS_URL = "redis://..."
39
+```
40
+
41
+## 2. Launch the app
42
+
43
+```bash
44
+flyctl launch --no-deploy
45
+flyctl deploy
46
+```
47
+
48
+## 3. Scale
49
+
50
+```bash
51
+flyctl scale count 3
52
+flyctl scale vm shared-cpu-1x
53
+```
54
+
55
+## 4. Attach a Fly Postgres database
56
+
57
+```bash
58
+flyctl postgres create
59
+flyctl postgres attach <pg-app-name>
60
+```
61
+
62
+## Verification
63
+
64
+```bash
65
+flyctl open
66
+# or
67
+curl https://justapi-app.fly.dev/health
68
+```
0
69
▼deploy/clouds/gke.md
+88-0
1
+# Deploy JustAPI to Google Kubernetes Engine (GKE)
2
+
3
+## Prerequisites
4
+
5
+- `gcloud` CLI installed and authenticated
6
+- `kubectl` installed
7
+- `helm` installed (v3+)
8
+- A GCP project with billing enabled
9
+
10
+## 1. Create a GKE cluster
11
+
12
+```bash
13
+PROJECT_ID="your-project-id"
14
+gcloud config set project $PROJECT_ID
15
+
16
+gcloud container clusters create justapi-cluster \
17
+ --region us-central1 \
18
+ --num-nodes 3 \
19
+ --machine-type e2-standard-2 \
20
+ --enable-autoscaling --min-nodes 3 --max-nodes 10
21
+```
22
+
23
+## 2. Get cluster credentials
24
+
25
+```bash
26
+gcloud container clusters get-credentials justapi-cluster --region us-central1
27
+```
28
+
29
+## 3. Install NGINX Ingress Controller
30
+
31
+```bash
32
+helm upgrade --install ingress-nginx ingress-nginx \
33
+ --repo https://kubernetes.github.io/ingress-nginx \
34
+ --namespace ingress-nginx --create-namespace
35
+```
36
+
37
+## 4. Install cert-manager for TLS
38
+
39
+```bash
40
+helm repo add jetstack https://charts.jetstack.io
41
+helm repo update
42
+helm upgrade --install cert-manager jetstack/cert-manager \
43
+ --namespace cert-manager --create-namespace \
44
+ --set installCRDs=true
45
+```
46
+
47
+## 5. Build and push Docker image
48
+
49
+```bash
50
+# Build for linux/amd64
51
+docker build -t gcr.io/$PROJECT_ID/justapi:latest .
52
+docker push gcr.io/$PROJECT_ID/justapi:latest
53
+```
54
+
55
+## 6. Deploy with Helm
56
+
57
+```bash
58
+helm upgrade --install justapi ./helm/justapi \
59
+ --set image.repository=gcr.io/$PROJECT_ID/justapi \
60
+ --set image.tag=latest \
61
+ --set ingress.hosts[0].host=api.yourdomain.com \
62
+ --set secrets.db.url="postgres://..." \
63
+ --set secrets.redis.url="redis://..."
64
+```
65
+
66
+## 7. Expose via Cloud Load Balancer
67
+
68
+The NGINX ingress will provision a GCP HTTP(S) Load Balancer automatically.
69
+
70
+```bash
71
+kubectl get ingress
72
+# Wait for the ADDRESS field to populate
73
+```
74
+
75
+## 8. Configure DNS
76
+
77
+Point your domain's A record to the load balancer IP (or use `external-dns` for automatic DNS).
78
+
79
+## Verification
80
+
81
+```bash
82
+curl https://api.yourdomain.com/health
83
+# {"status":"healthy","components":[]}
84
+curl https://api.yourdomain.com/ready
85
+# {"ready":true}
86
+curl https://api.yourdomain.com/live
87
+# {"alive":true}
88
+```
0
89
▼deploy/clouds/railway.md
+71-0
1
+# Deploy JustAPI to Railway
2
+
3
+## Prerequisites
4
+
5
+- Railway account (railway.app)
6
+- `railway` CLI installed
7
+
8
+## 1. Set up the project
9
+
10
+```bash
11
+# Login
12
+railway login
13
+
14
+# Initialize in your JustAPI project directory
15
+railway init
16
+```
17
+
18
+## 2. Configure `railway.toml`
19
+
20
+```toml
21
+[build]
22
+ builder = "DOCKERFILE"
23
+ dockerfile_path = "Dockerfile"
24
+
25
+[deploy]
26
+ restartPolicyType = "ON_FAILURE"
27
+ healthcheckPath = "/health"
28
+ healthcheckTimeout = 5
29
+
30
+[[service]]
31
+ name = "justapi"
32
+ port = 8080
33
+
34
+[[service]]
35
+ name = "postgres"
36
+ image = "postgres:16-alpine"
37
+ [service.env]
38
+ POSTGRES_USER = "justapi"
39
+ POSTGRES_PASSWORD = "justapi"
40
+ POSTGRES_DB = "justapi"
41
+```
42
+
43
+## 3. Add environment variables
44
+
45
+```bash
46
+railway vars set RUST_LOG=info
47
+railway vars set DATABASE_URL=$(railway vars get postgres://...)
48
+```
49
+
50
+## 4. Deploy
51
+
52
+```bash
53
+railway up
54
+# The CLI will build and deploy your application
55
+
56
+railway domain
57
+# Get the public URL
58
+```
59
+
60
+## 5. Scale (Railway Pro)
61
+
62
+```bash
63
+railway scale 3
64
+```
65
+
66
+## Verification
67
+
68
+```bash
69
+curl https://<your-app>.railway.app/health
70
+# {"status":"healthy","components":[]}
71
+```
0
72
▼docker-compose.yml
+61-0
1
+version: "3.9"
2
+
3
+services:
4
+ justapi:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ ports:
9
+ - "8080:8080"
10
+ environment:
11
+ - RUST_LOG=info
12
+ - DATABASE_URL=postgres://justapi:justapi@db:5432/justapi
13
+ - REDIS_URL=redis://redis:6379
14
+ - JAEGER_AGENT_HOST=jaeger
15
+ - JAEGER_AGENT_PORT=6831
16
+ depends_on:
17
+ db:
18
+ condition: service_healthy
19
+ redis:
20
+ condition: service_started
21
+ volumes:
22
+ - ./python:/app/python:ro
23
+ restart: unless-stopped
24
+
25
+ db:
26
+ image: postgres:16-alpine
27
+ environment:
28
+ POSTGRES_USER: justapi
29
+ POSTGRES_PASSWORD: justapi
30
+ POSTGRES_DB: justapi
31
+ ports:
32
+ - "5432:5432"
33
+ volumes:
34
+ - pgdata:/var/lib/postgresql/data
35
+ healthcheck:
36
+ test: ["CMD-SHELL", "pg_isready -U justapi"]
37
+ interval: 5s
38
+ timeout: 5s
39
+ retries: 5
40
+
41
+ redis:
42
+ image: redis:7-alpine
43
+ ports:
44
+ - "6379:6379"
45
+ healthcheck:
46
+ test: ["CMD", "redis-cli", "ping"]
47
+ interval: 5s
48
+ timeout: 3s
49
+ retries: 5
50
+
51
+ jaeger:
52
+ image: jaegertracing/all-in-one:latest
53
+ ports:
54
+ - "16686:16686"
55
+ - "4318:4318"
56
+ - "6831:6831/udp"
57
+ environment:
58
+ - COLLECTOR_OTLP_ENABLED=true
59
+
60
+volumes:
61
+ pgdata:
0
62
▼helm/justapi/Chart.yaml
+18-0
1
+apiVersion: v2
2
+name: justapi
3
+description: Helm chart for JustAPI — high-performance Python web framework
4
+type: application
5
+version: 0.1.0
6
+appVersion: "0.1.0"
7
+home: https://github.com/anomalyco/justapi
8
+sources:
9
+ - https://github.com/anomalyco/justapi
10
+maintainers:
11
+ - name: JustAPI Team
12
13
+keywords:
14
+ - python
15
+ - web
16
+ - framework
17
+ - rust
18
+ - high-performance
0
19
▼helm/justapi/templates/_helpers.tpl
+60-0
1
+{{/*
2
+Expand the name of the chart.
3
+*/}}
4
+{{- define "justapi.name" -}}
5
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6
+{{- end }}
7
+
8
+{{/*
9
+Create a default fully qualified app name.
10
+*/}}
11
+{{- define "justapi.fullname" -}}
12
+{{- if .Values.fullnameOverride }}
13
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14
+{{- else }}
15
+{{- $name := default .Chart.Name .Values.nameOverride }}
16
+{{- if contains $name .Release.Name }}
17
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18
+{{- else }}
19
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20
+{{- end }}
21
+{{- end }}
22
+{{- end }}
23
+
24
+{{/*
25
+Create chart name and version as used by the chart label.
26
+*/}}
27
+{{- define "justapi.chart" -}}
28
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29
+{{- end }}
30
+
31
+{{/*
32
+Common labels
33
+*/}}
34
+{{- define "justapi.labels" -}}
35
+helm.sh/chart: {{ include "justapi.chart" . }}
36
+{{ include "justapi.selectorLabels" . }}
37
+{{- if .Chart.AppVersion }}
38
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39
+{{- end }}
40
+app.kubernetes.io/managed-by: {{ .Release.Service }}
41
+{{- end }}
42
+
43
+{{/*
44
+Selector labels
45
+*/}}
46
+{{- define "justapi.selectorLabels" -}}
47
+app.kubernetes.io/name: {{ include "justapi.name" . }}
48
+app.kubernetes.io/instance: {{ .Release.Name }}
49
+{{- end }}
50
+
51
+{{/*
52
+Create the name of the service account to use
53
+*/}}
54
+{{- define "justapi.serviceAccountName" -}}
55
+{{- if .Values.serviceAccount.create }}
56
+{{- default (include "justapi.fullname" .) .Values.serviceAccount.name }}
57
+{{- else }}
58
+{{- default "default" .Values.serviceAccount.name }}
59
+{{- end }}
60
+{{- end }}
0
61
▼helm/justapi/templates/configmap.yaml
+10-0
1
+{{- if .Values.configMap.enabled }}
2
+apiVersion: v1
3
+kind: ConfigMap
4
+metadata:
5
+ name: {{ include "justapi.fullname" . }}-config
6
+ labels:
7
+ {{- include "justapi.labels" . | nindent 4 }}
8
+data:
9
+ {{- toYaml .Values.configMap.data | nindent 2 }}
10
+{{- end }}
0
11
▼helm/justapi/templates/deployment.yaml
+106-0
1
+apiVersion: apps/v1
2
+kind: Deployment
3
+metadata:
4
+ name: {{ include "justapi.fullname" . }}
5
+ labels:
6
+ {{- include "justapi.labels" . | nindent 4 }}
7
+spec:
8
+ {{- if not .Values.autoscaling.enabled }}
9
+ replicas: {{ .Values.replicaCount }}
10
+ {{- end }}
11
+ selector:
12
+ matchLabels:
13
+ {{- include "justapi.selectorLabels" . | nindent 6 }}
14
+ template:
15
+ metadata:
16
+ {{- with .Values.podAnnotations }}
17
+ annotations:
18
+ {{- toYaml . | nindent 8 }}
19
+ {{- end }}
20
+ labels:
21
+ {{- include "justapi.labels" . | nindent 8 }}
22
+ {{- with .Values.podLabels }}
23
+ {{- toYaml . | nindent 8 }}
24
+ {{- end }}
25
+ spec:
26
+ {{- with .Values.imagePullSecrets }}
27
+ imagePullSecrets:
28
+ {{- toYaml . | nindent 8 }}
29
+ {{- end }}
30
+ serviceAccountName: {{ include "justapi.serviceAccountName" . }}
31
+ securityContext:
32
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
33
+ containers:
34
+ - name: {{ .Chart.Name }}
35
+ securityContext:
36
+ {{- toYaml .Values.securityContext | nindent 12 }}
37
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
38
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
39
+ command:
40
+ {{- toYaml .Values.image.command | nindent 12 }}
41
+ args:
42
+ {{- toYaml .Values.image.args | nindent 12 }}
43
+ ports:
44
+ - name: http
45
+ containerPort: {{ .Values.service.port }}
46
+ protocol: TCP
47
+ livenessProbe:
48
+ httpGet:
49
+ path: {{ .Values.probes.liveness.path }}
50
+ port: http
51
+ initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
52
+ periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
53
+ timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
54
+ failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
55
+ readinessProbe:
56
+ httpGet:
57
+ path: {{ .Values.probes.readiness.path }}
58
+ port: http
59
+ initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
60
+ periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
61
+ timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
62
+ failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
63
+ startupProbe:
64
+ httpGet:
65
+ path: {{ .Values.probes.startup.path }}
66
+ port: http
67
+ initialDelaySeconds: {{ .Values.probes.startup.initialDelaySeconds }}
68
+ periodSeconds: {{ .Values.probes.startup.periodSeconds }}
69
+ timeoutSeconds: {{ .Values.probes.startup.timeoutSeconds }}
70
+ failureThreshold: {{ .Values.probes.startup.failureThreshold }}
71
+ env:
72
+ {{- toYaml .Values.env | nindent 12 }}
73
+ {{- if .Values.configMap.enabled }}
74
+ - name: RUST_LOG
75
+ valueFrom:
76
+ configMapKeyRef:
77
+ name: {{ include "justapi.fullname" . }}-config
78
+ key: RUST_LOG
79
+ - name: OTEL_SERVICE_NAME
80
+ valueFrom:
81
+ configMapKeyRef:
82
+ name: {{ include "justapi.fullname" . }}-config
83
+ key: OTEL_SERVICE_NAME
84
+ {{- end }}
85
+ resources:
86
+ {{- toYaml .Values.resources | nindent 12 }}
87
+ {{- with .Values.volumeMounts }}
88
+ volumeMounts:
89
+ {{- toYaml . | nindent 12 }}
90
+ {{- end }}
91
+ {{- with .Values.volumes }}
92
+ volumes:
93
+ {{- toYaml . | nindent 8 }}
94
+ {{- end }}
95
+ {{- with .Values.nodeSelector }}
96
+ nodeSelector:
97
+ {{- toYaml . | nindent 8 }}
98
+ {{- end }}
99
+ {{- with .Values.affinity }}
100
+ affinity:
101
+ {{- toYaml . | nindent 8 }}
102
+ {{- end }}
103
+ {{- with .Values.tolerations }}
104
+ tolerations:
105
+ {{- toYaml . | nindent 8 }}
106
+ {{- end }}
0
107
▼helm/justapi/templates/hpa.yaml
+28-0
1
+{{- if .Values.autoscaling.enabled }}
2
+apiVersion: autoscaling/v2
3
+kind: HorizontalPodAutoscaler
4
+metadata:
5
+ name: {{ include "justapi.fullname" . }}
6
+ labels:
7
+ {{- include "justapi.labels" . | nindent 4 }}
8
+spec:
9
+ scaleTargetRef:
10
+ apiVersion: apps/v1
11
+ kind: Deployment
12
+ name: {{ include "justapi.fullname" . }}
13
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
14
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15
+ metrics:
16
+ - type: Resource
17
+ resource:
18
+ name: cpu
19
+ target:
20
+ type: Utilization
21
+ averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
22
+ - type: Resource
23
+ resource:
24
+ name: memory
25
+ target:
26
+ type: Utilization
27
+ averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
28
+{{- end }}
0
29
▼helm/justapi/templates/ingress.yaml
+37-0
1
+{{- if .Values.ingress.enabled -}}
2
+apiVersion: networking.k8s.io/v1
3
+kind: Ingress
4
+metadata:
5
+ name: {{ include "justapi.fullname" . }}
6
+ labels:
7
+ {{- include "justapi.labels" . | nindent 4 }}
8
+ annotations:
9
+ {{- toYaml .Values.ingress.annotations | nindent 4 }}
10
+spec:
11
+ ingressClassName: {{ .Values.ingress.className }}
12
+ {{- if .Values.ingress.tls }}
13
+ tls:
14
+ {{- range .Values.ingress.tls }}
15
+ - hosts:
16
+ {{- range .hosts }}
17
+ - {{ . | quote }}
18
+ {{- end }}
19
+ secretName: {{ .secretName }}
20
+ {{- end }}
21
+ {{- end }}
22
+ rules:
23
+ {{- range .Values.ingress.hosts }}
24
+ - host: {{ .host | quote }}
25
+ http:
26
+ paths:
27
+ {{- range .paths }}
28
+ - path: {{ .path }}
29
+ pathType: {{ .pathType }}
30
+ backend:
31
+ service:
32
+ name: {{ include "justapi.fullname" $ }}
33
+ port:
34
+ number: {{ $.Values.service.port }}
35
+ {{- end }}
36
+ {{- end }}
37
+{{- end }}
0
38
▼helm/justapi/templates/secret.yaml
+19-0
1
+apiVersion: v1
2
+kind: Secret
3
+metadata:
4
+ name: justapi-db
5
+ labels:
6
+ {{- include "justapi.labels" . | nindent 4 }}
7
+type: Opaque
8
+stringData:
9
+ url: {{ .Values.secrets.db.url | quote }}
10
+---
11
+apiVersion: v1
12
+kind: Secret
13
+metadata:
14
+ name: justapi-redis
15
+ labels:
16
+ {{- include "justapi.labels" . | nindent 4 }}
17
+type: Opaque
18
+stringData:
19
+ url: {{ .Values.secrets.redis.url | quote }}
0
20
▼helm/justapi/templates/service.yaml
+19-0
1
+apiVersion: v1
2
+kind: Service
3
+metadata:
4
+ name: {{ include "justapi.fullname" . }}
5
+ labels:
6
+ {{- include "justapi.labels" . | nindent 4 }}
7
+ {{- with .Values.service.annotations }}
8
+ annotations:
9
+ {{- toYaml . | nindent 4 }}
10
+ {{- end }}
11
+spec:
12
+ type: {{ .Values.service.type }}
13
+ ports:
14
+ - port: {{ .Values.service.port }}
15
+ targetPort: http
16
+ protocol: TCP
17
+ name: http
18
+ selector:
19
+ {{- include "justapi.selectorLabels" . | nindent 4 }}
0
20
▼helm/justapi/templates/serviceaccount.yaml
+13-0
1
+{{- if .Values.serviceAccount.create -}}
2
+apiVersion: v1
3
+kind: ServiceAccount
4
+metadata:
5
+ name: {{ include "justapi.serviceAccountName" . }}
6
+ labels:
7
+ {{- include "justapi.labels" . | nindent 4 }}
8
+ {{- with .Values.serviceAccount.annotations }}
9
+ annotations:
10
+ {{- toYaml . | nindent 4 }}
11
+ {{- end }}
12
+automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13
+{{- end }}
0
14
▼helm/justapi/values.yaml
+130-0
1
+# Default values for JustAPI Helm chart.
2
+# This is a YAML-formatted file.
3
+# Declare variables to be passed into your templates.
4
+
5
+# Number of replicas
6
+replicaCount: 2
7
+
8
+image:
9
+ repository: ghcr.io/anomalyco/justapi
10
+ tag: latest
11
+ pullPolicy: IfNotPresent
12
+ # Override the image's entrypoint command
13
+ command: []
14
+ args:
15
+ - serve
16
+ - --addr
17
+ - "0.0.0.0:8080"
18
+
19
+imagePullSecrets: []
20
+nameOverride: ""
21
+fullnameOverride: ""
22
+
23
+serviceAccount:
24
+ create: true
25
+ automount: true
26
+ annotations: {}
27
+ name: ""
28
+
29
+podAnnotations: {}
30
+podLabels: {}
31
+
32
+podSecurityContext:
33
+ fsGroup: 1000
34
+
35
+securityContext:
36
+ capabilities:
37
+ drop:
38
+ - ALL
39
+ readOnlyRootFilesystem: true
40
+ runAsNonRoot: true
41
+ runAsUser: 1000
42
+
43
+service:
44
+ type: ClusterIP
45
+ port: 8080
46
+ annotations: {}
47
+ labels: {}
48
+
49
+ingress:
50
+ enabled: true
51
+ className: nginx
52
+ annotations:
53
+ cert-manager.io/cluster-issuer: letsencrypt-prod
54
+ nginx.ingress.kubernetes.io/ssl-redirect: "true"
55
+ hosts:
56
+ - host: api.justapi.dev
57
+ paths:
58
+ - path: /
59
+ pathType: Prefix
60
+ tls:
61
+ - secretName: justapi-tls
62
+ hosts:
63
+ - api.justapi.dev
64
+
65
+resources:
66
+ limits:
67
+ cpu: 1
68
+ memory: 512Mi
69
+ requests:
70
+ cpu: 250m
71
+ memory: 128Mi
72
+
73
+autoscaling:
74
+ enabled: true
75
+ minReplicas: 2
76
+ maxReplicas: 10
77
+ targetCPUUtilizationPercentage: 70
78
+ targetMemoryUtilizationPercentage: 80
79
+
80
+# Liveness, readiness, startup probes
81
+probes:
82
+ liveness:
83
+ path: /live
84
+ initialDelaySeconds: 5
85
+ periodSeconds: 15
86
+ timeoutSeconds: 3
87
+ failureThreshold: 3
88
+ readiness:
89
+ path: /ready
90
+ initialDelaySeconds: 5
91
+ periodSeconds: 10
92
+ timeoutSeconds: 3
93
+ failureThreshold: 2
94
+ startup:
95
+ path: /live
96
+ initialDelaySeconds: 1
97
+ periodSeconds: 5
98
+ timeoutSeconds: 2
99
+ failureThreshold: 30
100
+
101
+nodeSelector: {}
102
+tolerations: []
103
+affinity: {}
104
+
105
+env:
106
+ - name: RUST_LOG
107
+ value: info
108
+ - name: DATABASE_URL
109
+ valueFrom:
110
+ secretKeyRef:
111
+ name: justapi-db
112
+ key: url
113
+ - name: REDIS_URL
114
+ valueFrom:
115
+ secretKeyRef:
116
+ name: justapi-redis
117
+ key: url
118
+
119
+configMap:
120
+ enabled: true
121
+ data:
122
+ RUST_LOG: info
123
+ OTEL_SERVICE_NAME: justapi
124
+
125
+# Secret values (provide via --set or external secrets)
126
+secrets:
127
+ db:
128
+ url: postgres://justapi:changeme@justapi-postgres:5432/justapi
129
+ redis:
130
+ url: redis://justapi-redis:6379
0
131