Kubernetes Installation
Deploy DBCraft on Kubernetes for production-grade reliability, scalability, and high availability.
Prerequisites
- Kubernetes cluster (EKS, GKE, AKS, or self-managed)
kubectlconfigured with cluster access- StorageClass configured for PersistentVolumeClaims
- Ingress controller (nginx, traefik) for external access
Installation Steps
1
Create Namespace
Create a dedicated namespace for DBCraft:
namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: dbcraft
labels:
app.kubernetes.io/name: dbcraftTerminal
kubectl apply -f namespace.yaml2
Create Secrets
Create a secret for sensitive configuration:
secrets.yaml
apiVersion: v1
kind: Secret
metadata:
name: dbcraft-secrets
namespace: dbcraft
type: Opaque
stringData:
JWT_SECRET: "your-secure-secret-key-at-least-32-characters-long"Security
Generate a strong random JWT_SECRET. Never commit secrets to version control. Consider using external secret management (AWS Secrets Manager, HashiCorp Vault).
Terminal
kubectl apply -f secrets.yaml3
Create Persistent Volume
Create a PersistentVolumeClaim for data storage:
pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dbcraft-data
namespace: dbcraft
spec:
accessModes:
- ReadWriteOnce
storageClassName: gp3 # Adjust for your cloud provider
resources:
requests:
storage: 10GiAdjust storageClassName for your cloud provider: AWS (gp3), GCP (standard), Azure (default).
Terminal
kubectl apply -f pvc.yaml4
Create Deployment
Deploy DBCraft with health checks and resource limits:
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: dbcraft
namespace: dbcraft
labels:
app.kubernetes.io/name: dbcraft
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: dbcraft
template:
metadata:
labels:
app.kubernetes.io/name: dbcraft
spec:
securityContext:
fsGroup: 1000
initContainers:
- name: fix-permissions
image: busybox
command: ["sh", "-c", "chown -R 1000:1000 /app/data"]
volumeMounts:
- name: data
mountPath: /app/data
containers:
- name: dbcraft
image: krishcdbry/dbcraft:v0.4.4
imagePullPolicy: Always
ports:
- name: http
containerPort: 9000
protocol: TCP
env:
- name: PORT
value: "9000"
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: dbcraft-secrets
key: JWT_SECRET
- name: LOG_LEVEL
value: "info"
volumeMounts:
- name: data
mountPath: /app/data
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /api/v1/health
port: http
initialDelaySeconds: 10
periodSeconds: 30
readinessProbe:
httpGet:
path: /api/v1/health
port: http
initialDelaySeconds: 5
periodSeconds: 10
volumes:
- name: data
persistentVolumeClaim:
claimName: dbcraft-dataTerminal
kubectl apply -f deployment.yaml5
Create Service
Expose DBCraft within the cluster:
service.yaml
apiVersion: v1
kind: Service
metadata:
name: dbcraft
namespace: dbcraft
labels:
app.kubernetes.io/name: dbcraft
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: dbcraftTerminal
kubectl apply -f service.yaml6
Create Ingress (Optional)
Expose DBCraft externally with TLS:
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dbcraft
namespace: dbcraft
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- hosts:
- dbcraft.yourdomain.com
secretName: dbcraft-tls
rules:
- host: dbcraft.yourdomain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: dbcraft
port:
number: 80DNS & TLS
Ensure your domain points to your Ingress controller's IP/load balancer. This example uses cert-manager for automatic TLS certificates.
Terminal
kubectl apply -f ingress.yamlVerify Installation
Check that all resources are running:
Terminal
# Check pods
kubectl get pods -n dbcraft
# Check deployment
kubectl get deployment -n dbcraft
# View logs
kubectl logs -f deployment/dbcraft -n dbcraft
# Port forward for local testing
kubectl port-forward svc/dbcraft 3001:80 -n dbcraftCloud-Specific Notes
AWS EKS
- • StorageClass:
gp3 - • Use ALB Ingress Controller
- • Consider AWS Secrets Manager
GCP GKE
- • StorageClass:
standard - • Use GCP Ingress
- • Consider Secret Manager
Azure AKS
- • StorageClass:
default - • Use AGIC Ingress
- • Consider Key Vault
