Keptn v1 reached EOL December 22, 2023. For more information see https://bit.ly/keptn
This documentation is for an older Keptn release. Please consider the newest one when working with the latest Keptn.

Get started with Quality Gates

In this section, you will get an overview of the use-case and learn how to get started setting up a quality gate for your project.

ℹ️ If you are not familiar with the concept of a quality gate, learn more here.

Quality gate result

💡 A quality gate answers one question: Does my service meet all defined quality criteria?

Keptn quality gates help you answer this question by representing a quality gate results like this:

Quality gate result

This visualization in the Keptn Bridge allows you to answer the following questions:

  • First and most important, does the service meet all defined quality criteria?
    • 1️⃣ Here, the overall result is a warning as shown by the orange bar and with the total score between 50 (fail) and 90 (pass) points.
  • Which criteria did not meet its objective?
    • 2️⃣ The response time P95 was measured with 1048 ms. This value is higher than the pass criteria set at 600 ms.
  • What does the <=10% mean?
    • 3️⃣ This is a relative comparison for which the quality gate result of a previous evaluation is taken into account. In fact, the last passed comparison is taken as a reference value.
  • How did this quality result perform compared to others?
    • 4️⃣ The answer to this question can be found in the Heatmap and Chart on the top.
    • The Heatmap highlights the currently selected quality gate result with a gray and solid border. The quality gate result that is taken into comparison is highlighted by the dashed border.
    • 5️⃣ The total score of a quality gate result is depicted by the cell on the top.
    • The individual criteria are represented by a separate cell in the column.

The rest of this section assumes you have Keptn installed on your cluster, your Keptn CLI is authenticated, and you have a deployed application that is monitored by your favorite monitoring solution.

Given these requirements, this section defines the entities of a Keptn project, stage, and services using an example. Afterwards, four steps explain how to set up the quality gate, trigger it, and finally see the quality gate evaluation result.

Definition of project, stage, and service

Let’s assume you have an application that is running in an environment and composed of one or multiple services (aka. microservices). For example, you have an application called easyBooking, which can be broken down into the booking and payment service. Besides, the application is running in a quality_assurance environment (aka. stage). In order to manage your application and services in Keptn, you need a Keptn project, stage and services. For the easyBooking application, the Keptn entities of a project, stage, and service map to the example as follows:

  • project: easyBooking
  • stage: quality_assurance
  • service: booking & payment (For the sake of simplicity, a quality gate will be configured for booking only.)

For defining the stage(s) a service has to go through, a Shipyard file is needed. Since a quality gate should be configured for the quality_assurance environment only, the corresponding Shipyard for the easyBooking project looks as follows:

apiVersion: "spec.keptn.sh/0.2.3"
kind: "Shipyard"
metadata:
  name: "shipyard-sockshop"
spec:
  stages:
    - name: "quality-assurance"

You do not have to define any task sequence in a stage because quality gates (aka. evaluation) are a built-in Keptn capability. Hence, there is no need to explicitly add an evaluation sequence. However, the explicit form of the above Shipyard file would look as the following one, which behaves the same way:

apiVersion: "spec.keptn.sh/0.2.3"
kind: "Shipyard"
metadata:
  name: "shipyard-sockshop"
spec:
  stages:
    - name: "quality-assurance"
      sequences:
       - name: "evaluation"
         tasks:
         - name: "evaluation"

Create project and service

Note: It is not needed to create the stage since it is declared in the Shipyard that is applied during the project creation.

Step 1: Create project and service

  • To create the Keptn project (e.g., easyBooking), use the keptn create project CLI command. Here the Shipyard file is needed, which declares the stages.

  • To create the Keptn service (e.g., booking), use the keptn create service CLI command.

Step 2: Configure Keptn to use your SLI-provider and add SLIs

Depending on the monitoring solution you have in place, a corresponding SLI-provider is required by Keptn. This SLI-provider gets its queries for the individual metrics from the Service-Level Indicator (SLI) config.

  • Familiarize yourself with the concept of an SLI and derive the set of indicators required for, e.g., the booking service.

  • Follow the steps of deploying an SLI-provider and uploading an SLI config as described here.

Step 3: Add SLO configuration to a service

By adding an Service-Level Objective (SLO) config to your service, you activate a quality gate for that service.

Step 4: Trigger the quality gate

At this point, you have:

✔️ created the project e.g. easyBooking and the service e.g. booking

✔️ configured Keptn to use your SLI-provider with custom SLIs

✔️ activated the quality gate for e.g. booking by providing an SLO

To trigger a quality gate evaluation, execute the keptn trigger evaluation CLI command. This CLI command sends an event to Keptn, which acknowledges receipt of the event by returning a unique ID (keptn-context). This unique ID is required to fetch the result of the quality gate evaluation.

ℹ️ Learn here more about working with a quality gate and integrating it into an existing pipeline.