Quick Start with kubectl
Deploy a simple single-node NATS Server:StatefulSet Deployment
For production deployments with clustering and persistence, use a StatefulSet:nats-statefulset.yaml
ConfigMap for Configuration
Store NATS configuration in a ConfigMap:nats-config.yaml
Service Definitions
Headless Service for StatefulSet
External Service (LoadBalancer)
Monitoring Service
Helm Chart Deployment
The official NATS Helm chart is the recommended way to deploy NATS on Kubernetes.Installation
Add the NATS Helm repository:Custom Values
Create avalues.yaml file for customization:
values.yaml
Helm Chart Repository
The NATS Helm chart is available on ArtifactHub. View all configuration options:JetStream with Persistent Storage
For JetStream deployments, use PersistentVolumeClaims:Scaling and High Availability
Horizontal Scaling
Scale the StatefulSet:Pod Disruption Budget
Ensure availability during maintenance:nats-pdb.yaml
Anti-Affinity Rules
Distribute pods across nodes:Monitoring and Health Checks
Liveness Probe
Readiness Probe
Prometheus Metrics
Expose metrics for Prometheus:RBAC Configuration
Create ServiceAccount and permissions:nats-rbac.yaml
Upgrading
Rolling Update
Update the image version:Helm Upgrade
Namespace Isolation
Deploy NATS in a dedicated namespace:Best Practices
Use StatefulSets
Always use StatefulSets for clustered deployments to maintain stable network identities.
Configure Resource Limits
Set appropriate CPU and memory requests/limits based on your workload.
Enable Persistence
Use PersistentVolumes for JetStream to ensure data durability.
Implement Anti-Affinity
Spread pods across nodes for better fault tolerance.
Troubleshooting
Check Pod Status
View Logs
Check Cluster Formation
Verify Configuration
Next Steps
Configuration
Explore advanced configuration options
Docker Deployment
Learn about Docker-based deployments