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: edit lifecycle management getting started #2602

Merged
merged 26 commits into from
Jan 12, 2024
Merged
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ebf1e39
docs: edit lifecycle management getting started
StackScribe Nov 29, 2023
8e85d89
spelling
StackScribe Nov 29, 2023
a1f727a
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Nov 29, 2023
6307d97
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Nov 29, 2023
105a53e
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Nov 29, 2023
8365d03
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Nov 29, 2023
7710c2a
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Dec 13, 2023
314d2d3
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Dec 13, 2023
501c4a8
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Dec 13, 2023
a28493a
Merge branch 'main' into 1128-lifecycle-gs
mowies Dec 18, 2023
0e72033
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Dec 19, 2023
b227dcf
Update docs/content/en/docs/getting-started/lifecycle-management.md
StackScribe Dec 19, 2023
f2149c3
edits
StackScribe Dec 15, 2023
768f60b
move content to docs-new
StackScribe Dec 19, 2023
56c8e98
a few style edits
StackScribe Dec 20, 2023
6ff4a98
xrefs
StackScribe Dec 20, 2023
6a76062
more edits
StackScribe Dec 20, 2023
4444f0e
last edits
StackScribe Dec 21, 2023
61ef3ca
polish
StackScribe Dec 21, 2023
921342a
fix formatting in ordered list
StackScribe Dec 21, 2023
35bbfb3
Merge branch 'main' into 1128-lifecycle-gs
StackScribe Dec 21, 2023
1a69b2b
Update lifecycle-management.md
StackScribe Dec 21, 2023
243e7a6
Update lifecycle-management.md
StackScribe Dec 21, 2023
0888d37
Update lifecycle-management.md
StackScribe Dec 21, 2023
b6b2a2b
remove link to community/slack
StackScribe Dec 21, 2023
0f24315
Merge branch 'main' into 1128-lifecycle-gs
StackScribe Jan 10, 2024
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
121 changes: 76 additions & 45 deletions docs/content/en/docs/getting-started/lifecycle-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,65 @@ This tutorial introduces these tools.
> This tutorial assumes you have already completed the
[Getting started with Keptn Observability](../getting-started/)
exercise.
> Please ensure you've finished that before attempting this guide.
> Please ensure you've finished that before attempting this exercise.

## Keptn Pre and Post Deployment Tasks

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 and post deployments can also run on a KeptnApp level.
When Keptn is successfully monitoring your deployments,
it can also run arbitrary tasks and SLO evaluations for you
either pre-deployment or post-deployment
as specified in the pod template specs 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/),
and
[ReplicaSets](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/).
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

