Kubernetes Deployment
Deploy CognitiveX on Kubernetes for enterprise-grade scalability and high availability.
Prerequisites
- Kubernetes cluster 1.24+
- kubectl configured
- Helm 3.0+ (recommended)
- Persistent storage (PVC support)
- Load balancer or ingress controller
Quick Start with Helm
bash
# Add CognitiveX Helm repository
helm repo add cognitivex https://charts.cognitivex.ai
helm repo update
# Install CognitiveX
helm install cognitivex cognitivex/cognitivex \
--namespace cognitivex \
--create-namespace \
--set apiKey=YOUR_API_KEYManual Deployment
1. Create Namespace
namespace.yamlyaml
apiVersion: v1
kind: Namespace
metadata:
name: cognitivex2. PostgreSQL StatefulSet
postgres.yamlyaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
namespace: cognitivex
spec:
serviceName: postgres
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: pgvector/pgvector:pg16
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: cognitivex
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: cognitivex-secrets
key: postgres-password
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 100Gi3. Redis Deployment
redis.yamlyaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: cognitivex
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7-alpine
ports:
- containerPort: 6379
command: ["redis-server"]
args: ["--requirepass", "$(REDIS_PASSWORD)"]
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: cognitivex-secrets
key: redis-password4. CognitiveX Deployment
cognitivex.yamlyaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: cognitivex-backend
namespace: cognitivex
spec:
replicas: 3
selector:
matchLabels:
app: cognitivex-backend
template:
metadata:
labels:
app: cognitivex-backend
spec:
containers:
- name: backend
image: cognitivex/backend:latest
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: production
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: cognitivex-secrets
key: database-url
- name: REDIS_URL
valueFrom:
secretKeyRef:
name: cognitivex-secrets
key: redis-url
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 2000m
memory: 4Gi
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 3000
initialDelaySeconds: 10
periodSeconds: 55. Ingress
ingress.yamlyaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cognitivex-ingress
namespace: cognitivex
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: nginx
tls:
- hosts:
- api.cognitivex.example.com
secretName: cognitivex-tls
rules:
- host: api.cognitivex.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: cognitivex-backend
port:
number: 3000Auto-scaling
hpa.yamlyaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: cognitivex-backend-hpa
namespace: cognitivex
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: cognitivex-backend
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80Management Commands
Deploy
bash
kubectl apply -f k8s/Check Status
bash
kubectl get pods -n cognitivex
kubectl logs -f deployment/cognitivex-backend -n cognitivexScale
bash
kubectl scale deployment cognitivex-backend --replicas=5 -n cognitivexProduction Best Practices
- • Use PersistentVolumes for stateful services
- • Configure resource requests and limits
- • Set up health checks (liveness/readiness probes)
- • Use Secrets for sensitive data
- • Enable auto-scaling with HPA
- • Configure ingress with TLS
- • Set up monitoring and logging
- • Use namespaces for isolation