Services

Overview

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.

Docker Compose Definition

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:

Common Service Types

Databases

PostgreSQL, MySQL, MongoDB, and other relational or NoSQL databases

  • Persistent storage with volumes
  • Environment variable configuration

Caches & Message Queues

Redis, Memcached, RabbitMQ, Kafka for caching and message processing

  • Fast data access
  • Asynchronous processing

Application Services

APIs, microservices, background workers running your application code

  • Multiple replicas support
  • Environment-specific configuration

Service Networking

Services within an environment can communicate with each other using their service names as DNS hostnames. This provides simple service discovery without hardcoding IPs.

Connecting to Services:

  • From Workspaces: Connect using service name and port (e.g., postgres:5432)
  • Between Services: Services in the same environment can call each other by name
  • Port Mapping: Expose specific ports for service communication

Configuration

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.

Service Lifecycle & Troubleshooting

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.

Update Flow

  1. Save the updated Compose file from the console or CLI.
  2. The controller compares the desired spec with existing Kubernetes resources.
  3. Deployments are patched; pods roll out one replica at a time to avoid downtime.
  4. Status for each service is published back to the environment dashboard.

Inspecting Runtime State

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

Troubleshooting Checklist

  • Check the environment dashboard for failed services and descriptive error messages.
  • Review recent events: kubectl get events -n env-myapp --sort-by=.lastTimestamp
  • Verify referenced ConfigMaps or Secrets exist and include the expected keys.
  • Ensure port mappings do not collide with other services inside the namespace.

Best Practices

Define Reliable Services

  • Add healthcheck probes to restart unhealthy containers quickly.
  • Prefer named volumes so data persists across redeployments.
  • Specify resource requests/limits to prevent noisy-neighbour problems.

Manage Configuration Cleanly

  • Keep credentials in Secrets and surface them in Compose via ${VAR_NAME}.
  • Use labels or annotations to surface ownership, alerts, or routing metadata.
  • Split large systems into multiple environments instead of overloading a single Compose file.