Services are the applications and infrastructure components that run within your environments. They are defined using Docker Compose and can include databases, caches, APIs, message queues, and any other containerized services your application needs.
Environment Services
Services run in the environment's namespace and are accessible to workspaces connected to that environment. Each service gets its own DNS name for easy discovery.
Services are defined using standard Docker Compose syntax. Kloudlite processes your compose file and deploys the services to the environment.
Example: Database and Cache Services
services:
postgres:
image: postgres:16
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: myapp
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
volumes:
postgres-data:
redis-data:PostgreSQL, MySQL, MongoDB, and other relational or NoSQL databases
Redis, Memcached, RabbitMQ, Kafka for caching and message processing
APIs, microservices, background workers running your application code
Services within an environment can communicate with each other using their service names as DNS hostnames. This provides simple service discovery without hardcoding IPs.
postgres:5432)Services can be configured using environment variables, volumes, and other Docker Compose features. Configuration can reference environment-level configs and secrets.
Best Practice
Use environment variables for configuration and mount volumes for data persistence. Reference configs and secrets defined at the environment level for sensitive data.
Every time you edit the Docker Compose definition, the Composition controller reconciles the spec and performs a rolling update. Understanding that lifecycle makes it easier to predict behaviour and diagnose issues when something fails to deploy.
Use Kubernetes tooling when you need deeper visibility into the namespace created for your environment (default pattern: env-{environment-name}).
kubectl get pods -n env-myapp
kubectl logs deployment/api -n env-myapp
kubectl describe pod api-6d7f8c -n env-myapp
kubectl get events -n env-myapp --sort-by=.lastTimestamphealthcheck probes to restart unhealthy containers quickly.${VAR_NAME}.