Skip to content

Commit

Permalink
Adding documentation for Kanister Function KubeOps & Wait (#1153)
Browse files Browse the repository at this point in the history
* Added the documentation for function KubeOps

* Removed trailing spaces

* Added documentation for Wait function

* Update docs/functions.rst: spelling correction

Co-authored-by: Vivek Singh <vsingh.ggits.2010@gmail.com>

* Fixed Indentation

* Update docs/functions.rst

Co-authored-by: Pavan Navarathna <pavan@kasten.io>

* Resolved Comments

* updated functions.rst

* updated the conditions description

* updated the conditions description

* updated functions.rst

* updated description for wait condition

* Update docs/functions.rst

Co-authored-by: Pavan Navarathna <pavan@kasten.io>

* Update docs/functions.rst

Co-authored-by: Pavan Navarathna <pavan@kasten.io>

Co-authored-by: Vivek Singh <vsingh.ggits.2010@gmail.com>
Co-authored-by: Pavan Navarathna <pavan@kasten.io>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Dec 16, 2021
1 parent 12157ea commit 1fc41c2
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,111 @@ Example:
args:
snapshotID: "{{ .ArtifactsIn.backupInfo.KeyValue.snapshotID }}"
KubeOps
-------

This function is used to create or delete Kubernetes resources.

Arguments:

.. csv-table::
:header: "Argument", "Required", "Type", "Description"
:align: left
:widths: 5,5,5,15

`operation`, Yes, `string`, ``create`` or ``delete`` Kubernetes resource
`namespace`, No, `string`, namespace in which the operation is executed
`spec`, No, `string`, resource spec that needs to be created
`objectReference`, No, `map[string]interface{}`, object reference for delete operation

Example:

.. code-block:: yaml
:linenos:
- func: KubeOps
name: createDeploy
args:
operation: create
namespace: "{{ .Deployment.Namespace }}"
spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ .Deployment.Name }}"
spec:
replicas: 1
selector:
matchLabels:
app: example
template:
metadata:
labels:
app: example
spec:
containers:
- image: busybox
imagePullPolicy: IfNotPresent
name: container
ports:
- containerPort: 80
name: http
protocol: TCP
Wait
----

This function is used to wait on a Kubernetes resource
until a desired state is reached.

Arguments:

.. csv-table::
:header: "Argument", "Required", "Type", "Description"
:align: left
:widths: 5,5,5,15

`timeout`, Yes, `string`, wait timeout
`conditions`, Yes, `map[string]interface{}`, keys should be ``allOf`` and/or ``anyOf`` with value as ``[]Condition``

``Condition`` struct:

.. code-block:: yaml
:linenos:
condition: "Go template condition that returns true or false"
objectReference:
apiVersion: "Kubernetes resource API version"
resource: "Type of resource to wait for"
name: "Name of the resource"
.. note::
We can refer to the object key-value in Go template condition with the help of a ``$`` prefix JSON-path syntax.

Example:

.. code-block:: yaml
:linenos:
- func: Wait
name: waitNsReady
args:
timeout: 60s
conditions:
allOf:
- condition: '{{ if (eq "{ $.status.phase }" "Invalid")}}true{{ else }}false{{ end }}'
objectReference:
apiVersion: v1
resource: namespaces
name: "{{ .Namespace.Name }}"
- condition: '{{ if (eq "{ $.status.phase }" "Active")}}true{{ else }}false{{ end }}'
objectReference:
apiVersion: v1
resource: namespaces
name: "{{ .Namespace.Name }}"
Registering Functions
---------------------

Expand Down

0 comments on commit 1fc41c2

Please sign in to comment.