Keptn Hello World


The Keptn “Hello World” example in under 10 minutes.


There are lots of excellent tutorials on the Keptn website but this post aims to get you up and running with Keptn and a “Hello World” example in under 10 minutes.

What You Will Need

To follow along, you will need:

  1. A GitHub account
  2. A Kubernetes Cluster
  3. Helm installed

Create GitHub Stuff

  1. Create a GitHub PAT with full repo scope. Keptn will use this token to ensure all files and changes are synced to the upstream repo.
  2. Create a blank (uninitialised) repository for Keptn to work with. Do not add any files (not even a readme)
  3. Set some environment variables like below
export GIT_USER=<YourGitUsername>
export GIT_REPO=<YourGitUserName>/<YourRepo>
export GIT_TOKEN=ghp_****

Install and Expose Keptn

curl -sL | KEPTN_VERSION=0.12.0 bash
helm install keptn -n keptn --create-namespace --wait

All pods should now be up and running: kubectl get pods -n keptn

NAME                         READY   STATUS
bridge-*                     1/1     Running
approval-service-*           2/2     Running
api-gateway-nginx-*          1/1     Running
webhook-service-*            2/2     Running
lighthouse-service-*         2/2     Running
keptn-mongo-*                1/1     Running
remediation-service-*        2/2     Running
configuration-service-*      1/1     Running
secret-service-*             1/1     Running
keptn-nats-cluster-0         2/2     Running
api-service-*                2/2     Running
mongodb-datastore-*          2/2     Running
shipyard-controller-*        2/2     Running
statistics-service-*         2/2     Running


helm install -n keptn job-executor-service --wait

This will add one extra pod:

NAME                      READY   STATUS
job-executor-service-*    2/2     Running

Expose Keptn:

curl -SL | bash

Temporary Note: If running on localhost, that script will work perfectly. If running on a cloud provider with Load Balancers available, the script above will point to which obviously isn’t correct. To fix, run the following to expose the bridge (UI) on a loadBalancer. We’re working on a fixed script and I will remove this step once merged.

helm upgrade keptn -n keptn --set=control-plane.apiGatewayNginx.type=LoadBalancer --wait
export KEPTN_ENDPOINT=$(kubectl get services -n keptn api-gateway-nginx -o=jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "Keptn Available at: http://$KEPTN_ENDPOINT"
keptn auth --endpoint=$KEPTN_ENDPOINT

Configure Keptn

keptn create project hello-world --shipyard=shipyard.yaml --git-user=$GIT_USER --git-remote-url=$GIT_REPO --git-token=$GIT_TOKEN
keptn create service demo --project=hello-world
keptn add-resource --project=hello-world --service=demo --stage=dev --resource=jobconfig.yaml --resourceUri=job/config.yaml

Trigger Keptn

Trigger Keptn by sending a cloudevent to the API using the keptn send event command. A precrafted cloudevent is available for you:

keptn send event -f hello.triggered.event.json

Go to the Keptn bridge, into the sequence view of the hello-world project and you should see:

keptn sequence run success

What Happened?

Keptn core components were installed along with the job-executor-service microservice. The keptn CLI was also downloaded. The Keptn bridge was exposed and, to make this demo easier, all authentication was removed.

A Keptn project was created called hello-world and a shipyard file was provided. A shipyard file is the “blueprint” of a Keptn project. Inspect this file. Notice it has one stage (dev), one sequence (hello) and this sequence has one task associated to it (hello-world). A Keptn service was created called demo.

The job executor service comes preconfigured to listen for all Keptn events.

The job/config.yaml file instructs the job-executor-service microservice to run the alpine docker image and run echo "hello world" when it “hears” the sh.keptn.event.hello-world.triggered event.

The keptn send event is a wrapper around the Keptn API endpoint. The cloudevent asks Keptn to trigger the hello sequence in the dev stage of the hello-world project for the demo service.

Wait! I triggered hello, not hello-world?

Correct: You triggered the sequence and Keptn handles the task execution for you.

Humans (or other tooling) trigger Keptn sequences. Tooling responds to Keptn tasks.

Due to the shipyard file, Keptn knows that the first task in your sequence is called hello-world so:

  1. Keptn crafts a cloud event for you and distributes it to whatever service is listening for the sh.keptn.event.hello-world.triggered event
  2. In our case, the job executor service is configured to respond. The JES looks up the config from the yaml file and runs the container
  3. The job executor service sends a pair of events back to Keptn (a .started and corresponding .finished event)
  4. Keptn receives a matching pair of .started and .finished events from JES so knows the task is done
  5. Keptn now finishes the sequence

What’s the big deal?

Keptn handles the orchestration and timing, you bring the tools you already use.

You’ve successfully split the process from the tooling. You’ve hidden the complexities of tooling API interaction. There are thousands of tool integrations already written for Keptn or write your own. Keptn comes out-of-the-box with microservices dedicated to self-healing and code quality gate workflows.

With Keptn it is incredibly easy to build complex task sequences whilst no longer worrying about the tooling that will implement those tasks.

  • Try adding further tasks to your sequence
  • Try sending a webhook to a third party tool instead of using the job executor service
  • Build a full end-to-end delivery pipeline or any other sequence of tasks you can dream up

Next Steps

  1. Continue to explore Keptn on the public demo system
  2. Use Keptn for multi-stage delivery or self-healing with Prometheus
  3. Use Keptn to orchestrate Argo Rollouts
  4. Use Keptn for Resilience evaluation with LitmusChaos
  5. Explore the tools and integrations that Keptn currently supports

Got questions? Need help? Join the Keptn community on Slack