Skip to main content

Configuring sloctl

Reading time: 0 minute(s) (0 words)

This guide will walk you through configuring sloctl, enabling seamless access to your reliability metrics and simplifying SLO management across your infrastructure.

Using sloctl for SLO management requires authentication.

Authentication prerequisites

Prepare a Client ID and Client secret pair for use in sloctl. For this:

  1. In the Nobl9 Web, go to Settings > Access keys.

  2. Click Create access key.

    Secure your client secret

    The client secret is only displayed at this step. Ensure it's available for authentication.

  3. Download a generated file with credentials and save it at:

    • ~/.config/nobl9/ on Linux and macOS
    • %UserProfile%\.config\nobl9\ on Windows

The generated config.toml file contains your details necessary for sloctl authentication:

defaultContext = "default"

[Contexts]
[Contexts.default]
clientId = "YOUR_CLIENT_ID"
clientSecret = "YOUR_CLIENT_SECRET"
project = "default"
FieldDescription
defaultContextThe default context to use if none is specified when running sloctl commands
clientIdThe client ID for API authorization with your sloctl access key
clientSecretThe client secret for API authorization with your sloctl access key
projectThe default project to use if none is specified when running sloctl commands

With your authentication prerequisites in place, you can now authenticate sloctl either directly on your local system or using a Docker container.

Authenticating sloctl

  1. Run sloctl config add-context, providing:
    • Context name, for example, production, sandbox, default, or any other that fits your needs
    • The client ID and client secret generated for your sloctl access key
    • Your required default project's name identifier
  2. To verify successful authentication, run sloctl get slos. You will receive one of these responses:
ResponseReason
No resources found in default projectAuthentication succeeded. No SLOs exist
List of SLOsAuthentication succeeded. SLOs exist
Error 401Authentication failed. To troubleshoot, verify the following:
  • Your credentials are correct
  • config.toml is located in the configuration directory
  • Customizing timeout and prompt

    You can set your custom timeout and prompt threshold per context to be applied with the sloctl apply and sloctl delete commands. For this, specify the required values in the config.toml file for your context, as follows:

    [Contexts.production]
    clientId = "your-value"
    clientSecret = "your-value"
    project = "customer-facing-applications"
    organization = "flower-market"
    timeout = "1m" # Maximum value = 1 minute. If set to >1m, it defaults to 1m.
    filesPromptThreshold = "30" # Custom threshold for applying multiple files.
    filesPromptEnabled = "false" # Enable/disable prompt for applying multiple files.

    Docker authentication for sloctl

    Nobl9's sloctl image is published on Docker Hub. You can leverage it to integrate Nobl9 in the CI/CD pipelines.

    Follow these steps to use the sloctl image:

    1. Pull the latest sloctl docker image. For this, run:
      docker pull nobl9/sloctl:latest
    2. Test if the image is pulled successfully. Run:
      docker run nobl9/sloctl:latest --help

    If the command executes without errors and displays the help documentation, it confirms that the Docker image was pulled correctly and is functioning as expected.

    Using the sloctl image for SLO and other Nobl9 resource management requires authentication. You can authenticate in either of the following ways:

    • Pass your config.toml file
    • Pass your credentials with environment variables

    Before authenticating with config.toml, make sure you have it locally. When using Docker, you can store this file in any location on your system.

    To pass your configuration to the Docker container:

    1. Move config.toml to a directory of your choice.
    2. Set the N9_AUTH environment variable to the absolute path of the directory where your config.toml is located:
    export N9_AUTH='/absolute/path/to/directory'

    To test your authentication configuration with Docker:

    1. Run the Docker container with the -v flag.
    2. This flag bind mounts your configuration directory into the container.
    3. Syntax: docker run -v /local/config/path:/container/config/path nobl9/sloctl:latest [command].

    Example:

    docker run -v ~/.config/nobl9:/root/.config/nobl9 nobl9/sloctl:latest get slos

    sloctl is expecting to find your config file at /home/appuser/.config/nobl9 from within the container.

    Using sloctl with Docker

    sloctl is the entrypoint for the Docker container, so it's the default command that runs when the sloctl container starts.

    When using Docker with sloctl:

    • Provide arguments or subcommands directly (e.g., docker run nobl9/sloctl:latest --help)
    • Run any sloctl command following this pattern:
    docker run -v $N9_AUTH:/home/appuser/.config/nobl9 nobl9/sloctl:latest <sloctl command>