This guide provides instructions on how to use the Knts CLI effectively.
Quick Start
Installation
- Install the Knts CLI by following the installation documentation.
Initial Setup
-
Navigate to Your Application Directory
cd <Application directory>
-
Activate Your Kubernetes Cluster
Verify your cluster is active with:kubectl get nodes
-
Set the Context for Your Cluster
knts context use Default # Replace 'Default' with your cluster's context name
-
Initialize Knts
This command creates a template for the Knts manifest file:knts init
Editing the Manifest File
-
Uncomment and Edit the Dev Section
Open the generated manifest file and edit it as needed:#AUTOGENERATED template # The dev section defines how to activate a development container # dev: # sample: # image: knts/dev:latest # command: bash # workdir: /usr/src/app # sync: # - .:/usr/src/app # environment: # - name=$USER # forward: # - 8080:80
Edit it as follows
dev:
service-name:
image: <base image according to the tech stack>
command: bash
workdir: <work directory inside the container>
sync:
- <path/of/the/service/in/vs-code>:<path/of/the/service/inside/the/container>
environment:
- name=$USER # ENV IF ANY
forward:
- 8080:80 # Port used by the application
Activating the Dev Container
-
Start the Dev Container
knts up
This command will sync your local VS Code environment with the container and start the development environment.
Sample output:
i Using default @ Default as context i Running 'helm upgrade --install my-application chart ' Release "my-application" does not exist. Installing it now. NAME: my-application NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None ✓ Development container 'frontend' selected ✓ Persistent volume successfully attached ✓ Images successfully pulled ✓ Files synchronized Context: Default Namespace: default Name: frontend Forward: 8080 -> 8080 I have no name!@frontend-knts:/src$
- Now you can enjoy your development environment by live syncing your changes to the container and running the application as you would in your local terminal.
Deactivating the Dev Environment
-
Exit the Container
To stop working in the container, use:knts down
-
Destroy the Dev Environment
When you no longer need the development environment for the day:knts destroy
-
Reactivate the Dev Environment
To start your development environment again:knts up
By following these steps, you can effectively use the Knts CLI to manage your development environments seamlessly. Enjoy your development!