Skip to content

Commit

Permalink
Merge pull request #126 from SamYuan1990/supportConfigcluster
Browse files Browse the repository at this point in the history
support for config existing cluster
  • Loading branch information
SamYuan1990 authored Jun 15, 2024
2 parents 00f05c0 + f8a6040 commit 649de15
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 28 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ jobs:
run: |
./verify.sh cluster
test_existing_cluster:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# set up k8s cluster
- uses: ./
name: dummy cluster for test
with:
cluster_provider: kind
config_cluster: false
# config cluster
- uses: ./
name: config cluster
with:
cluster_provider: existing
prometheus_enable: true
tekton_enable: true
- name: verify
run: |
./verify.sh cluster
# test if kernel module can be loaded, this is very os and instance specific, ignore if it fails
test_kernel_module:
runs-on: ubuntu-latest
Expand Down
52 changes: 39 additions & 13 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

52 changes: 39 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ function installKind(kind_version,local_path) {
executeCommand("mv ./kind "+local_path);
}

async function setup() {
const cluster_provider = getInputOrDefault('cluster_provider', 'kind');
async function configcluster() {
core.info('start config cluster');
core.info('checking kubeconf at /tmp/kubeconfig')
let result=shell.exec("ls -al /tmp/kubeconfig");
core.info(result.stdout);

const prometheus_enable = getInputOrDefault('prometheus_enable', '');
const prometheus_operator_version = getInputOrDefault('prometheus_operator_version', '');
const grafana_enable = getInputOrDefault('grafana_enable', '');
const tekton_enable = getInputOrDefault('tekton_enable', '');

let parameterExport = "export CLUSTER_PROVIDER="+cluster_provider;

let parameterExport = "export KUBECONFIG_ROOT_DIR=/tmp/kubeconfig"
if (prometheus_enable.length !== 0) {
core.info(`use prometheus enable `+prometheus_enable);
parameterExport = parameterExport + " && export PROMETHEUS_ENABLE="+prometheus_enable;
Expand All @@ -80,10 +82,19 @@ async function setup() {
parameterExport = parameterExport + " && export TEKTON_ENABLE="+tekton_enable;
}

parameterExport = parameterExport + " && "
core.debug(parameterExport);
executeCommand(parameterExport +` cd local-dev-cluster && bash -c './main.sh up'`, "fail to setup local-dev-cluster")
executeCommand(`cp ./local-dev-cluster/.kube/config /tmp/kubeconfig`)
let command = parameterExport +` && cd local-dev-cluster && mkdir -p ./tmp && bash -xc './main.sh config'`;
core.info('command going to be executed: ' + command);
executeCommand(command, "fail to config cluster")
}

async function setupcluster() {
core.info('start set up cluster');
const cluster_provider = getInputOrDefault('cluster_provider', 'kind');
let parameterExport = "export CLUSTER_CONFIG=false && export CLUSTER_PROVIDER="+cluster_provider;
let command = parameterExport +` && cd local-dev-cluster && bash -xc './main.sh up'`;
core.info('command going to be executed: ' + command);
executeCommand(command, "fail to setup local-dev-cluster")
executeCommand(`mkdir -p /tmp/kubeconfig && cp ./local-dev-cluster/.kube/config /tmp/kubeconfig/`)
}

async function run() {
Expand All @@ -95,9 +106,14 @@ async function run() {
// download local dev cluster
const local_dev_cluster_version = getInputOrDefault('local_dev_cluster_version', 'main');
core.info(`Get local-cluster-dev with version `+ local_dev_cluster_version);
executeCommand("git clone -b "+local_dev_cluster_version+" https://github.com/sustainable-computing-io/local-dev-cluster.git --depth=1", "fail to get local-dev-cluster");
// if there is local-cluster-dev folder skip
executeCommand("rm -rf local-dev-cluster && git clone -b "+local_dev_cluster_version+" https://github.com/sustainable-computing-io/local-dev-cluster.git --depth=1", "fail to get local-dev-cluster");
// download kubectl and other tools
installKubectl(kubectl_version,local_path);
// if there kubectl skip
let is_kubectl = shell.exec("command -v kubectl");
if (is_kubectl.code !== 0) {
installKubectl(kubectl_version,local_path);
}
// end of prepare
try {
const artifacts_version = getInputOrDefault('artifacts_version', '0.26.0');
Expand All @@ -106,6 +122,7 @@ async function run() {
const kernel_module_names = getInputOrDefault('kernel_module_names', ''); // comma delimited names, for example: rapl,intel_rapl_common
const install_containerruntime = getInputOrDefault('install_containerruntime', '');
const restartcontianerruntime = getInputOrDefault('restartcontianerruntime', '');
const config_cluster = getInputOrDefault('config_cluster', '');
// base on a general workflow
// Step 1 linux header, models, extramodules, ebpf
// prerequisites
Expand Down Expand Up @@ -140,10 +157,19 @@ async function run() {
if (runningBranch == 'kind' || getInputOrDefault('cluster_provider', '') == 'kind') {
const kind_version = getInputOrDefault('kind_version','0.22.0');
installKind(kind_version,local_path)
await setup();
await setupcluster();
if (config_cluster != 'false' ) {
await configcluster();
}
}
if (runningBranch == 'microshift' || getInputOrDefault('cluster_provider', '') == 'microshift') {
await setup();
await setupcluster();
if (config_cluster != 'false' ){
await configcluster();
}
}
if (getInputOrDefault('cluster_provider', '') == 'existing') {
await configcluster();
}
} catch (error) {
core.setFailed(error.message);
Expand Down
2 changes: 1 addition & 1 deletion verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ verify_xgboost() {
}

verify_cluster() {
export KUBECONFIG="/tmp/kubeconfig"
export KUBECONFIG="/tmp/kubeconfig/config"
# basic command check
which kubectl
which kustomize
Expand Down

0 comments on commit 649de15

Please sign in to comment.