> Pre and post deployments can also run on a `KeptnApp` level.
> A `KeptnApp` groups multiple workloads into a single application.
> See [annotations to KeptnApp](../guides/integrate.md#annotations-to-keptnapp)

## Prerequisites: Deploy webhook sink

During this exercise, you will configure Keptn to trigger a webhook before and after a deployment has successfully completed.
During this exercise, you will configure Keptn to trigger a webhook
before and after a deployment has completed successfully.

For demo purposes, a place is required to send those request.
Install the [open source webhook.site tool](https://github.com/webhooksite/webhook.site/tree/master/kubernetes) now.
For demo purposes, a place is required to which those request are sent.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
To implement this:

This will provide a place, on cluster, to send (and view) web requests.
1. Install the
[open source webhook.site tool](https://github.com/webhooksite/webhook.site/tree/master/kubernetes).

> Note: If you have your own endpoint, you can skip this step.
This provides a place on your cluster to which web requests are sent
and from which they can be viewed.

```shell
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/namespace.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/redis.deployment.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/laravel-echo-server.deployment.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/webhook.deployment.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/service.yml
```
1. Execute the following commands to apply the web hook:

Wait until all pods are running in the `webhook` namespace then port-forward and view the webhook sink page:
> Note: If you have your own endpoint, you can skip this step.

```shell
kubectl -n webhook wait --for=condition=Ready pods --all
kubectl -n webhook port-forward svc/webhook 8084
```
```shell
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/namespace.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/redis.deployment.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/laravel-echo-server.deployment.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/webhook.deployment.yml
kubectl apply -f https://raw.githubusercontent.com/webhooksite/webhook.site/master/kubernetes/service.yml
```

1. Wait until all pods are running in the `webhook` namespace
then port-forward and view the webhook sink page:

```shell
kubectl -n webhook wait --for=condition=Ready pods --all
kubectl -n webhook port-forward svc/webhook 8084
```

Open a browser and go to `http://localhost:8084`
1. 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).
1. You should see a page like this with a unique URL
(your ID will be different than the example).

![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 @@ -64,7 +80,7 @@ Make a note of that unique URL.
Open a new browser table and go to your unique URL.
The page should remain blank, but when toggling back to `http://localhost:8084`, you should see a new entry.

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

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

Expand Down Expand Up @@ -101,9 +117,10 @@ spec:

### Verify it works

Verify that the KeptnTaskDefinition above actually works.
Verify that the `KeptnTaskDefinition` resource shown above actually works.

Trigger an on-demand task execution to verify that the job and pod function correctly.
Trigger an on-demand task execution
to verify that the job and pod are working correctly.

In the following steps we will have Keptn orchestrate this for us automatically.

Expand Down Expand Up @@ -140,17 +157,22 @@ The webhook sync should show this:

![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).
Incidentally, this is exactly how you can use Keptn with
[applications deployed outside of Kubernetes](../use-cases/non-k8s.md).

> Note: If you want to trigger this multiple times, you must change the KeptnTask name.
> Note: If you want to trigger this task multiple times,
you must change the value of the `name` field
in he `KeptnTask` resource each time.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
>
> For example, by changing `runsendevent1` to `runsendevent2`
> For example, change `runsendevent1` to `runsendevent2`.

## Ask Keptn to trigger task after Deployment

Annotate the demo application `Deployment` manifest to have Keptn automatically trigger the task after every deployment.
Annotate the demo application `Deployment` manifest
to have Keptn automatically trigger the task after every deployment.

Recall the `Deployment` from the [Observability](../getting-started/observability.md#step-3-deploy-demo-application)
Recall the `Deployment` from the
[Observability](../getting-started/observability.md#step-3-deploy-demo-application)
Getting started guide.

Add a new label so the `labels` section looks like this:
Expand Down Expand Up @@ -203,26 +225,35 @@ spec:

### What Happens Next?

1. The deployment will be applied
1. When the pods are running, Keptn will automatically create a `KeptnTask` resource for version `0.0.2` of this KeptnApp
1. The `KeptnTask` will create a Kubernetes Job
1. The Kubernetes Job will create a Pod
1. The pod will run curl and send a new event to the event sink
1. The deployment is applied.
1. When the pods are running,
Keptn automatically creates a `KeptnTask` resource
for version `0.0.2` of this `KeptnApp`.
1. The `KeptnTask` creates a Kubernetes `job`.
1. The Kubernetes `job` creates a Kubernetes `pod`.
1. The `pod` runs `curl` and sends a new event to the event sink.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

### Pre-deployment Tasks

Keptn Tasks can also be executed pre-deployment (before the pods are scheduled).
Do this by using the `keptn.sh/pre-deployment-tasks` label.
Do this by using the `keptn.sh/pre-deployment-tasks` label or annotation.

> Note: If a pre-deployment task fails, the pod will remain in a Pending state.
> Note: If a pre-deployment task fails, the `pod` remains in a Pending state.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

## Further Information

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

## What's next?

Keptn can also run pre and post deployment SLO evaluations.
Keptn can also run simple pre- and post-deployment SLO evaluations.

Continue the Keptn learning journey by adding evaluations.
See the
[Evaluations](../guides/evaluations.md)
for more information.
Loading