Manage release lifecycle
In this exercise, we will configure the Keptn Lifecyle Toolkit
to run deployment checks as part of your deployment.
Whether you are deploying your software with
Argo, Flux, another deployment engine, or even
the Lifecycle Toolkit can do the following:
Pre-deploy: Validate external dependencies, confirm that images are scanned, and so forth
Post-deply: Execute tests, notify stakeholders, promote to the next stage
Automatically validate against your SLO (Service Level Objectives)
KLT sits on top of the Kubernetes scheduler and can do the following:
- Trace the deployment from start to end
- KLT is application aware, so can extend the deployment with tasks and evaluations that are run either before or after your whole application starts the deployment or at the individual workload level.
- Validate any Keptn metric, either pre- or post-deployment, using the metrics from the Keptn Metrics Server introduced in Getting started with Keptn metrics.
This means that you can be sure that the environment is healthy and has adequate resources before you begin the deployment. After the deployment succeeds, use Keptn metrics to confirm that your deployed software is really healthy – not just that the pods are running but validate against SLOs such as performance and user experience. You can also check for new logs that came in from a log monitoring solution.
Using this exercise
This exercise shows how to implement pre- and post-deployment evaluations and tasks for your application. It is based on the simplenode-dev example.
The steps to implement pre- and post-deployment orchestration are:
- Define evaluations to be performed pre- and post-deployment
- Define tasks to be performed pre- and post-deployment
- Integrate evaluations and tasks into the cluster
This is the third of three exercises in the Introducing the Keptn Lifecycle Toolkit series. You may want to complete the other exercises before doing this exercise although that is not required:
- In the Getting started with Keptn metrics exercise, you learn how to define and use Keptn metrics.
- In Standardize observability, you learn how to standardize access to the observability data for your cluster.
If you are installing the Keptn Lifecycle Toolkit on an existing cluster or in a local cluster you are creating for this exercise and did not previously set up your cluster for the Standardize observability exercise, you need to do the following:
Follow the instructions in Install and update to install and enable KLT on your cluster.
Follow the instructions in Integrate KLT with your applications to integrate KLT with your Kubernetes cluster:
- Follow the instructions in
to integrate the Lifecycle Toolkit into your Kubernetes cluster
by applying basic annotations to your
- Follow the instructions in Define a Keptn application to create a KeptnApp resource that includes all workloads on the cluster, regardless of the tools being used. For this exercise, we recommend that you Use Keptn automatic app discovery to automatically generate a Keptn Application.
- Follow the instructions in Annotate workload to integrate the Lifecycle Toolkit into your Kubernetes cluster by applying basic annotations to your
Define evaluations to be performed pre- and post-deployment
evaluation is a KeptnMetric that has a defined target value.
Evaluations are resources that are defined in a
In our example, evaluations are defined in the
For example, the definition of the
looks like this:
apiVersion: lifecycle.keptn.sh/v1alpha3 kind: KeptnEvaluationDefinition metadata: name: evaluate-dependencies namespace: simplenode-dev spec: objectives: - keptnMetricRef: name: available-cpus namespace: simplenode-dev evaluationTarget: ">4"
You see that the
available-cpus metric is defined in the
evaluationTarget is set to be
so this evaluation makes sure that more than 4 CPUs are available.
You could include objectives and additional metrics in this evaluation.
Define tasks to be performed pre- and post-deployment
Tasks are resources that are defined in a
In our example, the tasks are defined in the
As an example,
we have a
notify task that composes some markdown text
to be sent as Slack notifications
KeptnTaskDefinition looks like this:
Note that, beginning with KLT 0.8.0, you can also use Python 3 to define your task, or you can define a standard Kubernetes container that uses the image, runner, and runtime dependencies that you choose. For more information, see Working with Keptn tasks.
Because the slack server that is required to execute this task is protected by a secret, the task definition also specifies that secret.
Integrate evaluations and tasks into the cluster
Follow the instructions in
to integrate the evaluations and tasks you defined
into the cluster
by applying annotations to the
file for an example.