Consul K8s CLI Reference

Consul K8s CLI is a tool for quickly installing and interacting with Consul on Kubernetes. This topic describes the commands, subcommands, and available options for using Consul K8s CLI.

Consul K8s CLI is is currently availabe as a beta release and is not recommended for production environments.

Download and Build the Binary

  1. Clone the consul-k8s project.

  2. Navigate to the consul-k8s/cli directory and issue the following command to build the tool:

    1. go build -o bin/consul-k8s
  3. (Optional) Move the binary to you $PATH for ease of use, e.g.:

    1. mv consul-k8s /usr/local/bin/consul-k8s
  4. (Optional) Issue the consul-k8s version command to verify the installation:

    1. consul-k8s version
    2. consul-k8s 0.35.0

Usage

Consul K8s CLI uses the following syntax:

  1. consul-k8s <SUBCOMMAND> <OPTIONS>

Subcommands

You can use the following subcommands with consul-k8s.

install

The install command installs Consul on Kubernetes.

  1. consul-k8s install <OPTIONS>

The following options are available.

FlagDescriptionDefaultRequired
-auto-approve                                    Boolean value that enables you to skip the installation confirmation prompt.falseOptional
-dry-runBoolean value that validates the installation and returns a summary.falseOptional
-config-fileString value that specifies the path to a file containing custom installation configurations, e.g., Consul Helm chart values file.
You can use the -config-file flag multiple times to specify multiple files.
noneOptional
-namespaceString value that specifies the namespace of the Consul installation.consulOptional
-presetString value that installs Consul based on a preset configuration. You can specify the following values:
demo: Installs a single replica server with sidecar injection enabled; useful for testing service mesh functionality.
secure: Installs a single replica server with sidecar injection, ACLs, and TLS enabled; useful for testing service mesh functionality.
Configuration of the Consul Helm chart.Optional
-setString value that enables you to set a customizeable value. This flag is comparable to the helm install —set flag.
You can use the -set flag multiple times to set multiple values.
Consul Helm chart values are supported.
noneOptional
-set-fileString value that specifies the name of an arbitrary config file. This flag is comparable to the helm install —set-file
flag. The contents of the file will be used to set a customizeable value. You can use the -set-file flag multiple times to specify multiple files.
Consul Helm chart values are supported.
noneOptional
-set-stringString value that enables you to set a customizeable string value. This flag is comparable to the helm install —set-string
flag. You can use the -set-string flag multiple times to specify multiple strings.
Consul Helm chart values are supported.
noneOptional
-timeoutSpecifies how long to wait for the installation process to complete before timing out. The value is specified with an integer and string value indicating a unit of time.
The following units are supported:
ms (milliseconds)
s (seconds)
m (minutes)
In the following example, installation will timeout after one minute:
consul-k8s install -timeout 1m
Optional10m
-waitBoolean value that determines if Consul should wait for resources in the installation to be ready before exiting the command.Optionaltrue
-verbose, -vBoolean value that specifies whether to output verbose logs from the install command with the status of resources being installed.Optionalfalse
—helpPrints usage information for this option.noneOptional

See Global Options for additional commands that you can use when installing Consul on Kubernetes.

Example Commands

The following example command installs Consul according in the myNS namespace according to the secure preset.

  1. consul-k8s install -preset=secure -namespace=myNS

The following example commands install Consul on Kubernetes using custom values, files, or strings that are set via flags. The underlying Consul-on-Kubernetes Helm chart uses the flags to customize the installation. The flags are comparable to the helm install flags.

  1. consul-k8s install -set key=value
  2. consul-k8s install -set key1=value1 -set key2=value2
  3. consul-k8s install -set-file config1=value1.conf
  4. consul-k8s install -set-file config1=value1.conf -set-file config2=value2.conf
  5. consul-k8s install -set-string key=value-bool
  6. consul-k8s install -set key1=value1 -set key2=value2

uninstall

The uninstall command removes Consul from Kubernetes.

  1. consul-k8s uninstall <OPTIONS>

The following options are available.

FlagDescriptionDefaultRequired
-auto-approve                                    Boolean value that enables you to skip the removal confirmation prompt.falseOptional
-nameString value for the name of the installation to remove.noneOptional
-namespaceString value that specifies the namespace of the Consul installation to remove.consulOptional
-timeoutSpecifies how long to wait for the removal process to complete before timing out. The value is specified with an integer and string value indicating a unit of time.
The following units are supported:
ms (milliseconds)
s (seconds)
m (minutes)
h (hours)
In the following example, removal will timeout after one minute:
consul-k8s uninstall -timeout 1m
Optional10m
-wipe-dataBoolan value that deletes PVCs and secrets associated with the Consul installation during installation.
Data will be removed without a verification prompt if the -auto-approve flag is set to true.
false
Instructions for removing data will be printed to the console.
Optional
—helpPrints usage information for this option.noneOptional

See Global Options for additional commands that you can use when uninstalling Consul from Kubernetes.

Example Command

The following example command immediately uninstalls Consul from the my-ns namespace with the name my-consul and removes PVCs and secrets associated with the installation without asking for verification:

  1. consul-k8s uninstall -namespace=my-ns -name=my-consul -wipe-data=true -auto-approve=true

version

The version command prints the Consul version.

  1. consul-k8s version

This command does not take any options.

You can also print the version with the --version flag.

  1. consul-k8s --version

Global Options

The following global options are available.

FlagDescriptionDefaultRequired
-context                  String value that sets the Kubernetes context to use for Consul K8s CLI operations.noneOptional
-kubeconfig
Alias: -c
String value that specifies the path to the kubeconfig file.
noneOptional