Getting Started
This guide will help you get started with Kloudlite. It will show you how to attach your cluster, create an environment, set up your workspace to access and intercept services of the environment.
Note: The quickest way to start using Kloudlite is to use our hosted solution. Login and set up your free team.
Quick start
Create Team
To get started with Kloudlite, create a team in Kloudlite dashboard. Under team you manage your environments, managed services, infrastructure and devices.
Setup CLI
To create and manage workspaces or clusters on your local system, you need to install the Kloudlite CLI.
Prerequisites: kl will run docker containers. Make sure you have docker installed and running.
Install kl
using curl
curl 'https://kl.kloudlite.io/kloudlite/kloudlite!?select=kl' | bash
This will install the Kloudlite CLI on your system.
Login to Kloudlite
kl auth login
Note: You will be prompted to select the team you want to work with
Attach Cluster
To create development environments and run your workloads, you'll need to attach a Kubernetes cluster to Kloudlite. You can add and manage cluster references from the infrastructure section of the Kloudlite dashboard.
With kloudlite you can run a local k3s cluster on your system and attach it to your team. This allows developers to get started quickly without needing to provision compute from cloud providers.
kl cluster up
This command will create a local k3s cluster and attach it to your team.
Setup Environment
Environment is a logical grouping of applications, configs, and connection to managed resources.
With cluster attached you can create a new environment in Kloudlite by providing an environment name and the cluster.
Once environment is created you will be able to create applications and also manage configs and secrets inside the environment.
Creating applications
Managing Configs and Secrets
You can also explore how to create and attach managed resources like databases in this section
Initialize Workspace
Now let's create a workspace to connect to the environment.
Choose your workspace directory and create a kl.yaml
file with the following command:
mkdir kl-workspace
cd kl-workspace
kl init
You will be prompted to select kloudlite team and the default environment this workspace will connect to.
Once selected, a kl.yml
file with the environment details will be created.
You can now add necessary configs, secrets, from the environment to the local workspace with the following commands:
Note: Ensure that you have configs and secrets added to the environment before adding them to the workspace.
# Add config to your local workspace
kl add config
# Add secret
kl add secret
# Add configmount
kl add config-mount <file-path>
You can start and access workspace (development container) using the following command:
kl box ssh
This command creates a development container and mounts your codebase to it. The container will include all necessary configs, secrets, resources, and packages. You can now start developing your application.
The container runs an SSH service. You can also attach your IDEs like VSCode or IntelliJ to the container and start developing your application.
Add necessary packages to the local container using pkg
command
# inside development container
kl pkg add nvim
# restart the container to avail the installed package
kl box restart
Note: You can search for available packages using kl pkg search <package-name>
or from nixhub.io
You can add configs, secrets, config-mounts and packages to the workspace from inside or outside the workspace. When inside the workspce, you need to restart the workspace using
kl box restart
command to reflect these changes.
In the above example we showed adding configs and secrets from outside and packages from inside.
Working with the Workspace
The workspace container is already connected to the environment using wireguard. And also service disvovery is configured to resolve the domains of the services in the environment.
As you are in same network now you can access the apps running in the environment using their name. All the configs, secrets, packages are already loaded inside the workspace container.
Now you will be able to access the apps running in the environment using their name. All the configs, secrets, packages are already loaded inside the workspace container.
Intercept the traffic of the apps running in the environment using the following command:
kl intercept
You will be prompted to select the app you want to intercept, and port you want to redirect the traffic to.
Use the following command to stop the interception:
kl intercept stop
Note: In the above example, we have intercepted traffic going to the app running an nginx container with the workspace.