Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add manager for simple kubernetes job creation #47

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
de44dea
add manager for simple kubernetes job creation
iripiri Sep 23, 2021
8959757
suppress state changes from event repetitions
iripiri Sep 24, 2021
d69a26f
try create of superclass if parameters are missing
iripiri Sep 24, 2021
298df49
delete configmap when job is deleted
iripiri Sep 28, 2021
f13ea00
fix api_url for villas-node manager
stv0g Oct 1, 2021
df28149
simplify config handling
stv0g Oct 8, 2021
e0d569c
move global status to Controller mixin class
stv0g Oct 8, 2021
a0759cf
make work dir configurable
stv0g Oct 8, 2021
a9bde8d
pass payload instead of message to action handlers
stv0g Oct 8, 2021
1f30e93
fix mixed up state vs status properties in some components
stv0g Oct 8, 2021
4e23053
fix mixed up state vs status properties in some components
stv0g Oct 8, 2021
426cbf2
fix mixed up state vs status properties in some components
stv0g Oct 8, 2021
22ba436
added first version of an HTTP REST API
stv0g Oct 8, 2021
4360d29
creating AMQP queue with durable, exclusive and auto_delete flags
stv0g Oct 8, 2021
124f55f
add first draft of OpenAPI spec
stv0g Oct 8, 2021
5800d0b
fix simple manager
iripiri Oct 14, 2021
1f695f5
use 'villas' namespace as default
iripiri Nov 17, 2021
17080eb
use villas-controller namespace as default
iripiri Nov 17, 2021
d705699
move schemas to YAML files and load them from there for all components
stv0g Oct 12, 2021
208f8e8
config: show a useful error message when started without broker param…
stv0g Oct 12, 2021
71a4872
fix typo
stv0g Oct 12, 2021
075fbfc
config: fix bug when started without config file
stv0g Oct 12, 2021
aa6432c
validate action parameters against schema
stv0g Oct 12, 2021
b79c286
fix linting errors
stv0g Oct 13, 2021
bac3246
fix some errors in the API spec and schema
stv0g Oct 13, 2021
38c698c
validate schemas and openapi doc against meta jsonschemas
stv0g Oct 14, 2021
a27be13
raise a SimulationException if an IC with an existing UUID should be …
stv0g Oct 22, 2021
f87608c
provide version number within status field of status update
stv0g Oct 22, 2021
e0f7829
relay: do not remove vanished sessions by setting state to gone
stv0g Oct 22, 2021
f789439
improve error reporting
stv0g Oct 22, 2021
c0dcdad
add labels and annotations to created job resources
stv0g Oct 22, 2021
37634bd
k8s: add owner references
stv0g Oct 22, 2021
250c97b
make all manually configured components to be managed by the default …
stv0g Oct 22, 2021
b867d02
use a api/v1 prefix for the API handlers
stv0g Oct 22, 2021
061d629
fixes for schema & pod_uid
iripiri Oct 28, 2021
7a7f273
Change update interval
iripiri Nov 2, 2021
3093451
generic: move return code to status section
stv0g Nov 16, 2021
d298eba
fix exception in schema code
stv0g Nov 16, 2021
328249d
kubernetes fixes
iripiri Nov 16, 2021
31699d1
move schema to separate file
iripiri Nov 17, 2021
dcc4a65
debugging
iripiri Nov 18, 2021
5ed46b7
catch timeouterror
iripiri Nov 18, 2021
5c615cb
show event outputs
iripiri Nov 18, 2021
f30366c
debugging
iripiri Nov 18, 2021
b7de56f
add init file for kubernetes-simple schema
iripiri Nov 19, 2021
8837d2b
get kubernetes job running
iripiri Nov 19, 2021
5e925f0
fixes
iripiri Nov 22, 2021
4ff0014
allow UUID of default generic manager to be configured via configurat…
stv0g Dec 7, 2021
f82f994
fix villas-node manager
stv0g Dec 7, 2021
ff5ca02
api: make main request handler also available without trailing slash
stv0g Dec 7, 2021
e2c6631
more fixes for relay and node managers
stv0g Dec 7, 2021
ea5497d
cleanup
iripiri Dec 8, 2021
791af64
send status update while resetting to improve user experience
iripiri Dec 17, 2021
1c962d8
publish first status update immediately after creating component
iripiri Dec 17, 2021
7f0eac0
read namespace for kubernetes jobs from ENV
iripiri Dec 17, 2021
21af994
fix formatting
iripiri Jan 12, 2022
63c3b22
cleanup
iripiri Feb 11, 2022
d3779d1
fix 'invalid UUID length: 0' error
iripiri Mar 3, 2022
2007bf8
fix error handling relay/node
iripiri Jan 12, 2022
85d83e0
relay fix
iripiri Mar 4, 2022
3d7791b
container settings
iripiri Mar 9, 2022
723f052
update flake repo
iripiri Aug 14, 2023
6c6368f
formatting
iripiri Aug 14, 2023
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
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@ repos:
- id: check-symlinks
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
- repo: https://github.com/sirosen/check-jsonschema
rev: 8a14ffa1d4c81a56057f55e1da308daeccc3bcd6
hooks:
- id: check-jsonschema
name: "Check schemas"
language: python
files: ^villas/controller/schemas/.*\.yaml$
types: [yaml]
args: ["--schemafile", "https://json-schema.org/draft/2020-12/schema"]
- id: check-jsonschema
name: "Check OpenAPI doc"
language: python
files: ^doc/openapi.yaml$
types: [yaml]
args: ["--schemafile", "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include villas/controller *
327 changes: 327 additions & 0 deletions doc/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
---
openapi: 3.0.0
info:
title: VILLAScontroller API
description: 'A HTTP/REST API for controlling VILLAScontroller remotely for querying component status as well as issuing control actions.'
version: 0.0.1
contact:
name: "Steffen Vogel"
email: "[email protected]"
license:
name: Apache-2.0
url: https://www.apache.org/licenses/LICENSE-2.0

servers:
- url: https://villas.k8s.eonerc.rwth-aachen.de/controller/api/v1
description: Demo instance at RWTH Aachen

paths:

/:
get:
summary: 'Get status of VILLAScontroller daemon'
operationId: getStatus
tags:
- status
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
properties:
components:
type: array
items:
type: string
format: uuid
status:
type: object
properties:
version:
type: string
uptime:
type: number
host:
type: string
kernel:
type: object
properties:
sysname:
type: string
nodename:
type: string
release:
type: string
version:
type: string
machine:
type: string

example:
components:
- f4751894-205e-11eb-aefb-0741ff98abca
- 3ddd318e-fee1-46d7-bff4-7c064d640d4e
status:
version: 0.3.2
uptime: 15.38102650642395
host: lat.0l.de
kernel:
sysname: Linux
nodename: lat.0l.de
release: 5.13.14-200.fc34.x86_64
version: '#1 SMP Fri Sep 3 15:33:01 UTC 2021'
machine: x86_64

/health:
get:
operationId: getHealth
summary: Query health of daemon.
tags:
- status
responses:
'200':
description: The daemon is healthy
content:
application/json:
schema:
type: object
properties:
status:
type: string
example:
status: ok


/component/{uuid}:
get:
summary: 'Get the current status of a component'
operationId: getComponentStatus

parameters:
- name: uuid
in: path
required: true
schema:
type: string
format: uuid

responses:
'200':
description: ''
content:
application/json:
schema:
type: object
properties:
components:
type: array
items:
type: string
format: uuid

status:
type: object
properties:
managed_by:
type: string
format: uuid

state:
type: string
enum:
- idle
- starting
- running
- stopping
- pausing
- paused
- resuming
- error
- resetting
- shuttingdown
- shutdown
- gone

version:
type: string
uptime:
type: number
host:
type: string
kernel:
type: object
properties:
sysname:
type: string
nodename:
type: string
release:
type: string
version:
type: string
machine:
type: string

properties:
type: object
properties:
category:
type: string
enum:
- manager
- simulator
- gateway
type:
type: string
pattern: '[a-z-]+'
name:
type: string
realm:
type: string
pattern: '[a-z0-9-.]+'
uuid:
type: string
format: uuid

additionalProperties: true

schema:
type: object
additionalProperties:
$ref: 'https://json-schema.org/draft/2020-12/schema'

example:
components: []
status:
state: idle
version: 0.3.2
uptime: 480.25064611434937
host: lat.0l.de
kernel:
sysname: Linux
nodename: lat.0l.de
release: 5.13.14-200.fc34.x86_64
version: '#1 SMP Fri Sep 3 15:33:01 UTC 2021'
machine: x86_64
managed_by: f4751894-205e-11eb-aefb-0741ff98abca
properties:
category: manager
type: generic
name: Standard Controller
realm: de.rwth-aachen.eonerc.acs
uuid: f4751894-205e-11eb-aefb-0741ff98abca
schema:
create:
# $schema: 'http://json-schema.org/draft-07/schema'
type: object
default: {}
required:
- name
- category
- location
- owner
- realm
- type
- api_url
- ws_url
properties:
name:
type: string
title: Component name
default: New Component
examples: 'Generic Simulator #1'
owner:
type: string
title: Component owner
examples:
- rmr
- svg
realm:
type: string
title: Component realm
default: ''
examples:
- de.rwth-aachen.eonerc.acs
category:
type: string
title: Component category
examples:
- simulator
location:
type: string
title: Component location
examples:
- Richard's PC
type:
type: string
default: generic
uuid:
type: 'string'
format: uuid
ws_url:
type: string
examples:
- 'https://villas.k8s.eonerc.rwth-aachen.de/ws/relay/generic_1'
api_url:
type: string
examples:
- 'https://villas.k8s.eonerc.rwth-aachen.de/api/ic/generic_1'
shell:
type: boolean
default: false
examples:
- true
whitelist:
type: array
title: The whitelist schema
default: []
examples:
- - /sbin/ping
- ^echo
additionalItems: true
items:
anyOf:
- type: string
examples:
- /sbin/ping
- ^echo

post:
operationId: executeComponentAction
summary: 'Send a control action to the component'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
action:
type: string
enum:
- start
- stop
- pause
- resume
- create
- delete
- shutdown
- reset
parameters:
oneOf:
- $ref: ../villas/controller/schemas/manager/generic/create.yaml
- $ref: ../villas/controller/schemas/manager/kubernetes/create.yaml
- $ref: ../villas/controller/schemas/simulator/dpsim/start.yaml
- $ref: ../villas/controller/schemas/simulator/dummy/start.yaml

responses:
'200':
description: ''
content:
application/json: {}


# example:
# runtime: 10.2
14 changes: 14 additions & 0 deletions etc/config_simplekub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
broker:
url: amqp://villas:Haegiethu0rohtee@kubernetes-master-1.os-cloud.eonerc.rwth-aachen.de:30809/%2F

components:
- type: generic
category: manager
uuid: ebbbbba0-557b-4848-ac7a-faa3e7c51fa3

- category: manager
type: kubernetes-simple
uuid: 4bbbb73e-7e74-11eb-8f63-f3a5b3ab82f6

namespace: villas-controller
4 changes: 2 additions & 2 deletions etc/params_k8s_dpsim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ properties:
name: dpsim
spec:
suspend: true
activeDeadlineSeconds: 120 # kill the Job after 1h
activeDeadlineSeconds: 3600 # kill the Job after 1h
backoffLimit: 0 # only try to run pod once, no retries
ttlSecondsAfterFinished: 120 # delete the Job resources 1h after completion
ttlSecondsAfterFinished: 3600 # delete the Job resources 1h after completion
template:
spec:
restartPolicy: Never
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ requests
villas-node>=0.10.2
kubernetes
xdg
dotmap
PyYAML
tornado
jsonschema>=4.1.0
Loading