> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.adid.dev/llms.txt.
> For full documentation content, see https://docs.adid.dev/llms-full.txt.

# Kubernetes Deployment

Deploy IDA to a Kubernetes cluster for production use.

## Prerequisites

| Tool               | Version |
| ------------------ | ------- |
| kubectl            | 1.28+   |
| Helm               | 3.14+   |
| Kubernetes cluster | 1.28+   |

## Quick Deploy

```bash
# Add IDA Helm repo
helm repo add ida https://charts.ida.infinia.io
helm repo update

# Install IDA
helm install ida ida/ida-platform \
  --namespace ida \
  --create-namespace \
  --values values-production.yaml
```

## Namespace Structure

```
ida/
  ida-api (Deployment, 3 replicas)
  ida-resolver (Deployment, 2 replicas)
  ida-portal (Deployment, 2 replicas)
  postgres (StatefulSet, 1 replica)
  redis (StatefulSet, 1 replica)
  nats (StatefulSet, 3 replicas)

ida-blockchain/
  adi-node-validator-0 (StatefulSet)
  adi-node-validator-1 (StatefulSet)
  adi-node-observer-0 (StatefulSet)
```

## Manual Deployment (kubectl)

### Namespace

```yaml
apiVersion: v1
kind: Namespace
metadata:
  name: ida
```

### API Deployment

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ida-api
  namespace: ida
spec:
  replicas: 3
  selector:
    matchLabels:
      app: ida-api
  template:
    metadata:
      labels:
        app: ida-api
    spec:
      containers:
        - name: ida-api
          image: infinia/ida-api:latest
          ports:
            - containerPort: 8080
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: ida-secrets
                  key: database-url
            - name: REDIS_URL
              value: redis://redis:6379
            - name: ADI_RPC_URL
              value: http://adi-node-validator-0.ida-blockchain:8545
            - name: NATS_URL
              value: nats://nats:4222
            - name: LOG_LEVEL
              value: info
          resources:
            requests:
              cpu: 500m
              memory: 512Mi
            limits:
              cpu: 2000m
              memory: 2Gi
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 15
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: ida-api
  namespace: ida
spec:
  selector:
    app: ida-api
  ports:
    - port: 8080
      targetPort: 8080
  type: ClusterIP
```

### Ingress

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ida-ingress
  namespace: ida
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rate-limit: "100"
spec:
  tls:
    - hosts:
        - api.ida.infinia.io
        - portal.ida.infinia.io
      secretName: ida-tls
  rules:
    - host: api.ida.infinia.io
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: ida-api
                port:
                  number: 8080
    - host: portal.ida.infinia.io
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: ida-portal
                port:
                  number: 80
```

### Secrets

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: ida-secrets
  namespace: ida
type: Opaque
stringData:
  database-url: postgres://ida:password@postgres:5432/ida?sslmode=require
  redis-password: redis-secret
  api-signing-key: your-signing-key
```

## Helm Chart Values

### values-production.yaml

```yaml
global:
  environment: production
  domain: ida.infinia.io

api:
  replicas: 3
  image:
    repository: infinia/ida-api
    tag: "1.0.0"
  resources:
    requests:
      cpu: 500m
      memory: 512Mi
    limits:
      cpu: 2000m
      memory: 2Gi
  autoscaling:
    enabled: true
    minReplicas: 3
    maxReplicas: 10
    targetCPU: 70

resolver:
  replicas: 2
  image:
    repository: infinia/ida-resolver
    tag: "1.0.0"

portal:
  replicas: 2
  image:
    repository: infinia/ida-portal
    tag: "1.0.0"

postgres:
  enabled: true
  persistence:
    size: 100Gi
    storageClass: gp3

redis:
  enabled: true
  persistence:
    size: 10Gi

nats:
  enabled: true
  replicas: 3

blockchain:
  validators: 2
  observers: 1
  persistence:
    size: 500Gi

monitoring:
  enabled: true
  prometheus:
    enabled: true
  grafana:
    enabled: true

ingress:
  enabled: true
  className: nginx
  tls: true
  certManager: true
```

## Monitoring

### Prometheus ServiceMonitor

```yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: ida-api
  namespace: ida
spec:
  selector:
    matchLabels:
      app: ida-api
  endpoints:
    - port: metrics
      interval: 15s
      path: /metrics
```

## Scaling

```bash
# Scale API replicas
kubectl scale deployment ida-api --replicas=5 -n ida

# Enable HPA
kubectl autoscale deployment ida-api --min=3 --max=10 --cpu-percent=70 -n ida
```