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: restructure info on tasks and evaluations #2639

Merged
merged 43 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8c0b7ee
docs: restructure info on tasks and evaluations
StackScribe Dec 6, 2023
7a6dce8
markdownlint-fix
StackScribe Dec 6, 2023
bbec7c1
Ketn
StackScribe Dec 6, 2023
1e21dda
xrefs
StackScribe Dec 6, 2023
667d288
analysis text in evaluations
StackScribe Dec 11, 2023
4f82e34
pre/post annotations removed from integrate
StackScribe Dec 12, 2023
287dee0
links to pre/post deployment annotations
StackScribe Dec 13, 2023
cd628aa
try again
StackScribe Dec 13, 2023
444fc08
copy content to docs-new
StackScribe Dec 13, 2023
51dd1dd
Merge branch 'main' into 1201-autoapp
StackScribe Dec 13, 2023
856a166
Update docs-new/docs/guides/integrate.md
StackScribe Dec 14, 2023
5ae6780
some _index.md -> index.md fixes
StackScribe Dec 14, 2023
dcb7142
fix links
mowies Dec 14, 2023
4832f94
Delete docs-new/docs/core-concepts/usecase-orchestrate.md
StackScribe Dec 15, 2023
9d3d0b9
Delete docs/content/en/docs/reference/crd-reference/app.md
StackScribe Dec 19, 2023
256d3be
javascripts
StackScribe Dec 19, 2023
44b2fa5
Merge branch 'main' into 1201-autoapp
mowies Dec 19, 2023
0baa58f
remove app.md xref to pre/post annotations
StackScribe Dec 19, 2023
222b5ad
Update docs-new/docs/components/lifecycle-operator/keptn-apps.md
StackScribe Dec 19, 2023
dafc0de
Update docs-new/docs/components/lifecycle-operator/keptn-apps.md
StackScribe Dec 19, 2023
01cb07e
Update docs-new/docs/getting-started/lifecycle-management.md
StackScribe Dec 19, 2023
253b820
Update docs-new/docs/getting-started/lifecycle-management.md
StackScribe Dec 19, 2023
cfc226c
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
659a7ff
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
6c2bdbc
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
086c1d5
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
80e3c64
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
7f8413c
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
48e0c78
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
c4ba4ec
Update docs-new/docs/getting-started/lifecycle-management.md
StackScribe Dec 19, 2023
7a296b8
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
a4317a5
Update docs-new/docs/guides/integrate.md
StackScribe Dec 19, 2023
bfbc9b1
Update docs-new/docs/guides/integrate.md
StackScribe Dec 19, 2023
cea5fb2
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
32b2abf
Update docs-new/docs/guides/evaluations.md
StackScribe Dec 19, 2023
4777ceb
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
ed2343b
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
16e0610
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
c3e5599
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
f1e23c5
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
bf6c947
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
c8b3e20
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 2023
dcb6aa5
Update docs-new/docs/guides/tasks.md
StackScribe Dec 19, 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
1 change: 0 additions & 1 deletion .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ prebuilt
Predeployment
PREDEPLOYMENTEVALUATIONSTATUS
PREDEPLOYMENTSTATUS
prepost
prepostdeployment
prepostevaluation
previewer
Expand Down
8 changes: 4 additions & 4 deletions docs-new/docs/components/lifecycle-operator/keptn-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ A
resource augments a Kubernetes
[Workload](https://kubernetes.io/docs/concepts/workloads/)
with the ability to handle extra phases.
It can execute the pre- and post-deployment evaluations of a Workload
and run pre- and post-deployment tasks.
It can execute the pre/post-deployment evaluations of a Workload
and run pre/post-deployment tasks.

In its state, it tracks the currently active `Workload Instances`,
(`Pod`, `DaemonSet`, `StatefulSet`, and `ReplicaSet` resources),
Expand Down Expand Up @@ -64,9 +64,9 @@ for the `KeptnApp` resource itself:
that contain the identifications required
to run the Keptn observability features.
* You must manually add the annotations described in
[Pre- and post-deployment checks](../../guides/integrate.md#prepost-deployment-checks)
[Annotations to KeptnApp](../../guides/tasks.md#annotations-to-keptnapp)
to the basic `KeptnApp` manifest to define
the evaluations and tasks you want to run pre- and post-deployment.
the evaluations and tasks you want to run pre/post-deployment.

The `KeptnApp` resources that are generated automatically
contain the identifications required to run the Keptn observability features.
Expand Down
23 changes: 13 additions & 10 deletions docs-new/docs/getting-started/lifecycle-management.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Release Lifecycle Management

The Release Lifecycle Management tools run
pre- and post-deployment tasks and checks
pre/post-deployment tasks and checks
for your existing cloud-native deployments
to make them more robust.
This tutorial introduces these tools.
Expand All @@ -15,11 +15,12 @@ exercise.

When Keptn is successfully monitoring your deployments, it can also run arbitrary tasks and SLO evaluations:

- pre-deployment (before the pod is scheduled) and
- post-deployment (after the post is scheduled)
- pre-deployment (before the Pod is scheduled)
- post-deployment (after the Pod is scheduled)

> Pre and post deployments can also run on a KeptnApp level.
> See [annotations to KeptnApp](../guides/integrate.md#annotations-to-keptnapp)
> Tasks and Evaluations can also run on a KeptnApp level.
See
[Annotations to KeptnApp](../guides/tasks.md#annotations-to-keptnapp).

## Prerequisites: Deploy webhook sink

Expand Down Expand Up @@ -51,7 +52,7 @@ Open a browser and go to `http://localhost:8084`

You should see a page like this with a unique URL (your ID will be different).

![webhook.site page](./assets/webhook.site.1.png)
![webhook.site page](assets/webhook.site.1.png)

Make a note of that unique URL.

Expand All @@ -62,7 +63,7 @@ The page should remain blank, but when toggling back to `http://localhost:8084`,

Every request sent to that unique URL will be logged here.

![webhook.site entry](./assets/webhook.site.2.png)
![webhook.site entry](assets/webhook.site.2.png)

## Add a Post Deployment Task

Expand Down Expand Up @@ -134,7 +135,7 @@ runsendevent1-***** 1/1 6s 2m

The webhook sync should show this:

![webhook sync](./assets/webhook.site.3.png)
![webhook sync](assets/webhook.site.3.png)

Incidentally, this is exactly how you can use Keptn with [applications deployed outside of Kubernetes](../use-cases/non-k8s.md).

Expand Down Expand Up @@ -214,8 +215,10 @@ Do this by using the `keptn.sh/pre-deployment-tasks` label.

## Further Information

There is a lot more you can do with KeptnTasks.
See [pre and post deployment checks page](../guides/integrate.md#prepost-deployment-checks) to find out more.
You can do a lot more with KeptnTasks.
See the
[Deployment tasks](../guides/tasks.md)
guide for more information.

## What's next?

Expand Down
134 changes: 111 additions & 23 deletions docs-new/docs/guides/evaluations.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
# Evaluations

A `KeptnEvaluation` does a simple evaluation of the metrics data you capture,
to answer a question such as "Do I have more than four CPUs available?"
or "Is my remote database accessible?"
or check for other problems in your infrastructure.
It can be defined to run before or after your software is deployed.

When an evaluation is run pre-deployment,
the deployment is kept in a pending state
until the evaluation passes with a successful result.

Use the
[Analysis](slo.md)
feature if you want to do more complex investigations
that may include multiple criteria with weights and scoring applied.

To implement evaluations, you must:

1. [Install and enable Keptn](../installation/index.md)
in your cluster.
You will need both the
Keptn Metrics Operator (`metrics-operator`)
and the Keptn Lifecycle Operator (`lifecycle-operator`)
[components](../components/index.md).
1. Define a
[KeptnMetricsProvider](../reference/crd-reference/metricsprovider.md)
resource for each data source you want to use for evaluations.
You can define multiple instances of multiple types of data providers.
1. Annotate all
[workloads](https://kubernetes.io/docs/concepts/workloads/)
([Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/),
[StatefulSets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/),
[DaemonSets](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/),
and
[ReplicaSets](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/))
with
[basic annotations](integrate.md#basic-annotations).
1. Generate the required
[KeptnApp](../reference/crd-reference/app.md)
resources following the instructions in
[Auto app discovery](auto-app-discovery.md).
1. Define a
[KeptnMetric](../reference/crd-reference/metric.md)
resource for each piece of data
(defined as a query from one of your data sources)
that you need for your evaluations.
1. [Create KeptnEvaluationDefinition](#create-keptnevaluationdefinition-resources)
resources for each evaluation you want to perform.
1. Manually edit the appropriate `KeptnApp` resources
to annotate them for each `KeptnEvaluationDefinition` resource
you want to run pre- and/or post-deployment.

## Create KeptnEvaluationDefinition resources

A
[KeptnEvaluationDefinition](../reference/crd-reference/evaluationdefinition.md)
resource contains a list of `objectives`,
Expand All @@ -8,7 +61,7 @@ meets a defined target value.
The example
[app-pre-deploy-eval.yaml](https://github.com/keptn/lifecycle-toolkit/blob/main/examples/sample-app/version-3/app-pre-deploy-eval.yaml)
file specifies the `app-pre-deploy-eval-2` evaluation as follows:
{% include "../assets/crd/eval.yaml" %}
{{< embed path="/examples/sample-app/version-3/app-pre-deploy-eval.yaml" >}}
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

The `evaluationTarget` is set to be `>1`,
so this evaluation ensures that more than 1 CPU is available
Expand All @@ -20,28 +73,7 @@ that is named `available-cpus`.
This is defined in the example
[metric.yaml](https://github.com/keptn/lifecycle-toolkit/blob/main/examples/sample-app/base/metric.yaml)
file:
{% include "../assets/crd/metric.yaml" %}

To run an evaluation on one of your
[Workloads](https://kubernetes.io/docs/concepts/workloads/)
([Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/),
[StatefulSets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/),
[DaemonSets](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/),
or
[ReplicaSets](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/),
you must:

* Annotate your [workloads](https://kubernetes.io/docs/concepts/workloads/)
to identify the `KeptnEvaluationDefinition` resource you want to run
pre- and post-deployment for the specific [workloads](https://kubernetes.io/docs/concepts/workloads/).
* Manually edit all
[KeptnApp](../reference/crd-reference/app.md) resources
to specify the `KeptnEvaluationDefinition` to be run
pre- and post-deployment evaluations for the `KeptnApp` itself.

See
[Pre- and post-deployment checks](./integrate.md#prepost-deployment-checks)
for details.
{{< embed path="/examples/sample-app/base/metric.yaml" >}}
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

Note the following:

Expand All @@ -66,3 +98,59 @@ Note the following:
is written to a
[KeptnEvaluation](../reference/api-reference/lifecycle/v1alpha3/index.md#keptnevaluation)
resource.

## Annotate the KeptnApp resource

To define the pre/post-deployment evaluations to run,
you must manually edit the
[KeptnApp](../reference/crd-reference/app.md)
YAML file to provide an annotation
for each `KeptnEvaluationDefinition` resource to be run
pre/post-deployment.
The annotations for evaluations are:

```yaml
keptn.sh/pre-deployment-evaluations: <evaluation-name>
keptn.sh/post-deployment-evaluations: <evaluation-name>
```

> **Caveat:** Be very careful when implementing pre-deployment evaluations
since, if one fails, Keptn prevents the Deployment from running.
>

The value of these annotations corresponds
to the values of the `name` field of each
[KeptnTaskDefinition](../reference/crd-reference/taskdefinition.md)
resource.
These resources contain re-usable "functions"
that can execute before and after the deployment.

If everything is fine, the deployment continues.

## Example of pre/post-deployment actions

A comprehensive example of pre/post-deployment
evaluations and tasks can be found in our
[examples folder](https://github.com/keptn/lifecycle-toolkit/tree/main/examples/sample-app),
where we use [Podtato-Head](https://github.com/podtato-head/podtato-head)
to run some simple pre-deployment checks.

To run the example, download the example
then issue the following commands:

```shell
cd ./examples/podtatohead-deployment/
kubectl apply -f .
```

Afterward, use the following command
to monitor the status of the deployment:

```shell
kubectl get keptnworkloadversion -n podtato-kubectl -w
```

The deployment for a workload stays in a `Pending` state
until the respective pre-deployment check is successfully completed.
Afterwards, the deployment starts and when the workload is deployed,
the post-deployment checks start.
Loading
Loading