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

docs: [WIP] PoC draft of CRD reference pages #889

Closed
wants to merge 3 commits into from
Closed
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
127 changes: 127 additions & 0 deletions docs/content/en/docs/crd-ref/KeptnTaskDefinition/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: KeptnTaskDefinition
description: Define tasks that can be run pre- or post-deployment
weight: 89
---

A `KeptnTaskDefinition` is a CRD used to define tasks
that can be run by the Keptn Lifecycle Toolkit
as part of pre- and post-deployment phases of a deployment.
The task definition is a [Deno](https://deno.land/) script.
Please, refer to the [function runtime](https://github.com/keptn/lifecycle-toolkit/tree/main/functions-runtime)
for more information about the runtime.
In the future, we also intend to support other runtimes,
especially running a container image directly.

## Synopsis

```yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have code examples of our CRDs already prepared (mostly). I would use a link here instead of actual code.
You can find the examples here: #888

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to embed this content in the source and have it autogenerated! But I figured I needed to hand-write a few pages to work things out and then we know what we want the tools to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would very much like the "Synopsis" to show on the reference page that is displayed in the documentation, with a format similar to what I have here. But it would be ideal if that were pulled from the software source so it does not need to be maintained manually! I very much like the idea of just pointing to existing examples -- that allows people to see how this CRD fits in the "big picture" as it were.

apiVersion: lifecycle.keptn.sh/v1alpha2
kind: KeptnTaskDefinition
metadata:
name: <task-name>
spec:
function:
inline: | httpRef | functionRef
[parameters:
map:
textMessage: "This is my configuration"]
[secureParameters:
secret: slack-token]
```

## Fields

* **apiVersion** - API version being used.
The default for KLT Release 0.5.0 is `lifecycle.keptn.sh/v1alpha2`.
* This must match <whatever>
* Other information
`
* **kind** CRD type. This is `KeptnTaskDefinition`

* **name** Unique name of this task.
This must be an alphanumeric string and, by convention, is all lowercase.
It can use the special characters `_`, `-` ... <what others>.
It should not inclue spaces.

* **function** - Code to be executed.
This can be expressed as one of the following:

* **inline** - Include the actual executable code to execute.
This can be written as a full-fledged Deno script.
For example:
```function:
inline:
code: |
console.log("Deployment Task has been executed");
```
* **httpRef** - Specify a Deno script to be executed at runtime
from the remote webserver that is specified.
For example:

```yaml
name: hello-keptn-http
spec:
function:
httpRef:
url: <url>
```
* **functionRef** -- Execute another `KeptnTaskDefinition` that has been defined.
Populate this field with the value of the `name` field
for the `KeptnTaskDefinition` to be called.
This is commonly used to call a general function
that is used in multiple place with different parameters.
An example is:
```yaml
spec:
function:
functionRef:
name: slack-notification
```

This can also be used to group a set of tasks into a single `KeptnTaskDefinitions`,
such as defining a `KeptnTaskDefinition` for testing
and have it call a `KeptnTaskDefinition` for each type of test to be run.

* **parameters** - An optional field to supply input parameters to a function.
The Lifecycle Toolkit passes the values defined inside the `map` field
as a JSON object.
At the moment, multi-level maps are not supported.
For example:
```spec:
parameters:
map:
textMessage: "This is my configuration"
```

The JSON object can be read
through the `DATA` environment variable using `Deno.env.get("DATA");`.

* **secureParameters** -- An optional field used to pass a Kubernetes secret.
The `secret` value is the Kubernetes secrete name
that is mounted into the runtime
and made available to the function
using the `SECURE_DATA` environment variable.

```yaml
secureParameters:
secret: slack-token
```

## Usage

A Task is responsible for executing the TaskDefinition of a workload.
The execution is done by spawning a K8s Job to handle a single Task.
In its state, it keeps track of the current status of the K8s Job created.


<!-- How this CRD is "activated". For example, which event uses this CRD -->
<!-- Instructions and guidelines for when and how to customize a CRD -->

## Examples

## Files

## Differences between versions

## See also
4 changes: 2 additions & 2 deletions docs/content/en/docs/crd-ref/crd-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Copy this template to create a new CRD reference page.

## Synopsis

## Parameters
## Fields

<!-- Detailed description of each field/parameter -->
<!-- Detailed description of each field-->

## Usage

Expand Down