-
Notifications
You must be signed in to change notification settings - Fork 126
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
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
docs/content/en/docs/crd-ref/KeptnTaskDefinition/index.md
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,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 | ||
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 |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.