2 Using the CLI

Introduces the Oracle Cloud Native Environment CLI (ocne command), which is used to create and manage Kubernetes clusters.

This chapter contains information on using the CLI.

Getting Syntax Help

Learn how to get help with CLI syntax.

All ocne commands include the option to display help on the syntax. If you enter the ocne command without any options, the help is displayed:

ocne

The output is similar to:

The ocne tool manages an ocne environment

Usage:
  ocne [command]

Available Commands:
  application Manage ocne applications
  catalog     Manage ocne catalogs
  cluster     Manage ocne clusters
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  image       Manage ocne images
  node        Manage ocne nodes

Flags:
  -h, --help               help for ocne
  -l, --log-level string   Sets the log level.  Valid values are "error", "info", "debug", and "trace". (default "info")

Use "ocne [command] --help" for more information about a command.

Use the --help or -h option with each command to display the help about a command. For example:

ocne cluster --help

Or, use the ocne help command. For example:

ocne help cluster

The output is similar to:

Manage the lifecycle of ocne clusters and application deployment.

Usage:
  ocne cluster [flags]
  ocne cluster [command]

Examples:

ocne cluster <subcommand>


Available Commands:
  analyze     Analyze the cluster and report problems
  backup      Backup the etcd database
  console     Launch a console on a node
  delete      Destroy a cluster
  dump        Dump the cluster
  info        Get cluster information
  join        Join a node to a cluster, or generate the materials required to do so
  list        List clusters
  show        Show cluster configuration
  stage       Stage a cluster update to a specified k8s version
  start       Start an OCNE cluster
  template    Outputs a cluster configuration template
  update      Updates the version of a cluster

Flags:
  -h, --help                help for cluster
  -k, --kubeconfig string   the kubeconfig filepath

Global Flags:
  -l, --log-level string   Sets the log level.  Valid values are "error", "info", "debug", and "trace". (default "info")

Use "ocne cluster [command] --help" for more information about a command.

Prefix Matching

Learn how to use prefix matching in the CLI.

You can use prefix matching for any unambiguous prefix for an ocne command. For example, you can use the following instead of the full ocne cluster start command:

ocne cl s
ocne clu star

Instead of typing the full ocne application list command, you could use:

ocne ap l

Another example would be for the ocne catalog list command, you could use:

ocne ca l

Command Line Completion

Learn how to use command line completion with the CLI.

You can set up command line completion for the ocne command. If command line completion isn't set up by default, use the ocne completion command to generate a command line completion script for the shell.

For example, to generate a command line completion script for the Bash shell on Oracle Linux, run:

ocne completion bash

The generated command line completion script must be saved to /etc/bash_completion.d/ocne.

You can generate the script and save it to the correct location using:

ocne completion bash | sudo tee /etc/bash_completion.d/ocne

Start a new shell session for this to take effect. This also requires the bash-completion package to be installed on the system.

Environment Variables

Learn how to use environment variables in the CLI.

You can use environment variables to set options that are used in some ocne commands. The environment variables used are:

  • KUBECONFIG Sets the location of the kubeconfig file. This behaves the same way as the --kubeconfig option for most ocne commands. For example:

    export KUBECONFIG=$HOME/.kube/kubeconfig.ocne.local
  • EDITOR Sets the default document editor. For example:

    export EDITOR=/usr/bin/vim