Develop Locally

Overview

In this first part of the Kubestack tutorial you will:

  1. Download the CLI
  2. Scaffold your repository
  3. Configure the infrastructure.

Get the CLI

First, download the kbst command line client for your opearting system. The CLI is your typical single binary Go application.

You can follow the command line instructions below or download the latest version from the GitHub releases directly.

  1. Download the latest release

    # Download the latest release
    curl -LO "https://github.com/kbst/kbst/releases/download/$(curl -s https://www.kubestack.com/cli-latest.txt)/kbst_linux_amd64.zip"
  2. Extract the archive and place kbst in your PATH

    # Extract the binary into your PATH e.g. /usr/local/bin
    sudo unzip -d /usr/local/bin/ kbst_linux_amd64.zip kbst
  3. Verify the binary works

    # Verify the binary works
    kbst --version
  1. Download the latest release

    # Download the latest release
    curl -LO "https://github.com/kbst/kbst/releases/download/$(curl -s https://www.kubestack.com/cli-latest.txt)/kbst_darwin_amd64.zip"
  2. Extract the archive and place kbst in your PATH

    # Extract the binary into your PATH e.g. /usr/local/bin
    sudo unzip -d /usr/local/bin/ kbst_darwin_amd64.zip kbst
  3. Verify the binary works

    # Verify the binary works
    kbst --version

Windows instructions require WSL2 and Docker Desktop for Windows with the WSL2 backend.

  1. Download the latest release

    # Download the latest release
    curl -LO "https://github.com/kbst/kbst/releases/download/$(curl -s https://www.kubestack.com/cli-latest.txt)/kbst_linux_amd64.zip"
  2. Extract the archive and place kbst in your PATH

    # Extract the binary into your PATH e.g. /usr/local/bin
    sudo unzip -d /usr/local/bin/ kbst_linux_amd64.zip kbst
  3. Verify the binary works

    # Verify the binary works
    kbst --version

Scaffold your repository

Now, use the CLI to scaffold your local repository. Select the tab for your desired Kubestack starter below.

You can easily add more cluster pairs in different regions, on different cloud providers or both later. But for now pick one cloud and let's get started.

# Use the kbst CLI to scaffold your repository using the EKS starter
kbst repo init eks
# Change into the starter directory
cd kubestack-starter-eks
# Use the kbst CLI to scaffold your repository using the AKS starter
kbst repo init aks
# Change into the starter directory
cd kubestack-starter-aks
# Use the kbst CLI to scaffold your repository using the GKE starter
kbst repo init gke
# Change into the starter directory
cd kubestack-starter-gke

Edit the configuration

Follow the steps below to configure your cluster pair.

  1. config.auto.tfvars

    Set the required variables for apps. Optionally, overwrite settings for ops. By default, the configuration from apps is inherited.

    • name_prefix (required)
    • base_domain (required)
    • cluster_availability_zones (required)
  2. providers.tf

    Set the region attribute to your desired region in the file providers.tf.

Edit the file config.auto.tfvars and set the required variables for apps. Optionally, overwrite settings for ops. By default, the configuration from apps is inherited.

  • name_prefix (required)
  • base_domain (required)
  • resource_group (required)

Edit the file config.auto.tfvars and set the required variables for apps. Optionally, overwrite settings for ops. By default, the configuration from apps is inherited.

  • project_id (required)
  • name_prefix (required)
  • base_domain (required)
  • region (required)
  • cluster_node_locations (required)

Provision local clusters

# Bring up the local development environment
# and start watching for changes
kbst local apply
# Whenever you want to destroy it again
# simply run kbst local destroy

Commit the configuration

# Commit the configuration
git add .
git commit -m "Add cluster configuration"

Recap

To recap, you now have a local development environment that

  1. simulates the configuration you prepared for the cloud locally
  2. and automatically updates this environment as you make changes.

The local environment uses KinD (Kubernetes in Docker) to run the Kubernetes nodes as Docker containers on your local machine.

# See the Kubernetes cluster nodes running as Docker containers
docker ps

Next

If you're ready, lets continue the tutorial and apply what we learned to start automating real cloud infrastructure.