Skip to content

Commit d7f8885

Browse files
feat(helm): production kubernetes helm chart with HPA, Ingress, and ServiceMonitor
1 parent cecefee commit d7f8885

16 files changed

Lines changed: 966 additions & 1 deletion

‎README.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Seamlessly accelerates **Poly** and **Turborepo** build pipelines across distrib
1818
## ⚡ Highlights
1919

2020
- **Multi-Engine Storage Backend**: Pluggable storage supporting **AWS S3**, **Cloudflare R2**, **MinIO**, or high-speed **Local Disk / NVMe** with atomic streaming.
21+
- **Production Kubernetes Helm Chart**: Turnkey enterprise Helm chart (`charts/poly-cloud-api`) with Horizontal Pod Autoscaler (HPA v2), Ingress with TLS, Prometheus Operator ServiceMonitor, and ConfigMaps/Secrets for AWS S3, Cloudflare R2, and MinIO.
2122
- **Intelligent LRU Auto-Eviction & Deduplication Engine**: Background Quota Monitor daemon and Least-Recently-Used (LRU) eviction engine that automatically purges stale unaccessed artifacts down to a target low-watermark threshold when workspace quotas are exceeded, while strictly preserving hot dependencies. Cross-branch SHA-256 Content Addressable Storage (CAS) deduplication prevents redundant layer storage and tracks savings in real-time.
2223
- **Direct-to-Storage Presigned S3/R2 Engine**: High-throughput direct client-to-storage uploads and downloads via short-lived presigned S3 URLs and transparent HTTP 307 redirects, eliminating server egress bandwidth bottlenecks for gigabyte-scale artifacts.
2324
- **Cryptographic Attestation & SLSA Provenance Verification**: Ed25519 DSSE / in-toto build provenance signature verification preventing supply chain cache-poisoning attacks. Enforces strict corporate policy gates (approved CI runners, platforms, and architectures) and real-time SHA-256 integrity validation.
@@ -103,6 +104,15 @@ The stack will boot:
103104
- **Poly Cloud API**: `http://localhost:8080`
104105
- **MinIO Console**: `http://localhost:9001` (User: `minioadmin`, Pass: `minioadmin`)
105106

107+
### 4. Deploy to Kubernetes with Helm
108+
109+
```bash
110+
helm install poly-cache ./charts/poly-cloud-api \
111+
--namespace poly-cache \
112+
--create-namespace \
113+
--values ./charts/poly-cloud-api/values.yaml
114+
```
115+
106116
---
107117

108118
## 🛠️ Client Configuration
@@ -288,7 +298,7 @@ Response:
288298
## 🧪 Testing & Verification
289299

