Kubernetes
Hyperterse is a standalone binary, so you can run it in a Kubernetes cluster. It requires no external dependencies, it can also be easily scaled up and down.
Quick start
Section titled “Quick start”-
Build and push image
Terminal window # Export bundlehyperterse export -f my-query-gateway.terse -o dist# Build imagedocker build -t your-registry/my-query-gateway:latest .# Push to registrydocker push your-registry/my-query-gateway:latest -
Create secrets
Terminal window kubectl create secret generic my-query-gateway-secrets \--from-literal=DATABASE_URL="postgresql://user:pass@db:5432/app"
Kubernetes manifests
Section titled “Kubernetes manifests”apiVersion: apps/v1kind: Deploymentmetadata: name: my-query-gateway labels: app: my-query-gatewayspec: replicas: 3 selector: matchLabels: app: my-query-gateway template: metadata: labels: app: my-query-gateway spec: containers: - name: my-query-gateway image: your-registry/hyperterse:latest ports: - containerPort: 8080 envFrom: - secretRef: name: my-query-gateway-secrets resources: requests: memory: '128Mi' cpu: '100m' limits: memory: '512Mi' cpu: '500m' livenessProbe: httpGet: path: /heartbeat port: 8080 initialDelaySeconds: 5 periodSeconds: 10 readinessProbe: httpGet: path: /heartbeat port: 8080 initialDelaySeconds: 5 periodSeconds: 5apiVersion: v1kind: Servicemetadata: name: my-query-gatewayspec: selector: app: my-query-gateway ports: - port: 80 targetPort: 8080 type: ClusterIPapiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: my-query-gateway annotations: kubernetes.io/ingress.class: nginx cert-manager.io/cluster-issuer: letsencrypt-prodspec: tls: - hosts: - api.example.com secretName: my-query-gateway-tls rules: - host: api.example.com http: paths: - path: / pathType: Prefix backend: service: name: my-query-gateway port: number: 80Apply manifests
Section titled “Apply manifests”-
Apply all manifests
Terminal window kubectl apply -f deployment.yamlkubectl apply -f service.yamlkubectl apply -f ingress.yaml -
Verify deployment
Terminal window kubectl get pods -l app=my-query-gatewaykubectl get svc my-query-gatewaykubectl get ingress my-query-gateway
Secrets management
Section titled “Secrets management”-
Create secrets
secrets.yaml apiVersion: v1kind: Secretmetadata:name: my-query-gateway-secretstype: OpaquestringData:DATABASE_URL: 'postgresql://user:pass@db:5432/app' -
Apply secrets
Terminal window kubectl apply -f secrets.yaml
External secrets operator
Section titled “External secrets operator”For production, use External Secrets with AWS Secrets Manager, HashiCorp Vault, etc.:
apiVersion: external-secrets.io/v1beta1kind: ExternalSecretmetadata: name: my-query-gateway-secretsspec: refreshInterval: 1h secretStoreRef: kind: ClusterSecretStore name: aws-secrets target: name: my-query-gateway-secrets data: - secretKey: DATABASE_URL remoteRef: key: prod/my-query-gateway/database-urlScaling
Section titled “Scaling”Horizontal pod autoscaler
Section titled “Horizontal pod autoscaler”apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata: name: my-query-gatewayspec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-query-gateway minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70Health checks
Section titled “Health checks”The deployment includes probes:
- Liveness: Restarts unhealthy pods
- Readiness: Removes from load balancing during startup
Both use the /heartbeat endpoint which returns a simple success response.
Rolling updates
Section titled “Rolling updates”-
Configure rolling update strategy
Add to your deployment:
spec:strategy:type: RollingUpdaterollingUpdate:maxUnavailable: 1maxSurge: 1 -
Update image
Terminal window kubectl set image deployment/my-query-gateway \my-query-gateway=your-registry/my-query-gateway:v1.2.0 -
Monitor rollout
Terminal window kubectl rollout status deployment/my-query-gateway
Monitoring
Section titled “Monitoring”Prometheus metrics
Section titled “Prometheus metrics”Add annotations for Prometheus scraping:
template: metadata: annotations: prometheus.io/scrape: 'true' prometheus.io/port: '8080'Network policies
Section titled “Network policies”Restrict traffic:
apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: my-query-gateway-policyspec: podSelector: matchLabels: app: my-query-gateway policyTypes: - Ingress - Egress ingress: - from: - namespaceSelector: matchLabels: name: ingress-nginx ports: - port: 8080 egress: - to: - namespaceSelector: matchLabels: name: database ports: - port: 5432