kr8

command module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 1 Imported by: 0

README

kr8+

CI status Go Version

kr8+ is an opinionated Kubernetes cluster configuration management tool designed to simplify and standardize the process of managing Kubernetes clusters.By leveraging best practices and providing a structured approach, kr8+ helps DevOps teams streamline their workflows and maintain consistency across multiple environments.

kr8+ is pre-1.0. This means that breaking changes still happen from time to time, but it's stable enough for both scripting and interactive use in production environments.

Releases · Documentation · Get Help

Menu

Key Features

  • Cluster Configuration Management: Manage Kubernetes clusters across environments, regions and platforms with a declarative and centralized approach.
  • Opinionated Structure: Enforces best practices for consistent and reliable cluster configurations.
  • Jsonnet Native Funcitons: Use jsonnet to render and override component config from multiple sources, such as templates, docker-compose files, Kustomize, and Helm.
  • Extensibility: Easily extensible to meet the needs of diverse Kubernetes environments.
  • CI/CD Friendly: Statically define all your configuration in a single source of truth, making it easy to integrate with CI/CD pipelines and deployment automation like ArgoCD.
  • Standardization: Ensures consistency across Kubernetes clusters, reducing errors and improving maintainability.
  • Simplicity: Provides a straightforward approach to complex Kubernetes configurations, making it easier for teams to adopt.
  • Scalability: Designed to support clusters of all sizes, from simple single-node setups to large-scale production environments.

Technical Overview

kr8+ consists of:

Installation

The latest version is available for download from the Github releases page.

Once installed, use kr8 init commands to setup the initial structure and configurations.

Getting Started

An working example of a repo is found at ice-bergtech/kr8-examples:

git clone git@github.com:ice-bergtech/kr8-examples.git
Configuration

All configuration for kr8+ is written in Jsonnet. Jsonnet was chosen because it allows us to use code for configuration, while staying as close to JSON as possible.

A typical repo that uses kr8+ has the following parts:

  • Cluster Configurations
  • Component Configurations
  • Jsonnet Libraries
Clusters Configurations

A cluster is a deployment environment, organized in folders as a tree of configuration. Configuration the folders is layered on the parent folder's configuration, allowing you to override or extend configurations.

Cluster Spec: types.Kr8ClusterJsonnet

More information: Managing Clusters

Conponents Configurations

A component is a deployable unit that you wish to install in one or more clusters. Components can be declared multiple times within a cluster, as long as they are named distinctly when loaded.

Component Spec: types.Kr8ComponentJsonnet

More information: Managing Components

Jsonnet Libraries

Jsonnet libraries are reusable code that can be imported into your Jsonnet files. They allow you to write modular and maintainable configuration.

Common libraries include:

More information: Jsonnet Libraries

Deployment

To generate the final configured manifests, just run kr8 generate. kr8+ reads the cluster and components configuration files and generates the final manifests based on the parameters provided.

Manifest changes are checked into source control, allowing them to be ingested by tools like ArgoCD, Portainer, Rancher etc.

Further Information

Development

kr8+ is coded in Golang. Currently, version 1.24.2 is used.

Common tasks are described in Taskfile.yml, and can be executed with go-task.

Dependencies
Setup

Once go-task is installed, you can easily setup your environment by running:

# Install dev tools
task setup
Running Tasks
# View available tasks
task -l
task: Available tasks for this project:
* 01_setup:                     Instal dev tools                                         (aliases: setup, s)
* 01_setup-bats:                Install bats testing tools                               (aliases: setup-bats)
* 02_build:                     Build kr8+ for your local system                         (aliases: build, b)
* 03_build-snapshot:            Build a snapshot for all platforms using goreleaser      (aliases: build-snapshot, bs)
* 03_generate-bats-tests:       Generate resources to test against                       (aliases: gt)
* 03_test-go:                   Tesk kr8+ for your local system                          (aliases: test, t)
* 03_test-package:              Test compiled kr8+ binary against test inputs            (aliases: test-package, tp)
* 04_generate-examples:         Generate example clusters and components with kr8+       (aliases: ge, gen)
Examples

# Build kr8+ for your local system
task build

# Run tests
task test

# Build snapshot
task build-snapshot
Tests

There are a few sets of tests:

  • Unit Tests: go test ./... or task test
  • Integration Tests using bats: task test-package
  • Generate examples repo: ./kr8 generate -B examples or task gen
Build Troubleshooting
  • Dependencies download fail: There is a large number of reasons why this could fail. Be sure to check:
    • Networking problems: Check your connection to: github.com, golang.org and k8s.io.
    • Disk space: If no space is available on the disk, this step might fail.
  • The comand go build does not start the build:
    • Confirm you are in the correct project directory
    • Make sure your go installation works: go --version

Contributing

We welcome contributions from the community to enhance kr8+.

Fork the repo in github and send a merge request!

License

The project is licensed under the MIT license.

Parts of the code are derived from:

References and Additional Resources

kr8+ is a fork of kr8 with some additional features and improvements. kr8 was used in production to great success at Apptio for managing components of multiple Kubernetes clusters.

VSCode plugins:

Docs:

Alternatives:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
jnetvm
Package jvm contains the jsonnet rendering logic.
Package jvm contains the jsonnet rendering logic.
util
Utility functions for directories and files
Utility functions for directories and files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL