Skip to content

mm-camelcase/k8s-devenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Development Environment (k8s-devenv)

A Kubernetes development environment.

Project Thumbnail

Click image for a demo

Overview

A Kubernetes development environment that provides a local setup for developing, testing, and debugging Kubernetes-based applications. This guide will help you set up and configure all necessary tools to create an efficient workflow.

Prerequisites

This environment depends on the following tools, which are essential for running Kubernetes locally and managing your environment:

For detailed setup instructions, refer to prerequisites.md

Devenv Environment Setup

To setup the development environment run:

./devenv.sh

The deployed services are primarily Spring Boot applications built using Gradle

For more information on the setup script, see setup-devenv.md

Useful complementary tools

These tools are not required but can enhance your development experience:

  • zellij - Terminal multiplexer for managing multiple terminal windows.
  • k9s - A terminal-based UI to interact with Kubernetes clusters.
  • kubectx - A tool to switch between Kubernetes contexts easily.
  • kubens - A tool to switch between Kubernetes namespaces.

For more information on setting up these tools, refer to optional-tooling.md

How to use this development environment

Kubernetes Dashboard

Dev Env

Run the following command to access the Kubernetes Dashboard:

minikube dashboard

Then, navigate to the provided URL.

Deploying code

The environment uses Skaffold as a tool to package and deploy source code directly into the local k8s cluster. Each project contains a skaffold.yaml definition file that tells Skaffold how to handle local deployments (see example skaffold.yaml here)

Deploying Pod Resources

Resource deployments use Helm-style Skaffold configs (i.e. Skaffold generates Helm install and update commands).

To deploy source code (assuming code is build first using ./gradlew clean build) into the local cluster, run the following command from the same location as the skaffold.yaml definition file:

skaffold run --port-forward

or Skaffold can monitor your source code for changes using...

skaffold dev --port-forward

Debugging code

To deploy a service in debug mode, run:

skaffold debug

The deploy will automatically set up a port foward for debugging on port 5005. Configure your debugger as a remote JVM debugger (e.g. in IntelliJ):

debugger

Update the cluster

To update services to the latest available versions, simply run the setup script again. Since the script is idempotent, it will redeploy or update without causing conflicts.

Delete the cluster

To remove all traces of your cluster and start over, you can run:

minikube delete