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 library to interact with kubernetes #123

Merged
merged 22 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
update documentation
  • Loading branch information
fmirus committed Jul 31, 2024
commit 0c056a49a059125d2958499829414a512b01852e
4 changes: 3 additions & 1 deletion docs/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ junit
runtime
dot
png
svg
svg
Kubernetes
yaml
165 changes: 165 additions & 0 deletions docs/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Beside ``osc.standard`` provided by OpenSCENARIO 2 (which we divide into ``osc.s
- ROS Library (provided with :repo_link:`scenario_execution_ros`)
* - ``osc.gazebo``
- Gazebo Library (provided with :repo_link:`scenario_execution_gazebo`)
* - ``osc.kubernetes``
fmirus marked this conversation as resolved.
Show resolved Hide resolved
- Kubernetes Library (provided with :repo_link:`libs/scenario_execution_kubernetes`)

Additional features can be implemented by defining your own library.

Expand Down Expand Up @@ -982,3 +984,166 @@ Wait for topics to get available (i.e. publisher gets available).
- ``list of string``
-
- List of topics to wait for

fmirus marked this conversation as resolved.
Show resolved Hide resolved
Kubernetes
----------

The library contains actions to interact with the `Kubernetes API <https://kubernetes.io>`_. Import it with ``import osc.kubernetes``. It's provided by the package :repo_link:`libs/scenario_execution_kubernetes`.

Actions
^^^^^^^

``kubernetes_base_action()``
fmirus marked this conversation as resolved.
Show resolved Hide resolved
""""""""""""""""""""""""""""

Base action containing parameters common for all Kubernetes actions

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``namespace``
- ``string``
- ``default``
- Kubernetes namespace
* - ``within_cluster``
- ``bool``
- ``false``
- set to true if you want to access the cluster from within a running container/pod


``kubernetes_create_from_yaml()``
"""""""""""""""""""""""""""""""""

Create a Kubernetes object (e.g., a pod or network policy) from a yaml file. Inherits from ``kubernetes_base_action``

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``yaml_file``
- ``string``
-
- The yaml-file to use create the object from


``kubernetes_delete()``
"""""""""""""""""""""""

Delete a Kubernetes element (e.g., a pod or network policy). Inherits from ``kubernetes_base_action``

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``target``
- ``string``
-
- The target element to delete
* - ``regex``
- ``bool``
- ``false``
- Is the specified target a regular expression
* - ``element_type``
- ``string``
- ``pod``
- Type of the element to delete (e.g., pod or network policy)
* - ``grace_period``
- ``time``
- ``5s``
- Grace period to wait before forcing deletion


``kubernetes_patch_network_policy()``
"""""""""""""""""""""""""""""""""""""

Patch an existing Kubernetes network policy. Inherits from ``kubernetes_base_action``

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``target``
- ``string``
-
- The target network policy to patch
* - ``network_enabled``
- ``bool``
-
- Should the network be enabled
* - ``match_label``
- ``key_value``
-
- key-value pair to match (e.g., ``key_value("app", "pod_name"))``


``kubernetes_wait_for_network_policy_status()``
"""""""""""""""""""""""""""""""""""""""""""""""

Wait for an existing Kubernetes network policy to reach a specified state. Inherits from ``kubernetes_base_action``

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``target``
- ``string``
-
- The target network policy to monitor
* - ``status``
- ``kubernetes_network_policy_status``
-
- Expected status of the network policy, e.g., ``kubernetes_network_policy_status!added``


``kubernetes_wait_for_pod_status()``
""""""""""""""""""""""""""""""""""""

Wait for a Kubernetes pod to reach a specified state. Inherits from ``kubernetes_base_action``

.. list-table::
:widths: 15 15 5 65
:header-rows: 1
:class: tight-table

* - Parameter
- Type
- Default
- Description
* - ``target``
- ``string``
-
- The name of the pod to monitor
* - ``status``
- ``kubernetes_pod_status``
-
- Expected status of the pod, e.g., ``kubernetes_pod_status!running``
* - ``regex``
- ``bool``
- ``false``
- Is the specified target a regular expression
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ action kubernetes_base_action:
namespace: string = "default" # namespace within kubernetes cluster
within_cluster: bool = false # set to true if you want to access the cluster from within a running container/pod.


action kubernetes_create_from_yaml inherits kubernetes_base_action:
# create elements from yaml-file
yaml_file: string # yaml file to create from
Expand All @@ -45,4 +44,4 @@ action kubernetes_wait_for_pod_status inherits kubernetes_base_action:
# wait for a pod to reach the specified state
target: string # pod name to monitor
status: kubernetes_pod_status # expected pod status
regex: bool = false # is the specified target a regular expression
regex: bool = false # is the specified target a regular expression