-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add kube api for k6 scaffolding (#5494)
* make tfsimple_pipeline test create random models underneath * update alpine base image and install xk6 * make namespace configurable in shell script * add xk6 to .gitignore * add xk6 install as make target * adjust wrapper to use k6 with xk6 * add note in readme regarding xk6 * add k8s test script scenario * adjust namespace variable * ability to set namespace in kustomize * update model script * add newline in file * add NAMESPACE as envar * wire up namespace * parse pod namespace from envar * use NAMESPACE env var * add service account and remove unnecessary secret * have main scenario back as default * review comments
- Loading branch information
Showing
9 changed files
with
139 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,3 +150,6 @@ event.json | |
# Go workspace files | ||
go.work | ||
go.work.sum | ||
|
||
# xk6 binary | ||
tests/k6/k6 |
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
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,50 @@ | ||
// adapted from https://github.com/grafana/xk6-kubernetes/blob/main/examples/deployment_operations.js | ||
// note that xk6 needs to be installed to run this script | ||
import { Kubernetes } from "k6/x/kubernetes"; | ||
import { describe, expect } from "https://jslib.k6.io/k6chaijs/4.3.4.3/index.js"; | ||
import { load, dump } from "https://cdn.jsdelivr.net/npm/[email protected]/dist/js-yaml.mjs"; | ||
import { getConfig } from '../components/settings.js'; | ||
|
||
let yaml = ` | ||
apiVersion: mlops.seldon.io/v1alpha1 | ||
kind: Model | ||
metadata: | ||
name: tfsimple1 | ||
namespace: ${getConfig().namespace} | ||
spec: | ||
storageUri: "gs://seldon-models/triton/simple" | ||
requirements: | ||
- tensorflow | ||
memory: 100Ki | ||
` | ||
|
||
export default function () { | ||
const kubernetes = new Kubernetes(); | ||
|
||
describe('YAML-based resources', () => { | ||
let yamlObject = load(yaml) | ||
const name = yamlObject.metadata.name | ||
const ns = yamlObject.metadata.namespace | ||
|
||
describe('Create our Model using the YAML definition', () => { | ||
kubernetes.apply(yaml) | ||
let created = kubernetes.get("Model.mlops.seldon.io", name, ns) | ||
expect(created.metadata, 'new Model').to.have.property('uid') | ||
}) | ||
|
||
describe('Update our Model with a modified YAML definition', () => { | ||
const newValue = 2 | ||
yamlObject.spec.replicas = newValue | ||
let newYaml = dump(yamlObject) | ||
|
||
kubernetes.apply(newYaml) | ||
let updated = kubernetes.get("Model.mlops.seldon.io", name, ns) | ||
expect(updated.spec.replicas, 'changed value').to.be.equal(newValue) | ||
}) | ||
|
||
describe('Remove our Model to cleanup', () => { | ||
kubernetes.delete("Model.mlops.seldon.io", name, ns) | ||
}) | ||
}) | ||
|
||
} |