Skip to main content

Deployments

Deploying your applications on Molnett is designed to be straightforward, flexible, and integrate seamlessly with your development workflows. You define your service using a YAML configuration file and deploy it using our CLI (molnctl).

Service Definition File

At the core of a Molnett deployment is the service definition file (commonly named molnett.yaml, but any .yaml file is acceptable). This file describes how Molnett should run your application, including its containers, ports, environment variables, and more.

The structure of this file is based on Molnett's TenantServiceV2 API, giving you access to a rich set of configuration options.

Example molnett.yaml:

name: your-service-name # The desired name for your service in Molnett

containers:
- name: main-app-container # A unique name for this container within the service
image: your-registry/your-app-image:latest # Full image path from a container registry
type: main # Optional: Can be 'main' or 'sidecar'. Defaults to 'main' if only one container.

command: ["/app/start_server"] # Optional: Override the default container command
args: ["--port", "8080"] # Optional: Arguments for the command

environment: # Define environment variables for this container
- key: APP_MODE
value: "production"
- key: DATABASE_HOST
value: "internal-db.local"

secrets: # Reference secrets stored securely in Molnett
- key: API_KEY # The environment variable name in your container
value: "my-app-api-key-secret-name" # The name of the secret as stored in Molnett

ports:
- target: 8080 # The port your application listens on inside the container
publish: true # If true, Molnett will assign a public URL to this port
- target: 9090 # Another internal port, not published externally
publish: false

cpu: 1 # Optional: Number of vCPU cores (e.g., 0.5, 1, 2).
memory: 512 # Optional: Memory in MiB (e.g., 256, 512, 1024).

volume_mounts: # Optional: Mount volumes defined below into this container
- volume_name: shared-assets
path: /usr/share/assets # Path inside the container where the volume will be mounted
- volume_name: temp-data
path: /tmp

- name: logging-sidecar # Example of a second container (e.g., a sidecar)
image: fluent/fluent-bit:latest
type: sidecar
environment:
- key: FLUENT_CONFIG
value: "/etc/fluent-bit/fluent-bit.conf"
volume_mounts:
- volume_name: shared-assets # Sidecars can share volumes
path: /mnt/logs-from-main
- volume_name: fluent-config
path: /etc/fluent-bit

volumes: # Optional: Define volumes that can be mounted by containers in this service
- name: shared-assets # This volume can be mounted by multiple containers
- name: temp-data # Another volume, perhaps for temporary storage
- name: fluent-config # A volume to store configuration for the sidecar

host_aliases: # Optional: Add custom entries to /etc/hosts within your service containers
- ip: "10.0.0.10"
hostnames:
- "my-internal-database.local"
- "db.prod.internal"
- ip: "10.0.0.11"
hostnames:
- "my-caching-service.local"

Key Configuration Fields

  • name: (Required) The unique name for your service within your Molnett project and environment.
  • containers: (Required) A list of one or more containers that make up your service.
    • name: (Required) A name for the container within the service.
    • image: (Required) The Docker image to run.
    • type: (Optional) Type of container, e.g., main or sidecar.
    • command / args: (Optional) Override the container's default CMD or ENTRYPOINT.
    • environment: (Optional) List of key-value pairs for environment variables.
    • secrets: (Optional) List of key-value pairs to map Molnett-managed secrets to environment variables. The value is the name of the secret in Molnett.
    • ports: (Optional) Define ports your container exposes.
      • target: The port your application listens on inside the container.
      • publish: If true, Molnett makes this port accessible externally via a generated URL or a custom domain.
    • cpu / memory: (Optional) Request CPU cores and memory (in MiB) for the container.
    • volume_mounts: (Optional) Mount volumes (defined at the service level) into the container.
      • volume_name: Name of the volume to mount.
      • path: Path inside the container where the volume is mounted.
  • volumes: (Optional) Define named volumes. These provide shared, persistent (lifetime of the service instance) storage that can be mounted by one or more containers in the service. Note: True persistent storage across deployments/restarts (like for databases) will be a future addition. Currently, these volumes are ephemeral to the service instance.
  • host_aliases: (Optional) Add custom DNS records to the containers' /etc/hosts file for service discovery or specific routing needs within the service.

Deploying with molnctl

Once your molnett.yaml is defined, you deploy it using the CLI:

  1. Select your Project and Environment:

    molnctl select project <your-project-name-or-id>
    molnctl select environment <your-environment-name-or-id>
  2. Apply the configuration:

    molnctl apply -f molnett.yaml

    Or, if your file has a different name:

    molnctl apply -f my-service-config.yaml

Molnett will then provision the necessary resources and start your service. You can monitor the status using molnctl get service <your-service-name>.

Updating a Service

To update a running service, simply modify your molnett.yaml file and re-run the molnctl apply -f molnett.yaml command. Molnett will perform a rolling update to apply your changes with minimal downtime.

Deleting a Service

To remove a service from an environment:

molnctl delete service <your-service-name>