Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/TagReminder.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "Reminder"
on:
# works for mannual, in case of github agent updated.
# works for mannual, in case of github agent updated.
# we can run mannually to see if it can be fixed by update version of
# - kubectl
# - k8s cluster provider's
# - k8s cluster provider's
schedule: [{cron: "0 0 1 */3 *"}]

jobs:
Expand All @@ -16,5 +16,5 @@ jobs:
with:
title: AutoBumpUpVersionReminder
body: |-
:wave: Hi maintainers, please remind to bump version for kind, microshift or any dependency for github action!
pinned: true
:wave: Hi maintainers, please remind to bump version for kind, microshift or any dependency for github action!
pinned: true
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "units-test"
on:
# works for mannual, in case of github agent updated.
# works for mannual, in case of github agent updated.
# we can run mannually to see if it can be fixed by update version of
# - kubectl
# - k8s cluster provider's
# - k8s cluster provider's
workflow_dispatch:
pull_request:
push:
Expand Down Expand Up @@ -48,11 +48,11 @@ jobs:
PROMETHEUS_ENABLE: true
GRAFANA_ENABLE: true
TEKTON_ENABLE: false
LOADPROMETHEUSIMAGE: true
LOADPROMETHEUSIMAGE: true
steps:
- uses: actions/checkout@v3
- name: start from local
run: |
run: |
export PROMETHEUS_ENABLE=${{matrix.PROMETHEUS_ENABLE}}
export PROMETHEUS_OPERATOR_VERSION=${{matrix.prometheus_operator_version}}
export GRAFANA_ENABLE=${{matrix.GRAFANA_ENABLE}}
Expand Down Expand Up @@ -121,4 +121,3 @@ jobs:
#,linux/arm64,linux/s390x later
push: false
tags: testcontainer:latest

22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/markdownlint/markdownlint.git
rev: v0.13.0
hooks:
- id: markdownlint_docker
name: Markdownlint Docker
description: Run markdown lint on your Markdown files using the project docker image
language: docker_image
files: \.(md|mdown|markdown)$
entry: markdownlint/markdownlint
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
117 changes: 81 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
![GitHub](https://img.shields.io/github/license/sustainable-computing-io/local-dev-cluster)
[![units-test](https://github.com/sustainable-computing-io/local-dev-cluster/actions/workflows/test.yml/badge.svg)](https://github.com/sustainable-computing-io/local-dev-cluster/actions/workflows/test.yml)

This repo provides the scripts to create a local [kubernetes](kind/kind.sh)/[openshift](microshift/microshift.sh) cluster to be used for development or integration tests. It is also used in [Github action](https://github.com/sustainable-computing-io/kepler-action) for kepler.
This repo provides the scripts to create a local [kubernetes](kind/kind.sh)/[openshift](microshift/microshift.sh)
cluster to be used for development or integration tests. It is also used in
[Github action](https://github.com/sustainable-computing-io/kepler-action) for kepler.

## Prerequisites for this REPO

- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/)
- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installing-from-release-binaries)
- [Git](https://git-scm.com/)
Expand All @@ -17,73 +20,90 @@ Currently Kepler project's Github Action only supports `Ubuntu` based runners.
You can refer to tools list [here](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#tools)

## Prerequisites (optional)
```

```bash
./main.sh prerequisites
```

Will setup ebpf on your host instance.

## Container runtime (optional)
```

```bash
./main.sh containerruntime
```

Will setup container runtime on your host instance.

## Startup
1. Modify kind [config](./kind/manifests/kind.yml) to make sure `extraMounts:` cover the linux header and BCC.
2. Export `CLUSTER_PROVIDER` env variable:
```
export CLUSTER_PROVIDER=kind

or
1. Modify kind [config](./kind/manifests/kind.yml) to make sure `extraMounts:` cover
the linux header and BCC.
1. Export `CLUSTER_PROVIDER` env variable:

export CLUSTER_PROVIDER=microshift
```
3. To setup local env run:
```
./main.sh up
```
4. To tear down local env run:
```
./main.sh down
```
```bash
export CLUSTER_PROVIDER=kind

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

```sh
#.env
export CLUSTER_PROVIDER=microshift
```

CLUSTER_PROVIDER=microshift
CLUSTER_NAME=microshift
PROMETHEUS_ENABLE=false
GRAFANA_ENABLE=false
TEKTON_ENABLE=false
KUBEVIRT_ENABLE=false
```
1. To setup local env run:

Start the cluster by running
```sh
./main.sh up
```
```bash
./main.sh up
```

1. To tear down local env run:

```bash
./main.sh down
```

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

```sh
#.env

CLUSTER_PROVIDER=microshift
CLUSTER_NAME=microshift
PROMETHEUS_ENABLE=false
GRAFANA_ENABLE=false
TEKTON_ENABLE=false
KUBEVIRT_ENABLE=false
```

Start the cluster by running

```sh
./main.sh up
```

1. kubeconfig

5. kubeconfig
Following the hint on your terminal to find out the kubeconfig.

## 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.
1. Check k8s cluster provider's version(as KIND).
1. Check prometheus operator version.

## How to contribute to this repo

### A new k8s cluster provider

Please feel free to refer to [kind provider implementation](providers/kind/kind.sh)
to contribute a k8s cluster. Please ensure that these checklist are statisfies
as Kepler requires certain feature to be available.
Expand All @@ -102,3 +122,28 @@ as Kepler requires certain feature to be available.
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:

- [Pre-commit](https://pre-commit.com/#install)

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

```bash
pip install pre-commit
```

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

```bash
pre-commit install
```

To run pre-commit manually

```bash
pre-commit run --all-files
```
2 changes: 1 addition & 1 deletion lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ rollout_ns_status() {
for res in $resources; do
kubectl rollout status $res --namespace $1 --timeout=10m || die "failed to check status of ${res} inside namespace ${1}"
done
}
}
5 changes: 2 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# Copyright 2023 The Kepler Contributors
#

# shellcheck disable=SC1091
set -eu -o pipefail

# NOTE: PROJECT_ROOT is the root the local-dev-cluster project
Expand Down Expand Up @@ -86,7 +86,7 @@ config_cluster() {

cluster_up() {
"${CLUSTER_PROVIDER}_up"

info "Copying $CLUSTER_PROVIDER kubeconfig to $KUBECONFIG_ROOT_DIR/$KEPLER_KUBECONFIG"
local kubeconfig
kubeconfig="$("${CLUSTER_PROVIDER}"_kubeconfig)"
Expand Down Expand Up @@ -180,7 +180,6 @@ ebpf() {
cd /tmp/elfutils-source/elfutils-0.189
./configure --disable-debuginfod
make install

mkdir -p /tmp/libbpf-source
cd /tmp/libbpf-source
yumdownloader --source libbpf
Expand Down
2 changes: 1 addition & 1 deletion providers/kind/manifests/local-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ metadata:
data:
localRegistryHosting.v1: |
host: "localhost:5001"
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
2 changes: 1 addition & 1 deletion test/ubi.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ RUN yum update -y && yum install -y git sudo
#RUN yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
RUN sudo ./main.sh prerequisites
RUN sudo ./main.sh containerruntime
RUN sudo ./verify.sh containerruntime
RUN sudo ./verify.sh containerruntime
2 changes: 1 addition & 1 deletion test/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ WORKDIR /workspace
COPY . .
RUN apt-get update -y && apt-get install -y git sudo
RUN ./main.sh containerruntime
RUN ./verify.sh containerruntime
RUN ./verify.sh containerruntime