Skip to content

Latest commit

 

History

History
267 lines (179 loc) · 7.09 KB

getting-started.md

File metadata and controls

267 lines (179 loc) · 7.09 KB

Tanzu CLI Getting Started

A simple set of instructions to set up and use the Tanzu CLI.

Binary installation

Install the latest release of Tanzu CLI

linux-amd64,windows-amd64, and darwin-amd64 are the OS-ARCHITECTURE combinations we support now.

macOS/Linux

  • Download the latest release

  • Extract the downloaded tar file

    • for macOS:

      mkdir tanzu && tar -zxvf tanzu-framework-darwin-amd64.tar.gz -C tanzu
    • for Linux:

      mkdir tanzu && tar -zxvf tanzu-framework-linux-amd64.tar.gz -C tanzu
  • Install the tanzu CLI

    Note: Replace v0.8.0 with the version you've downloaded.

    • for macOS:

      install tanzu/cli/core/v0.8.0/tanzu-core-darwin_amd64 /usr/local/bin/tanzu
    • for Linux:

      sudo install tanzu/cli/core/v0.8.0/tanzu-core-linux_amd64 /usr/local/bin/tanzu
  • Set TANZU_CLI_NO_INIT=true

    export TANZU_CLI_NO_INIT=true
  • If you have a previous version of tanzu CLI already installed and the config file ~/.config/tanzu/config.yaml is present, run this command to make sure the default plugin repo points to the right path.

    tanzu plugin repo update -b tanzu-cli-framework core
  • Install the downloaded plugins

    tanzu plugin install --local tanzu/cli all
  • Verify installed plugins

    tanzu plugin list

Windows

  • Download the latest release

  • Open PowerShell as an administrator, change to the download directory and run:

    Expand-Archive tanzu-framework-windows-amd64.zip -DestinationPath tanzu
    cd .\tanzu\
  • Save following in install.bat in current directory and run install.bat

    Note: Replace v0.8.0 (line number 3) with the version you've downloaded.

    SET TANZU_CLI_DIR=%ProgramFiles%\tanzu
    mkdir "%TANZU_CLI_DIR%"
    copy /B /Y cli\core\v0.8.0\tanzu-core-windows_amd64.exe "%TANZU_CLI_DIR%\tanzu.exe"
    set PATH=%PATH%;%TANZU_CLI_DIR%
    SET PLUGIN_DIR=%LocalAppData%\tanzu-cli
    mkdir %PLUGIN_DIR%
    SET TANZU_CACHE_DIR=%LocalAppData%\.cache\tanzu
    rmdir /Q /S %TANZU_CACHE_DIR%
    set TANZU_CLI_NO_INIT=true
    tanzu plugin repo update -b tanzu-cli-framework core
    tanzu plugin install --local cli all
    tanzu plugin list
  • Add Program Files\tanzu to your PATH.

Delete a selected plugin

If you want to delete a given plugin (one use case is when a plugin has become obsolete), you can run the following command:

tanzu plugin delete <PLUGIN_NAME>

With v0.8.0 release, the plugin imagepullsecret is deprecated and renamed secret. The new plugin secret will be installed following the instructions listed above. Remove the installed deprecated plugin if it exists using:

tanzu plugin delete imagepullsecret

Build the CLI and plugins from source

If you want the very latest, you can also build and install tanzu CLI, and its plugins, from source.

Prerequisites

  • go version 1.16

  • Clone Tanzu Framework and run the below command to build and install CLI and plugins locally for your platform.

    TANZU_CLI_NO_INIT=true make build-install-cli-local
  • When the build is done, the tanzu CLI binary and the plugins will be produced locally in the artifacts directory. The CLI binary will be in a directory similar to the following:

    ./artifacts/<OS>/<ARCH>/cli/core/<version>/tanzu-core-<os_arch>
  • For instance, the following is a build for MacOS:

    ./artifacts/darwin/amd64/cli/core/latest/tanzu-core-darwin_amd64
  • If you additionally want to build and install CLI and plugins for all platforms, run:

    TANZU_CLI_NO_INIT=true make build-install-cli-all

The CLI currently contains a default distribution which is the default set of plugins that should be installed on initialization. Initialization of the distributions can be prevented by setting the env var TANZU_CLI_NO_INIT=true. Check out this doc to learn more about distributions in Tanzu CLI

Usage

Usage:
  tanzu [command]

Available command groups:

  Admin
    builder                 Build Tanzu components
    test                    Test the CLI

  Run
    cluster                 Kubernetes cluster operations
    kubernetes-release      Kubernetes release operations
    management-cluster      Kubernetes management cluster operations

  System
    completion              Output shell completion code
    config                  Configuration for the CLI
    init                    Initialize the CLI
    login                   Login to the platform
    plugin                  Manage CLI plugins
    update                  Update the CLI
    version                 Version information

  Version
    alpha                   Alpha CLI commands


Flags:
  -h, --help   help for tanzu

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

Creating clusters

Tanzu CLI allows you to create clusters on a variety of infrastructure platforms such as vSphere, Azure, AWS and on Docker.

  1. Initialize the Tanzu kickstart UI by running the below command to create the management cluster.

    tanzu management-cluster create --ui

    The above would open a management cluster provisioning UI and you can select the deployment infrastructure and create the cluster.

  2. To validate the creation of the management cluster

    tanzu management-cluster get
  3. Get the management cluster's kubeconfig

    tanzu management-cluster kubeconfig get ${MGMT_CLUSTER_NAME} --admin
  4. Set kubectl context

    kubectl config use-context ${MGMT_CLUSTER_NAME}-admin@${MGMT_CLUSTER_NAME}
  5. Next create the workload cluster

    1. Create a new workload clusterconfig file by copying the management cluster config file ~/.config/tanzu/tkg/clusterconfigs/<MGMT-CONFIG-FILE> and changing the CLUSTER_NAME parameter to the workload cluster name, you can also edit other parameters as required.

    2. Create workload cluster

      tanzu cluster create ${WORKLOAD_CLUSTER_NAME} --file ~/.config/tanzu/tkg/clusterconfigs/workload.yaml
    3. Validate workload cluster creation

      tanzu cluster list
  6. Do cool things with the provisioned clusters.

  7. Clean up

    1. To delete workload cluster

      tanzu cluster delete ${WORKLOAD_CLUSTER_NAME}

      Management cluster can only be deleted after deleting all the workload clusters.

    2. To delete management cluster

      tanzu management-cluster delete ${MGMT_CLUSTER_NAME}

What's next

Tanzu CLI is built to be extensible, if you wish to extend Tanzu CLI, you can do that by writing your CLI plugins.

Create your own plugin

To bootstrap a new plugin, follow the builder plugin documentation here.

Check out the plugin implementation guide for more details.