-
Notifications
You must be signed in to change notification settings - Fork 0
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: vsoch <[email protected]>
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Laghos Example | ||
|
||
This is an example of a metric app, Laghos. | ||
We have not yet added a Python example as we want a use case first, but can and will when it is warranted. | ||
|
||
## Usage | ||
|
||
Create a cluster | ||
|
||
```bash | ||
kind create cluster | ||
``` | ||
|
||
and install JobSet to it. | ||
|
||
```bash | ||
VERSION=v0.2.0 | ||
kubectl apply --server-side -f https://github.com/kubernetes-sigs/jobset/releases/download/$VERSION/manifests.yaml | ||
``` | ||
|
||
Install the operator (from the development manifest here): | ||
|
||
```bash | ||
$ kubectl apply -f ../../dist/metrics-operator-dev.yaml | ||
``` | ||
|
||
How to see metrics operator logs: | ||
|
||
```bash | ||
$ kubectl logs -n metrics-system metrics-controller-manager-859c66464c-7rpbw | ||
``` | ||
|
||
Then create the metrics set. This is going to run cabanaPIC on a single node. | ||
|
||
```bash | ||
kubectl apply -f metrics.yaml | ||
``` | ||
|
||
Wait until you see the pod created by the job and then running. | ||
|
||
```bash | ||
kubectl get pods | ||
``` | ||
```diff | ||
NAME READY STATUS RESTARTS AGE | ||
metricset-sample-l-0-0-lt782 1/1 Running 0 3s | ||
``` | ||
|
||
And the output is the simulation. There are output files generated but we aren't retrieving them for this demo. | ||
|
||
```bash | ||
kubectl logs metricset-sample-l-0-0-lt782 -f | ||
``` | ||
```console | ||
... | ||
5988 117.057419 6.957814e-05 2.644137e-03 | ||
5989 117.076973 7.096451e-05 2.644661e-03 | ||
5990 117.096519 7.223449e-05 2.645145e-03 | ||
5991 117.116066 7.343685e-05 2.645631e-03 | ||
5992 117.135612 7.469198e-05 2.646064e-03 | ||
5993 117.155167 7.599744e-05 2.646421e-03 | ||
5994 117.174713 7.732580e-05 2.646714e-03 | ||
5995 117.194260 7.854241e-05 2.646956e-03 | ||
5996 117.213814 7.978067e-05 2.647144e-03 | ||
5997 117.233360 8.094098e-05 2.647246e-03 | ||
5998 117.252907 8.202127e-05 2.647287e-03 | ||
5999 117.272453 8.307652e-05 2.647311e-03 | ||
6000 117.292007 8.416179e-05 2.647350e-03 | ||
METRICS OPERATOR COLLECTION END | ||
``` | ||
|
||
When you are done, cleanup. | ||
|
||
```bash | ||
kubectl delete -f metrics.yaml | ||
``` |
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,11 @@ | ||
apiVersion: flux-framework.org/v1alpha2 | ||
kind: MetricSet | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: metricset | ||
app.kubernetes.io/instance: metricset-sample | ||
name: metricset-sample | ||
spec: | ||
pods: 1 | ||
metrics: | ||
- name: app-cabanapic |
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,72 @@ | ||
/* | ||
Copyright 2023 Lawrence Livermore National Security, LLC | ||
(c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package application | ||
|
||
import ( | ||
api "github.com/converged-computing/metrics-operator/api/v1alpha2" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
|
||
metrics "github.com/converged-computing/metrics-operator/pkg/metrics" | ||
) | ||
|
||
const ( | ||
cabanapicIdentifier = "app-cabanapic" | ||
cabanapicSummary = "structured PIC (particle in cell) proxy app" | ||
cabanapicContainer = "ghcr.io/converged-computing/metric-cabanapic:latest" | ||
) | ||
|
||
type CabanaPIC struct { | ||
metrics.LauncherWorker | ||
} | ||
|
||
// I think this is a simulation? | ||
func (m CabanaPIC) Family() string { | ||
return metrics.SimulationFamily | ||
} | ||
|
||
func (m CabanaPIC) Validate(set *api.MetricSet) bool { | ||
return true | ||
} | ||
|
||
func (m CabanaPIC) Url() string { | ||
return "https://github.com/ECP-copa/CabanaPIC" | ||
} | ||
|
||
// Set custom options / attributes for the metric | ||
func (m *CabanaPIC) SetOptions(metric *api.Metric) { | ||
|
||
m.Identifier = cabanapicIdentifier | ||
m.Summary = cabanapicSummary | ||
m.Container = cabanapicContainer | ||
|
||
// Set user defined values or fall back to defaults | ||
m.Prefix = "/bin/bash" | ||
m.Command = "cbnpic" | ||
m.Workdir = "/opt/cabanaPIC/build" | ||
m.SetDefaultOptions(metric) | ||
} | ||
|
||
// Exported options and list options | ||
func (m CabanaPIC) Options() map[string]intstr.IntOrString { | ||
return map[string]intstr.IntOrString{ | ||
"command": intstr.FromString(m.Command), | ||
"prefix": intstr.FromString(m.Prefix), | ||
"workdir": intstr.FromString(m.Workdir), | ||
} | ||
} | ||
|
||
func init() { | ||
base := metrics.BaseMetric{ | ||
Identifier: cabanapicIdentifier, | ||
Summary: cabanapicSummary, | ||
Container: cabanapicContainer, | ||
} | ||
launcher := metrics.LauncherWorker{BaseMetric: base} | ||
CabanaPIC := CabanaPIC{LauncherWorker: launcher} | ||
metrics.Register(&CabanaPIC) | ||
} |