apiVersion: v1
kind: ConfigMap
metadata:
name: context-store-config
namespace: context-store
labels:
app: persistent-context-store
data:
# Application Configuration
NODE_ENV: "production"
PORT: "3000"
LOG_LEVEL: "info"
# Database Configuration
NEO4J_URI: "bolt://neo4j-service:7687"
NEO4J_DATABASE: "contextstore"
# Security Configuration
API_RATE_LIMIT: "10000"
CORS_ORIGIN: "https://contextstore.example.com"
# Performance Configuration
HEALTH_CHECK_INTERVAL: "30000"
PERFORMANCE_MONITORING: "true"
METRICS_COLLECTION: "true"
# Storage Configuration
BACKUP_DIRECTORY: "/var/backups"
BACKUP_RETENTION_DAYS: "90"
# Feature Flags
ENABLE_SEMANTIC_SEARCH: "true"
ENABLE_ANALYTICS: "true"
ENABLE_BACKUP_AUTOMATION: "true"
ENABLE_HEALTH_MONITORING: "true"
ENABLE_RATE_LIMITING: "true"
# Redis Configuration
REDIS_URL: "redis://redis-service:6379"
CACHE_TTL: "3600"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
namespace: context-store
labels:
app: nginx
data:
nginx.conf: |
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'rt=$request_time uct="$upstream_connect_time" '
'uht="$upstream_header_time" urt="$upstream_response_time"';
access_log /var/log/nginx/access.log main;
# Performance optimizations
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 10m;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_types
text/plain
text/css
application/json
application/javascript
text/xml
application/xml
application/xml+rss
text/javascript;
# Rate limiting
limit_req_zone $binary_remote_addr zone=api:10m rate=100r/m;
limit_req_zone $binary_remote_addr zone=health:10m rate=10r/s;
# Upstream configuration
upstream context-store-backend {
least_conn;
server context-store-service:3000 max_fails=3 fail_timeout=30s;
keepalive 32;
}
server {
listen 80;
server_name _;
# Security headers
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy strict-origin-when-cross-origin;
# Health check endpoint (no rate limiting)
location /health {
limit_req zone=health burst=5 nodelay;
proxy_pass http://context-store-backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 5s;
proxy_send_timeout 10s;
proxy_read_timeout 10s;
}
# API endpoints
location /api/ {
limit_req zone=api burst=20 nodelay;
proxy_pass http://context-store-backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 10s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# CORS headers
add_header Access-Control-Allow-Origin "$http_origin" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept" always;
add_header Access-Control-Allow-Credentials true always;
if ($request_method = OPTIONS) {
return 204;
}
}
# Root path
location / {
proxy_pass http://context-store-backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}