Manage release lifecycle
In this exercise, we will configure Keptn
to run deployment checks as part of your deployment.
Whether you are deploying your software with
Argo, Flux, another deployment engine, or even
Keptn can do the following:
Pre-deploy: Validate external dependencies, confirm that images are scanned, and so forth
Post-deploy: Execute tests, notify stakeholders, promote to the next stage
Automatically validate against your SLO (Service Level Objectives)
Keptn sits on top of the Kubernetes scheduler and can do the following:
- Trace the deployment from start to end
- Keptn 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:
- Using this exercise
- 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 Keptn 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 Keptn 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 Keptn on your cluster.
- Follow the instructions in
to integrate Keptn into your Kubernetes cluster
by applying basic annotations to your
Deploymentresource. This also creates appropriate KeptnApp resources which aggregate workloads that are combined into the released product, regardless of the tools being used.
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 Keptn 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.