Develop Locally
Overview
In this first part of the Kubestack tutorial you will:
- Download the CLI
- Scaffold your repository
- Configure the infrastructure.
Get the CLI
First, download the kbst
command line client for your operating 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.
Download the latest release
# Download the latest releasecurl -LO "https://github.com/kbst/kbst/releases/download/$(curl -s https://www.kubestack.com/cli-latest.txt)/kbst_linux_amd64.zip"Extract the archive and place kbst in your PATH
# Extract the binary into your PATH e.g. /usr/local/binsudo unzip -d /usr/local/bin/ kbst_linux_amd64.zip kbstVerify the binary works
# Verify the binary workskbst --version
Download the latest release
# Download the latest releasecurl -LO "https://github.com/kbst/kbst/releases/download/$(curl -s https://www.kubestack.com/cli-latest.txt)/kbst_darwin_amd64.zip"Extract the archive and place kbst in your PATH
# Extract the binary into your PATH e.g. /usr/local/binsudo unzip -d /usr/local/bin/ kbst_darwin_amd64.zip kbstVerify the binary works
# Verify the binary workskbst --version
Windows instructions require WSL2 and Docker Desktop for Windows with the WSL2 backend.
Download the latest release
# Download the latest releasecurl -LO "https://github.com/kbst/kbst/releases/download/$(curl -s https://www.kubestack.com/cli-latest.txt)/kbst_linux_amd64.zip"Extract the archive and place kbst in your PATH
# Extract the binary into your PATH e.g. /usr/local/binsudo unzip -d /usr/local/bin/ kbst_linux_amd64.zip kbstVerify the binary works
# Verify the binary workskbst --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 clusters 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 starterkbst repo init eks# Change into the starter directorycd kubestack-starter-eks
# Use the kbst CLI to scaffold your repository using the AKS starterkbst repo init aks# Change into the starter directorycd kubestack-starter-aks
# Use the kbst CLI to scaffold your repository using the GKE starterkbst repo init gke# Change into the starter directorycd kubestack-starter-gke
Edit the configuration
Follow the steps below to configure your cluster.
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)
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 changeskbst local apply# Whenever you want to destroy it again# simply run kbst local destroy
Commit the configuration
# Commit the configurationgit add .git commit -m "Add cluster configuration"
Recap
To recap, you now have a local development environment that
- simulates the configuration you prepared for the cloud locally
- 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 containersdocker ps
Next
If you're ready, lets continue the tutorial and apply what we learned to start automating real cloud infrastructure.