Skip to content

sustainable-computing-io/local-dev-cluster

Repository files navigation

local-dev-cluster

GitHub units-test

This repo provides the scripts to create a local kubernetes cluster to be used for development or integration tests. It is also used in Github action for kepler.

Prerequisites for this REPO

Please install the same version of kubectl and kind as Github-hosted runner.

Currently Kepler project's Github Action only supports Ubuntu based runners.

You can refer to tools list here

Prerequisites (optional)

./main.sh prerequisites

Will setup ebpf on your host instance.

Container runtime (optional)

./main.sh containerruntime

Will setup container runtime on your host instance.

Startup

Note: in 2024 July, we decoupled cluster config with kind cluster setup, so that we allow this repo to set up a existing cluster.

  1. Modify kind config to make sure extraMounts: cover the linux header and BCC.

  2. To setup local env run:

    ./main.sh up
    ./main.sh config
  3. To tear down local env run:

    ./main.sh down

    Alternatively, use .env file to define and override the default configuration variables. E.g

    #.env
    
    PROMETHEUS_ENABLE=false
    GRAFANA_ENABLE=false
    TEKTON_ENABLE=false
    KUBEVIRT_ENABLE=false

    Start the cluster by running

    ./main.sh up
    ./main.sh config

Container registry

There's a container registry available which is exposed at localhost:5001.

Note for kepler contributor

To set up a local cluster for kepler development, we need to make the cluster connected with a local container registry.

Bump version step for this repo

  1. Check kubectl version.
  2. Check k8s cluster provider's version(as KIND).
  3. Check prometheus operator version.

How to contribute to this repo

A new k8s cluster provider

Please feel free to refer to kind provider implementation to contribute a k8s cluster. Please ensure that these checklist are statisfies as Kepler requires certain feature to be available.

Checklist

  • The provider related script should be placed under './provider/<name>/<name.sh>'

  • The script should have a <provider>_up function that sets up the k8s cluster.

  • The script should have a <provider>_down function that deletes the cluster.

  • The script should have a <provider>_kubeconfig function that prints the path to the cluster's kubeconfig that is located on host machine. Consider using tmp/<provider>/kubeconfig as the path to create/copy the kubeconfig file.

  • Ensure cluster can pull from the local specific registry since for local development, we expect to push the development image to the local registry instead of a public registry.

  • Mount local path of linux kernel and ebpf(BCC) inside kepler pod.

Development

In order to make contributions to this repo, you need to have the following installed:

You can install pre-commit by running the following command:

pip install pre-commit

After installing pre-commit, you need to install the pre-commit hooks by running the following command:

pre-commit install

To run pre-commit manually

pre-commit run --all-files

To skip pre-commit checks, use the --no-verify flag when committing changes

git commit -m "test" --no-verify
[precommit-shellcheck-mardown 89ed1adc] test
 1 file changed, 1 insertion(+), 1 deletion(-)