ctlptl

repository·main·Indexed 20 days ago

https://github.com/tilt-dev/ctlptl

A CLI tool by tilt-dev for managing local Kubernetes clusters and registries. It supports provisioning clusters via products like docker-desktop, kind, and minikube, creating containerized registries, and applying cluster configurations. The tool includes built-in shell autocompletion generation for bash, fish, zsh, and PowerShell, as well as analytics management.

Tokens
8.7K
Snippets
58
Records
67
Agent score
70%

What's inside ctlptl

  1. Configure permanent ctlptl completions for zsh

    main

    To make ctlptl autocompletions available in every new zsh session, you must write the completion script to a directory in your $fpath. Use the command corresponding to your operating system:

    Linux

    ctlptl completion zsh > "${fpath[1]}/_ctlptl"

    macOS

    ctlptl completion zsh > $(brew --prefix)/share/zsh/site-functions/_ctlptl

    Note: You must start a new shell session for these changes to take effect.

    # Linux
    ctlptl completion zsh > "${fpath[1]}/_ctlptl"
    
    # macOS
    ctlptl completion zsh > $(brew --prefix)/share/zsh/site-functions/_ctlptl
  2. Install ctlptl via Command-line (macOS, Linux, Windows)

    main

    You can download and install the binaries directly using curl or Invoke-WebRequest depending on your operating system.

    # macOS
    CTLPTL_VERSION="0.9.4"
    curl -fsSL https://github.com/tilt-dev/ctlptl/releases/download/v$CTLPTL_VERSION/ctlptl.$CTLPTL_VERSION.mac.x86_64.tar.gz | sudo tar -xzv -C /usr/local/bin ctlptl
    
    # Linux
    CTLPTL_VERSION="0.9.4"
    curl -fsSL https://github.com/tilt-dev/ctlptl/releases/download/v$CTLPTL_VERSION/ctlptl.$CTLPTL_VERSION.linux.x86_64.tar.gz | sudo tar -xzv -C /usr/local/bin ctlptl
    # Windows
    $CTLPTL_VERSION = "0.9.4"
    Invoke-WebRequest "https://github.com/tilt-dev/ctlptl/releases/download/v$CTLPTL_VERSION/ctlptl.$CTLPTL_VERSION.windows.x86_64.zip" -OutFile "ctlptl.zip"
    Expand-Archive "ctlptl.zip" -DestinationPath "ctlptl"
    Move-Item -Force -Path "ctlptl\ctlptl.exe" -Destination "$home\bin\ctlptl.exe"
  3. Enable bash autocompletion for ctlptl

    main

    You can generate autocompletion scripts for the bash shell using the ctlptl completion bash command. This requires the bash-completion package to be installed on your system.

    Load completions for the current session

    To immediately use completions in your active terminal, run:

    source <(ctlptl completion bash)

    Enable completions permanently

    To ensure completions are available in every new shell session, redirect the output to your system's bash completion directory. You will need to start a new shell for the changes to take effect.

    On Linux:

    ctlptl completion bash > /etc/bash_completion.d/ctlptl

    On macOS:

    ctlptl completion bash > $(brew --prefix)/etc/bash_completion.d/ctlptl
    ctlptl completion bash
  4. Use ctlptl to manage local Kubernetes clusters

    main

    The ctlptl CLI tool allows you to manage and manipulate local Kubernetes clusters safely. You can use it to inspect currently running clusters or apply cluster configurations defined in YAML files.

    # List all currently running clusters
    ctlptl get clusters
    
    # Apply a cluster configuration from a file
    ctlptl apply -f my-cluster.yaml
  5. Set Docker Desktop settings with ctlptl docker-desktop set

    main

    Use the ctlptl docker-desktop set command to modify Docker Desktop configuration settings.

    Arguments:

    1. KEY: The full path to the specific setting you want to change.
    2. VALUE: The desired value for that setting.

    Note on Data Types:

    • Most settings accept scalar values (e.g., numbers or booleans).
    • List-based settings, such as vm.fileSharing, require a comma-separated string of values (e.g., /path1,/path2).
    # Set CPU count
    ctlptl docker-desktop set vm.resources.cpus 2
    
    # Enable or disable Kubernetes
    ctlptl docker-desktop set kubernetes.enabled false
    
    # Configure file sharing paths (comma-separated list)
    ctlptl docker-desktop set vm.fileSharing /Users,/Volumes,/private,/tmp
  6. Delete a running cluster with ctlptl delete

    main

    Use the ctlptl delete command to remove a currently running cluster. You can specify the cluster via a configuration file using the -f or --filename flag, or by providing the cluster name directly as an argument.

    # Delete a cluster defined in a YAML file
    ctlptl delete -f cluster.yaml
    
    # Delete a specific cluster by name
    ctlptl delete cluster minikube