Deployment Guide
Infrastructure Setup
Prerequisites
Kubernetes Cluster
- Version 1.24+
- Minimum 3 nodes
- Resource requirements per node:
- 4 vCPUs
- 8GB RAM
- 100GB storage
Required Tools
# Version requirements
kubectl version 1.24+
helm version 3+
terraform version 1.0+Access Configuration
# Configure kubectl
kubectl config use-context your-cluster-context
# Verify access
kubectl cluster-info
Core Components
1. Namespace Setup
# namespaces.yaml
apiVersion: v1
kind: Namespace
metadata:
name: kol-network
labels:
name: kol-network
environment: production
2. Storage Configuration
# storage-class.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: kol-network-storage
provisioner: kubernetes.io/your-storage-provisioner
parameters:
type: ssd
replication-type: none
3. Network Policies
# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: kol-network-policy
spec:
podSelector:
matchLabels:
app: matrix
policyTypes:
- Ingress
- Egress
# ... policy rules
Application Deployment
Matrix Server Deployment
1. Helm Configuration
# values.yaml
matrix:
image:
repository: matrixdotorg/synapse
tag: latest
resources:
requests:
cpu: 2
memory: 4Gi
limits:
cpu: 4
memory: 8Gi
persistence:
enabled: true
size: 20Gi
2. Database Setup
# postgres-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
data:
postgresql.conf: |
max_connections = 100
shared_buffers = 2GB
# ... more postgres config
3. Redis Cache
# redis-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
data:
redis.conf: |
maxmemory 2gb
maxmemory-policy allkeys-lru
Monitoring Setup
1. Prometheus Configuration
# prometheus-values.yaml
prometheus:
alertmanager:
enabled: true
pushgateway:
enabled: true
nodeExporter:
enabled: true
2. Grafana Dashboards
# grafana-values.yaml
grafana:
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server
Security Configuration
1. TLS Setup
# certificate.yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: kol-network-cert
spec:
secretName: kol-network-tls
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
2. Secret Management
# secrets-config.yaml
apiVersion: v1
kind: Secret
metadata:
name: kol-network-secrets
type: Opaque
data:
# ... encrypted secrets
Deployment Process
1. Infrastructure Setup
# Create namespace
kubectl apply -f namespaces.yaml
# Setup storage
kubectl apply -f storage-class.yaml
# Apply network policies
kubectl apply -f network-policy.yaml
2. Core Services
# Deploy database
helm install postgres bitnami/postgresql -f postgres-values.yaml
# Deploy Redis
helm install redis bitnami/redis -f redis-values.yaml
# Deploy Matrix
helm install matrix matrix/synapse -f matrix-values.yaml
3. Monitoring
# Deploy Prometheus
helm install prometheus prometheus-community/prometheus -f prometheus-values.yaml
# Deploy Grafana
helm install grafana grafana/grafana -f grafana-values.yaml
Post-Deployment Verification
1. System Check
# Check pods
kubectl get pods -n kol-network
# Check services
kubectl get services -n kol-network
# Check ingress
kubectl get ingress -n kol-network
2. Health Checks
# Database connectivity
kubectl exec -it postgres-0 -- psql -U postgres -c "\l"
# Matrix server health
curl -k https://matrix.your-domain/_matrix/client/versions
3. Monitoring Verification
# Access Grafana
kubectl port-forward svc/grafana 3000:80
# Check Prometheus targets
kubectl port-forward svc/prometheus-server 9090:80
Backup Configuration
1. Database Backups
# backup-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: db-backup
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: postgres:14
command: ["pg_dump"]
2. Matrix Data Backup
# Backup script
#!/bin/bash
BACKUP_DIR="/backups"
DATE=$(date +%Y%m%d)
# Backup Matrix data
matrix-admin-tools backup \
--config /etc/matrix-synapse/homeserver.yaml \
--backup-dir $BACKUP_DIR/$DATE
Maintenance Procedures
1. Updates
# Update Matrix
helm upgrade matrix matrix/synapse -f matrix-values.yaml
# Update dependencies
helm dependency update
2. Scaling
# Scale Matrix pods
kubectl scale deployment matrix --replicas=3
# Scale database
kubectl scale statefulset postgres --replicas=3
3. Monitoring
# Check resource usage
kubectl top pods -n kol-network
# View logs
kubectl logs -f deployment/matrix