Developer Documentation

Update a Config

Updating a configuration allows you to change the settings of an existing configuration. This can be useful if you want to modify the configuration of a deployment without creating a new configuration.

Info

Updating a configuration that is used in a deployment will affect all deployments that use this configuration. This is a powerful tool as it allows you to update all running servers with a new image or configuration with one command.

Usage

odin fleet configs update [--name=IMAGE_NAME] [--command=COMMAND] [--args=ARGS] [--binary-id= BINARY_ID] [--restart-policy=RESTART_POLICY] [--memory=MEMORY] [--cpu=CPU] [--payload=JSON_PAYLOAD] [--dry-run]

Flags

The command will only update the fields that are provided. If you want to update multiple fields, you can provide them all in one command. You can also provide a JSON payload to update the configuration using the usual --payload flag. This command also support the --dry-run flag to see the JSON payload that would be sent to the API without actually updating the configuration.

  • --name=<string>:
    The name of the configuration.
  • --command=<string>:
    The command that should be executed when the server starts. It overwrites the command that is defined in the image.
  • --args=<string>:
    The arguments that should be passed to the command when the server starts. It overwrites the arguments that are defined in the image.
  • --binary-id=<number>:
    The ID of the binary that should be used for the server. By changing the binary, you can update all running servers of deployments linked to this configuration file.
  • --restart-policy=<string>:
    The restart policy of the server. This can be always, on-failure, or any
  • --memory=<number>:
    The amount of memory that should be allocated to the server in GB.
  • --cpu=<number>:
    The amount of CPU that should be allocated to the server in cores.

Examples

Update the memory requirement of a configuration:

odin fleet configs update --config-id=123456 --memory=4

You can also update multiple fields at once:

odin fleet configs update --config-id=123456 --memory=4 --cpu=2

A usual use case is to update the underlying image of a configuration. This can be done by changing the binary ID of the configuration. In this more complex example, we create a new image, wait until the image is ready to be deployed and then update the configuration to use the new image which will restart all servers with the new image.

It can be used in CI/CD pipelines to update the image of a configuration and restart all servers with the new image.

#!/bin/bash

# Define the variables
IMAGE_NAME="Minecraft Java 21"
IMAGE_VERSION="1.0.1"
OS_TYPE="linux"
DOCKER_IMAGE="itzg/minecraft-server:java21"
REGISTRY_ID=1
CONFIG_ID=16

# Create a new image and get its ID
IMAGE_ID=$(./odin fleet images create \
    --name="$IMAGE_NAME" \
    --version="$IMAGE_VERSION" \
    --os="$OS_TYPE" \
    --type="steam" \
    --docker-image="$DOCKER_IMAGE" \
    --registry-id=$REGISTRY_ID \
    --format="value(id)" \
    --force)

echo "Created image with ID: $IMAGE_ID"

# Monitor the image status until it's ready
STATUS="processing"
while [[ "$STATUS" != "ready" ]]; do
    STATUS=$(./odin fleet images get --image-id=$IMAGE_ID --format="value(status)")
    echo "Current status of image $IMAGE_ID: $STATUS"

    # Check if the status is 'error', in which case we should exit with a failure
    if [[ "$STATUS" == "error" ]]; then
        echo "Error: Image creation failed. Exiting."
        exit 1
    fi

    # Wait for a few seconds before polling again
    sleep 5
done

echo "Image $IMAGE_ID is ready."

# Update the config with the new image ID
./odin fleet configs update --config-id=$CONFIG_ID --binary-id=$IMAGE_ID --force

echo "Config $CONFIG_ID has been updated to use image $IMAGE_ID."

Global Flags

The following flags can be used with any ODIN CLI command:

  • --api-key=<string>
    The API key to use for authentication. If omitted, the CLI will use the api-key stored in the configuration file on your system. Use odin login to store the API key for subsequent commands.

  • --app-id=<string>
    The ID of the app to use for the command. If omitted, the CLI will use the currently selected app. Use odin apps select to select an app interactively.

  • --format=<string>
    The output format to use for the command. Supported formats are json, value, flattened and table. If omitted, the CLI will use the default format specified in the configuration file. Learn more about output formatting.

  • --force
    Forces the command to execute without prompting for confirmation. Use with caution.

  • --quiet
    Suppresses all informational output except for errors. Useful for scripting and automation.