-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Scott Trent <[email protected]>
- Loading branch information
Showing
12 changed files
with
310 additions
and
81 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,10 @@ | ||
# Using SusQL with the Green Software Foundation's Impact Framework | ||
|
||
### Using prebuilt container image: | ||
- Ensure that you are logged into your cluster, then start the Impact Framework container: `oc apply -f impact-framework.yaml` | ||
- Log into the newly created container: `oc rsh impact-framework bash` | ||
- Try simple unit test: | ||
``` | ||
cd if | ||
npm run if-run -- --manifest manifests/examples/builtins/sum/success.yml | ||
``` | ||
- Use SusQL data: (Edit HOST and BEARER_TOKEN as necessary.) | ||
``` | ||
cd if | ||
echo "BEARER_TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) >>.env | ||
echo "HOST=https://thanos-querier.openshift-monitoring.svc.cluster.local:9091" >>.env | ||
npm run if-run -- --manifest ../ptest.yaml | ||
``` | ||
A large design point in using SusQL data with the Green Software Foundation's | ||
Impact Framework is whether to run in a container ON the cluster, or run on a machine | ||
external to the cluster. | ||
|
||
### Building your own container image | ||
For those who wish to build their own Impact Framework, log into both your | ||
cluster and your container image repository, and run the following commands: | ||
``` | ||
export IMG=<YOURIMAGEREPO>/<YOURID>/<YOURIMAGENAME | ||
podman build --tag ${IMG} . | ||
podman push ${IMG} | ||
``` | ||
Then edit `impact-framework.yaml` so that `image` points to your newly built image. | ||
This directory contains two directories with experiments into both approaches: | ||
|
||
Notes: | ||
- `oc` and `kubectl` are (should be) interchangable in this context. | ||
- `podman` and `docker` are (should be) interchangable in this context. | ||
- [onClusterApproach](onClusterApproach) | ||
- [offClusterApproach](offClusterApproach) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Using SusQL with the Green Software Foundation's Impact Framework | ||
|
||
This particular experiment was performed using a recent RHEL 9 x86 machine, | ||
however, any OS that supports a sufficiently recent version of nodejs should | ||
work in principle. | ||
|
||
### steps | ||
- Ensure that you are logged into your cluster and can use the `oc` (or `kubectl` command). | ||
- Make sure that a recent version of `node` is installed. (This test used v22.9.0) | ||
- Install Impact Framework | ||
- `npm install -g @grnsft/if` | ||
- Install Prometheus Importer | ||
- `npm install -g "https://github.com/trent-s/prometheus-importer"` | ||
- Update, just to be sure: | ||
- `cd test; npm update; cd -` | ||
|
||
- Create required credential file, and attempt to use prometheus-importer: | ||
``` | ||
cd test | ||
echo "BEARER_TOKEN="$(oc whoami -t) >.env | ||
echo HOST=https://$(oc get routes -n openshift-monitoring thanos-querier -o jsonpath='{.status.ingress[0].host}') >>.env | ||
if-run --manifest ../ptest.yaml --debug | ||
cd - | ||
``` | ||
|
||
|
||
Note: | ||
- `oc` and `kubectl` are (should be) interchangable in this context. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
samples/impact-framework/offClusterApproach/test/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
samples/impact-framework/offClusterApproach/test/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"description": "", | ||
"dependencies": { | ||
"prometheus-importer": "github:trent-s/prometheus-importer" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM ubuntu:latest | ||
|
||
ENV NPM_CONFIG_PREFIX=/usr/local | ||
ARG NPM_CONFIG_PREFIX=/usr/local | ||
|
||
WORKDIR /work | ||
COPY ?test.yaml . | ||
|
||
RUN apt-get update -y && \ | ||
apt-get upgrade -y && \ | ||
apt-get install git curl vim lsb-release -y && \ | ||
echo " --- Finished apt-get install" && \ | ||
# npm install -g npm@latest && \ | ||
# echo " --- Finished npm update" && \ | ||
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash && \ | ||
apt-get upgrade -y && \ | ||
apt-get install nodejs -y && \ | ||
npm install -g [email protected] && \ | ||
echo " --- Finished node update" && \ | ||
npm install -g typescript rimraf husky @grnsft/if && \ | ||
echo " --- Finished if install" && \ | ||
# npm install -g @types/node && \ | ||
# echo " --- Finished @types/node install" && \ | ||
# git clone https://github.com/Green-Software-Foundation/if.git && cd if && npm install -g && npm install && npm link && cd - && \ | ||
# echo " --- Finished IF npm link" && \ | ||
# npm install -g "https://github.com/trent-s/prometheus-importer" && \ | ||
# echo " --- Finished PI install" && \ | ||
# git clone https://github.com/trent-s/prometheus-importer.git && cd prometheus-importer && \ | ||
# npm install --save-dev @types/node && npm run build && npm install -g && npm install && npm link && cd - && \ | ||
# echo " --- Finished cloning PI" && \ | ||
# npm install -g "https://github.com/trent-s/hello-plugin" && \ | ||
# git clone https://github.com/trent-s/hello-plugin.git && cd hello-plugin && \ | ||
# npm install --save-dev @types/node && npm run build && npm install -g && npm install && npm link && cd - && \ | ||
# cd if && npm link hello-plugin && cd - && \ | ||
# echo " --- Finished cloning and initializing hello-plugin" && \ | ||
# cd if && npm link prometheus-importer && cd - && \ | ||
# echo " --- Finished last link " && \ | ||
chown -R 1000:1000 /work /usr/local/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Using SusQL with the Green Software Foundation's Impact Framework | ||
|
||
The following README explains an approach to utilize SusQL data in the | ||
Green Software Foundation's Impact Framework using a slightly modified version | ||
of the PrometheusImporter plugin. The fundamental focus of this particular | ||
approach is to run entirely on Cluster, and is based on OpenShift. | ||
|
||
However, this is a work in progress related to an apparent limitation | ||
in the use of certain required nodejs functionality within a container. | ||
|
||
### Using prebuilt container image: | ||
- Ensure that you are logged into your cluster, then start the Impact Framework container: `oc apply -f impact-framework.yaml` | ||
- Log into the newly created container: `oc rsh impact-framework bash` | ||
- Try simple unit test: | ||
``` | ||
cd if | ||
npm run if-run -- --manifest manifests/examples/builtins/sum/success.yml | ||
``` | ||
- Use SusQL data: (Edit HOST and BEARER_TOKEN as necessary.) | ||
``` | ||
cd if | ||
echo "BEARER_TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) >>.env | ||
echo "HOST=https://thanos-querier.openshift-monitoring.svc.cluster.local:9091" >>.env | ||
npm run if-run -- --manifest ../ptest.yaml | ||
``` | ||
|
||
### Building your own container image | ||
For those who wish to build their own Impact Framework, log into both your | ||
cluster and your container image repository, and run the following commands: | ||
``` | ||
export IMG=<YOURIMAGEREPO>/<YOURID>/<YOURIMAGENAME | ||
podman build --tag ${IMG} . | ||
podman push ${IMG} | ||
``` | ||
Then edit `impact-framework.yaml` so that `image` points to your newly built image. | ||
|
||
Notes: | ||
- `oc` and `kubectl` are (should be) interchangable in this context. | ||
- `podman` and `docker` are (should be) interchangable in this context. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: hello plugin test | ||
description: simple verification of plugin tech | ||
tags: null | ||
initialize: | ||
plugins: | ||
'hello-plugin': | ||
method: HelloPlugin | ||
path: 'https://github.com/trent-s/hello-plugin' | ||
config: | ||
allow-padding: true | ||
outputs: | ||
- yaml | ||
tree: | ||
children: | ||
child: | ||
pipeline: | ||
- hello-plugin | ||
inputs: | ||
- timestamp: 2023-08-06T00:00 | ||
duration: 3600 | ||
carbon: 30 | ||
- timestamp: 2023-09-06T00:00 | ||
duration: 3600 | ||
carbon: 30 |
File renamed without changes.
Oops, something went wrong.