290300
```bash
291-
# Run unit & integration test suite (86 tests)
301+
# Run unit & integration test suite (94 tests)
292302
npm test
293303

294304
# Run Biome formatting & linter verification

‎charts/poly-cloud-api/Chart.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: v2
2+
name: poly-cloud-api
3+
description: Production Kubernetes Helm Chart for Poly Cloud API (Enterprise Remote Cache & ROI Analytics Server)
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
home: https://github.com/RitualDev-Lab/poly-cloud-api
8+
sources:
9+
- https://github.com/RitualDev-Lab/poly-cloud-api
10+
- https://github.com/RitualDev-Lab/poly
11+
maintainers:
12+
- name: RitualDev Lab
13+
email: developer@ritualdev.in
14+
url: https://github.com/RitualDev-Lab
15+
keywords:
16+
- remote-cache
17+
- poly
18+
- turborepo
19+
- monorepo
20+
- kubernetes
21+
- enterprise
22+
- s3
23+
- r2
24+
- minio
25+
- slsa
26+
- in-toto
27+
annotations:
28+
artifacthub.io/license: Apache-2.0
29+
artifacthub.io/category: developer-tools
30+
artifacthub.io/prerelease: "false"

‎charts/poly-cloud-api/README.md‎

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# ☸️ Poly Cloud API Helm Chart
2+
3+
Production-ready Kubernetes Helm Chart for **Poly Cloud API** — high-throughput, pluggable remote cache server and ROI analytics engine for Poly and Turborepo.
4+
5+
---
6+
7+
## ⚡ Features
8+
9+
- **Horizontal Pod Autoscaling (HPA)**: Auto-scales across CPU and Memory utilization targets.
10+
- **Ingress & TLS**: Seamless Ingress configuration with automatic cert-manager Let's Encrypt certificates and large-body streaming support (`2048m`).
11+
- **Prometheus ServiceMonitor**: Turnkey integration with Prometheus Operator for `/api/v1/metrics`.
12+
- **Pluggable Object Storage**: Complete ConfigMaps & Secrets for **AWS S3**, **Cloudflare R2**, and **MinIO**.
13+
- **Non-Root Security Hardened**: Runs unprivileged with `runAsNonRoot: true`, read-only root filesystems, and dropped Linux capabilities.
14+
- **High-Availability Resilience**: PodAntiAffinity and RollingUpdate zero-downtime deployment strategy.
15+
16+
---
17+
18+
## 🚀 Quickstart
19+
20+
### 1. Add Repository & Install Chart
21+
22+
```bash
23+
# Add repo or clone
24+
git clone https://github.com/RitualDev-Lab/poly-cloud-api.git
25+
cd poly-cloud-api
26+
27+
# Install chart into 'poly-cache' namespace
28+
helm install poly-cache ./charts/poly-cloud-api \
29+
--namespace poly-cache \
30+
--create-namespace \
31+
--values ./charts/poly-cloud-api/values.yaml
32+
```
33+
34+
### 2. Retrieve Admin Token
35+
36+
```bash
37+
kubectl get secret --namespace poly-cache poly-cache-poly-cloud-api-secrets \
38+
-o jsonpath="{.data.DEFAULT_ADMIN_TOKEN}" | base64 --decode
39+
```
40+
41+
### 3. Connect Poly CLI
42+
43+
```bash
44+
poly login --url https://cache.example.com --token <ADMIN_TOKEN> --workspace default
45+
poly cache status
46+
```
47+
48+
---
49+
50+
## 🛠️ Storage Backend Configurations
51+
52+
### Option A: AWS S3 with EKS IAM Roles for Service Accounts (IRSA)
53+
54+
```yaml
55+
# values-aws.yaml
56+
serviceAccount:
57+
create: true
58+
annotations:
59+
eks.amazonaws.com/role-arn: "arn:aws:iam::123456789012:role/PolyCloudCacheRole"
60+
61+
config:
62+
storageBackend: "s3"
63+
s3:
64+
bucket: "my-company-poly-cache"
65+
region: "us-east-1"
66+
```
67+
68+
### Option B: Cloudflare R2
69+
70+
```yaml
71+
# values-r2.yaml
72+
config:
73+
storageBackend: "s3"
74+
s3:
75+
bucket: "poly-cache-bucket"
76+
region: "auto"
77+
endpoint: "https://<account_id>.r2.cloudflarestorage.com"
78+
accessKeyId: "CLOUDFLARE_R2_ACCESS_KEY_ID"
79+
secretAccessKey: "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
80+
```
81+
82+
### Option C: MinIO (On-Premises or Kubernetes-Native)
83+
84+
```yaml
85+
# values-minio.yaml
86+
config:
87+
storageBackend: "s3"
88+
s3:
89+
bucket: "poly-artifacts"
90+
region: "us-east-1"
91+
endpoint: "http://minio.minio.svc.cluster.local:9000"
92+
forcePathStyle: true
93+
accessKeyId: "minioadmin"
94+
secretAccessKey: "minioadmin"
95+
```
96+
97+
### Option D: Local Disk Storage with PersistentVolumeClaim (PVC)
98+
99+
```yaml
100+
# values-local.yaml
101+
config:
102+
storageBackend: "local"
103+
104+
persistence:
105+
enabled: true
106+
storageClass: "gp3" # or local-path, ebs-sc
107+
size: 100Gi
108+
mountPath: /app/data
109+
```
110+
111+
---
112+
113+
## ⚙️ Parameters Reference
114+
115+
| Parameter | Default | Description |
116+
|:---|:---|:---|
117+
| `replicaCount` | `2` | Number of pod replicas for High Availability |
118+
| `image.repository` | `ghcr.io/ritualdev-lab/poly-cloud-api` | Container image repository |
119+
| `image.tag` | `""` (Chart appVersion) | Container image tag |
120+
| `service.type` | `ClusterIP` | Kubernetes Service type |
121+
| `service.port` | `8080` | Internal HTTP service port |
122+
| `ingress.enabled` | `true` | Enable Kubernetes Ingress controller |
123+
| `ingress.className` | `"nginx"` | Ingress class name |
124+
| `ingress.hosts` | `[cache.example.com]` | Ingress routing hostnames |
125+
| `ingress.tls` | `[poly-cloud-tls]` | TLS certificate secrets |
126+
| `autoscaling.enabled` | `true` | Enable Horizontal Pod Autoscaler (HPA v2) |
127+
| `autoscaling.minReplicas` | `2` | Minimum pod replicas |
128+
| `autoscaling.maxReplicas` | `10` | Maximum pod replicas |
129+
| `autoscaling.targetCPUUtilizationPercentage` | `75` | Target CPU utilization percentage |
130+
| `serviceMonitor.enabled` | `true` | Enable Prometheus Operator ServiceMonitor |
131+
| `serviceMonitor.interval` | `15s` | Prometheus scrape interval |
132+
| `config.storageBackend` | `"s3"` | Storage backend (`s3`, `local`, `memory`) |
133+
| `config.s3.bucket` | `"poly-remote-cache"` | S3 / R2 Bucket name |
134+
| `config.s3.region` | `"us-east-1"` | S3 region |
135+
| `config.s3.endpoint` | `""` | S3 endpoint URL (for R2 / MinIO) |
136+
| `config.presignedUrls.enabled` | `true` | Enable direct-to-storage presigned S3/R2 URLs |
137+
| `config.oidc.enabled` | `true` | Enable GitHub Actions OIDC zero-secret auth |
138+
| `config.optimizer.autoEvictionEnabled` | `true` | Enable LRU auto-eviction daemon |
139+
| `config.optimizer.deduplicationEnabled` | `true` | Enable cross-branch CAS layer deduplication |
140+
| `persistence.enabled` | `false` | Enable PersistentVolumeClaim (for local disk backend) |
141+
| `persistence.size` | `50Gi` | Size of persistent volume |
142+
143+
---
144+
145+
## 📜 License
146+
147+
Licensed under the [Apache License, Version 2.0](https://github.com/RitualDev-Lab/poly-cloud-api/blob/main/LICENSE).
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
================================================================================
2+
☁️ Poly Cloud API has been successfully deployed to Kubernetes!
3+
================================================================================
4+
5+
1. Retrieve Master Cluster Admin Token:
6+
{{- if .Values.config.existingAdminTokenSecret }}
7+
kubectl get secret --namespace {{ .Release.Namespace }} {{ .Values.config.existingAdminTokenSecret }} -o jsonpath="{.data.{{ .Values.config.adminTokenSecretKey | default "admin-token" }}}" | base64 --decode
8+
{{- else }}
9+
kubectl get secret --namespace {{ .Release.Namespace }} {{ include "poly-cloud-api.fullname" . }}-secrets -o jsonpath="{.data.DEFAULT_ADMIN_TOKEN}" | base64 --decode
10+
{{- end }}
11+
12+
2. Access the Application:
13+
{{- if .Values.ingress.enabled }}
14+
{{- range $host := .Values.ingress.hosts }}
15+
Web Dashboard: https://{{ $host.host }}/dashboard
16+
Health Probe: https://{{ $host.host }}/api/v1/health
17+
Prometheus: https://{{ $host.host }}/api/v1/metrics
18+
{{- end }}
19+
{{- else if contains "NodePort" .Values.service.type }}
20+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "poly-cloud-api.fullname" . }})
21+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
22+
echo "http://$NODE_IP:$NODE_PORT/dashboard"
23+
{{- else if contains "LoadBalancer" .Values.service.type }}
24+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
25+
kubectl get svc --namespace {{ .Release.Namespace }} {{ include "poly-cloud-api.fullname" . }} -w
26+
{{- else if contains "ClusterIP" .Values.service.type }}
27+
kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "poly-cloud-api.fullname" . }} 8080:{{ .Values.service.port }}
28+
echo "Dashboard available at: http://127.0.0.1:8080/dashboard"
29+
{{- end }}
30+
31+
3. Connect Poly CLI:
32+
poly login --url https://{{ (index .Values.ingress.hosts 0).host }} --token <TOKEN> --workspace default
33+
poly cache status
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "poly-cloud-api.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 "poly-cloud-api.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 "poly-cloud-api.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "poly-cloud-api.labels" -}}
37+
helm.sh/chart: {{ include "poly-cloud-api.chart" . }}
38+
{{ include "poly-cloud-api.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "poly-cloud-api.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "poly-cloud-api.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "poly-cloud-api.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "poly-cloud-api.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "poly-cloud-api.fullname" . }}-config
5+
labels:
6+
{{- include "poly-cloud-api.labels" . | nindent 4 }}
7+
data:
8+
HOST: "0.0.0.0"
9+
PORT: {{ .Values.service.port | quote }}
10+
STORAGE_BACKEND: {{ .Values.config.storageBackend | quote }}
11+
STORAGE_LOCAL_DIR: "{{ .Values.persistence.mountPath }}/artifacts"
12+
METADATA_DB_PATH: "{{ .Values.persistence.mountPath }}/metadata.sqlite"
13+
DEFAULT_WORKSPACE: {{ .Values.config.defaultWorkspace | quote }}
14+
AUTH_ENABLED: {{ .Values.config.authEnabled | quote }}
15+
MAX_ARTIFACT_SIZE_BYTES: {{ .Values.config.maxArtifactSizeBytes | quote }}
16+
COMPUTE_COST_PER_HOUR_USD: {{ .Values.config.computeCostPerHourUsd | quote }}
17+
18+
# S3 / Object Storage
19+
S3_BUCKET: {{ .Values.config.s3.bucket | quote }}
20+
S3_REGION: {{ .Values.config.s3.region | quote }}
21+
S3_ENDPOINT: {{ .Values.config.s3.endpoint | quote }}
22+
S3_FORCE_PATH_STYLE: {{ .Values.config.s3.forcePathStyle | quote }}
23+
24+
# Direct Presigned URLs
25+
PRESIGNED_URLS_ENABLED: {{ .Values.config.presignedUrls.enabled | quote }}
26+
PRESIGNED_EXPIRY_SECONDS: {{ .Values.config.presignedUrls.expirySeconds | quote }}
27+
PRESIGNED_REDIRECT_ON_GET: {{ .Values.config.presignedUrls.redirectOnGet | quote }}
28+
29+
# Attestation & SLSA Verification
30+
ATTESTATION_REQUIRED: {{ .Values.config.attestation.required | quote }}
31+
ATTESTATION_ALLOWED_RUNNERS: {{ .Values.config.attestation.allowedRunners | quote }}
32+
ATTESTATION_ALLOWED_ARCHS: {{ .Values.config.attestation.allowedArchs | quote }}
33+
ATTESTATION_ALLOWED_PLATFORMS: {{ .Values.config.attestation.allowedPlatforms | quote }}
34+
CHECKSUM_VERIFICATION_ENABLED: {{ .Values.config.attestation.checksumVerification | quote }}
35+
36+
# GitHub Actions OIDC Auth
37+
GITHUB_OIDC_ENABLED: {{ .Values.config.oidc.enabled | quote }}
38+
GITHUB_OIDC_AUDIENCE: {{ .Values.config.oidc.audience | quote }}
39+
GITHUB_OIDC_ALLOWED_OWNERS: {{ .Values.config.oidc.allowedOwners | quote }}
40+
GITHUB_OIDC_ALLOWED_REPOS: {{ .Values.config.oidc.allowedRepositories | quote }}
41+
GITHUB_OIDC_WRITE_BRANCHES: {{ .Values.config.oidc.writeBranches | quote }}
42+
GITHUB_OIDC_ALLOW_PR_WRITE: {{ .Values.config.oidc.allowPrWrite | quote }}
43+
GITHUB_OIDC_TOKEN_TTL: {{ .Values.config.oidc.tokenTtlSeconds | quote }}
44+
45+
# Storage Optimizer & LRU Auto-Eviction
46+
AUTO_EVICTION_ENABLED: {{ .Values.config.optimizer.autoEvictionEnabled | quote }}
47+
AUTO_EVICTION_INTERVAL_SECONDS: {{ .Values.config.optimizer.autoEvictIntervalSeconds | quote }}
48+
AUTO_EVICT_ON_WRITE: {{ .Values.config.optimizer.autoEvictOnWrite | quote }}
49+
QUOTA_HIGH_WATERMARK_RATIO: {{ .Values.config.optimizer.quotaHighWatermarkRatio | quote }}
50+
QUOTA_LOW_WATERMARK_RATIO: {{ .Values.config.optimizer.quotaLowWatermarkRatio | quote }}
51+
DEDUPLICATION_ENABLED: {{ .Values.config.optimizer.deduplicationEnabled | quote }}

0 commit comments

Comments
 (0)