liveBook · Manning

KeptnTaskDefinition

As explained in Platform Engineering on Kubernetes

A KeptnTaskDefinition is a Kubernetes custom resource that declares executable behavior for a Keptn lifecycle task.

A KeptnTaskDefinition is a Kubernetes custom resource that declares executable behavior for a Keptn lifecycle task. Keptn uses these definitions to run custom pre- or post-deployment actions for monitored workloads. section 9.3

A KeptnTaskDefinition participates in a workflow that:

  • Associates applications with Keptn through standard Kubernetes annotations. section 9.3
  • Runs executable functions before or after deployment events. section 9.3
  • Receives lifecycle context describing the workload, application, version, task type, and object type. section 9.3

Inline Deno task

A definition named stdout-notification uses an inline Deno function to read the CONTEXT environment variable and print the Keptn task context. A post-deployment annotation invokes this task for a service, producing workload and application details. section 9.3

Listing 9.4 Keptn TaskDefinition using Deno
apiVersion: lifecycle.keptn.sh/v1alpha3
kind: KeptnTaskDefinition
metadata:
  name: stdout-notification                          #1
spec:
  function:
    inline:
      code: |
        let context = Deno.env.get("CONTEXT");      #2
        console.log("Keptn Task Executed with context: \n");
        console.log(context);

Inspect the complete KeptnTaskDefinition manifest, including its lifecycle API version, resource kind, inline function, and context access. section 9.3

How Platform Engineering on Kubernetes covers it

How deep it goes
Defines the resource and demonstrates inline execution and output, but does not detail the complete task runtime.
Examples
Uses the Conference application's services, an inline Deno notification task, and printed lifecycle context.
What it assumes
Assumes Kubernetes resources and annotations, while demonstrating the task definition and lifecycle context directly.
What you can do after
Operate/configure lifecycle tasks by defining inline behavior and attaching it to deployment events with annotations.
How it connects
Connects Kubernetes annotations, the Kubernetes Scheduler, deployment lifecycle hooks, and workload observability.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Platform Engineering on Kubernetes. The section links point to the parts of the book it draws on.