Kubernetes installation
eRPC can be deployed on Kubernetes using the following manifests. These examples provide a basic setup that you can customize based on your needs.
Configuration
First, create a ConfigMap and a Secret for your eRPC configuration:
apiVersion: v1
kind: ConfigMap
metadata:
name: erpc-config
data:
erpc.yaml: |
logLevel: debug
projects:
- id: main
upstreams:
- endpoint: alchemy://${ALCHEMY_API_KEY}
- endpoint: blastapi://${BLASTAPI_API_KEY}
- endpoint: https://mynode-chain-1.svc.cluster.local
---
apiVersion: v1
kind: Secret
metadata:
name: erpc-secrets
type: Opaque
stringData:
ALCHEMY_API_KEY: your-alchemy-key-here
BLASTAPI_API_KEY: your-blastapi-key-here
Deployment
Deploy eRPC with the following configuration:
apiVersion: apps/v1
kind: Deployment
metadata:
name: erpc
labels:
app: erpc
spec:
replicas: 1
selector:
matchLabels:
app: erpc
template:
metadata:
labels:
app: erpc
spec:
containers:
- name: erpc
image: ghcr.io/erpc/erpc:latest
resources:
# CPU limits removed as they can cause throttling issues
requests:
memory: "256Mi"
limits:
memory: "2Gi"
env:
- name: GOGC
value: "40"
- name: GOMEMLIMIT
value: "1900MiB"
envFrom:
- secretRef:
name: erpc-secrets
ports:
- containerPort: 4000
name: http
- containerPort: 4001
name: metrics
volumeMounts:
- name: config
mountPath: /erpc.yaml
subPath: erpc.yaml
startupProbe:
httpGet:
path: /healthcheck
port: 4000
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
readinessProbe:
httpGet:
path: /healthcheck
port: 4000
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 2
successThreshold: 1
livenessProbe:
tcpSocket:
port: 4000
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
successThreshold: 1
volumes:
- name: config
configMap:
name: erpc-config
# This must be same or greater than server.maxTimeout in erpc.yaml
terminationGracePeriodSeconds: 180
Service
Expose eRPC using a Service:
apiVersion: v1
kind: Service
metadata:
name: erpc
labels:
app: erpc
spec:
ports:
- port: 4000
name: http
targetPort: 4000
- port: 4001
name: metrics
targetPort: 4001
selector:
app: erpc
Horizontal Pod Autoscaling
Configure automatic scaling based on CPU and memory usage:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: erpc
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: erpc
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
Installation
Apply the manifests using kubectl:
# Apply the manifests
kubectl apply -f erpc-configmap.yaml
kubectl apply -f erpc-secret.yaml
kubectl apply -f erpc-deployment.yaml
kubectl apply -f erpc-service.yaml
kubectl apply -f erpc-hpa.yaml
# Verify the deployment
kubectl get pods
kubectl get services
kubectl get hpa
The eRPC service will be available within your cluster at erpc:4000
for HTTP traffic and erpc:4001
for metrics.