Skip to main content

Installing a Promise

This is Part 2 of a series illustrating how Kratix works.
👈🏾   Previous: Install Kratix
👉🏾   Next: Using multiple Kratix Promises

info

If you just completed the Installing Kratix step, you can skip the pre-requisites section.

Pre-requisites

You need a fresh installation of Kratix for this section. The simplest way to do so is by running the quick-start script from within the Kratix directory.

./scripts/quick-start.sh --recreate

Alternatively, you can go back to Installing Kratix and follow the appropriate guide.


In this guide, you will

  1. learn more about Kratix Promises
  2. install Jenkins as a Kratix Promise

What is a Kratix Promise?

Conceptually, Promises are the building blocks of Kratix that allow you to develop your platform incrementally. Technically, a Promise is a YAML document that defines a contract between the Platform and its users. You can explore more about this contract and the internals of a Kratix Promise in the writing a Promise guide.

Kratix Promises

  • enable you to build your platform incrementally and in response to the needs of your users.
  • codify the contract between platform teams and application teams for the delivery of a specific service, e.g. a database, an identity service, a supply chain, or a complete development pipeline of patterns and tools.
  • are easy to build, deploy, and update.
  • are sharable and reusable between platforms, teams, business units, and other organisations.
  • add up to a frictionless experience when platform users want to create services that they need to deliver value.

Now that you know more about Kratix Promises, follow the steps below to install a Promise.



Install the Kratix sample Jenkins Promise

Now that your system is set up, you can install your first Kratix Promise! This guide will follow the steps below:

  1. Install the Jenkins Promise
  2. Request a new Jenkins instance
  3. Use the instance
  4. Cleanup environment

Overview

Install the Jenkins Promise

tip

The commands below will refer to a KRATIX_REPO env variable. You can either:

  • clone Kratix and set it to the path of your local clone:
    export KRATIX_REPO=/path/to/kratix
  • set it to a remote URL:
    export KRATIX_REPO="https://raw.githubusercontent.com/syntasso/kratix/main"

Installing a Kratix Promise is as simple as applying the Promise YAML definition on your Platform Cluster:

kubectl --context kind-platform apply \
--filename "${KRATIX_REPO}/samples/jenkins/jenkins-promise.yaml"

Verify that your platform cluster has registered Jenkins as a new available Kratix Promise.

kubectl --context kind-platform get crds jenkins.example.promise.syntasso.io

The above command will give an output similar to

NAME                                  CREATED AT
jenkins.example.promise.syntasso.io 2021-05-10T12:00:00Z

The Jenkins Promise requires the Jenkins Operator to be deployed to the worker clusters. Kratix will deploy the operator when you apply the Promise. You can verify that the Jenkins Operator is now installed
(This may take a few minutes so --watch will watch the command. Press Ctrl+C to stop watching)

kubectl --context kind-worker get pods --watch

The above command will give an output similar to (it may take a couple of minutes):

NAME                                READY   STATUS    RESTARTS   AGE
jenkins-operator-7886c47f9c-zschr 1/1 Running 0 1m

🎉 Congratulations! You have installed your first Kratix Promise, which means your application teams can now get on-demand instances of Jenkins from your platform.

Request a Jenkins Instance

Application developers using your platform will be issued a Jenkins instance after applying a Kratix Resource Request.



Verify-Instance


Test your platform by acting as an application developer and submitting a Resource Request.

kubectl --context kind-platform apply \
--filename "${KRATIX_REPO}/samples/jenkins/jenkins-resource-request.yaml"

Verify that the Resource Request was issued on the platform cluster.

kubectl --context kind-platform get jenkins.example.promise.syntasso.io

The above command will give an output similar to

NAME                AGE
example 1m

Eventually (it can take a couple of minutes), a new Jenkins instance should spin up on your worker cluster. You can verify this by running the following command:

Verify the instance was created on the Worker Cluster
(This may take a few minutes so --watch will watch the command. Press Ctrl+C to stop watching)

kubectl --context kind-worker get pods --watch

The above command will give an output similar to

NAME                                READY   STATUS    RESTARTS   AGE
jenkins-example 1/1 Running 0 1m
jenkins-operator-7886c47f9c-zschr 1/1 Running 0 10m

🎉 Congratulations! You have successfully requested and created an on-demand instance of Jenkins from your platform.

Use your Jenkins instance

Access the Jenkins UI in a browser to ensure the instance is working.

note

Before you can access Jenkins UI, you must port forward from within the Kubernetes cluster to a local port on your computer. Running the port-forward command is continuousas long as the command is running, the connection stays open.

Open a new terminal to request the port forward.

kubectl --context kind-worker port-forward jenkins-example 8080:8080

Navigate to http://localhost:8080 and log in with the credentials you get from the commands below. In production, you want the credentials to be stored in a secure location where it could be accessed by the application team. In this example, credentials are stored as unencrypted Kubernetes secrets.

username
kubectl --context kind-worker get secret jenkins-operator-credentials-example \
-o 'jsonpath={.data.user}' | base64 -d
password
kubectl --context kind-worker get secret jenkins-operator-credentials-example \
-o 'jsonpath={.data.password}' | base64 -d

Summary

You installed your first Kratix Promise on your platform. Well done!

To recap the steps you took:

  1.   Installed the sample Jenkins Promise
  2.   Requested an instance of Jenkins
  3.   Tested the instance by logging in to the Jenkins UI

This is only the beginning of working with Promises. Next you will deploy three different Promises to provide a complete solution for an application team.

Cleanup environment

To clean up your environment you need to delete the Jenkins Resource Requests and the Jenkins Promise.

To delete the Jenkins Resource Requests:

kubectl --context kind-platform delete \
--filename "${KRATIX_REPO}/samples/jenkins/jenkins-resource-request.yaml"

Verify the Jenkins Resource Request in the Platform Cluster is gone

kubectl --context kind-platform get jenkins

and the resources for the Jenkins instance in the Worker Cluster have been deleted

kubectl --context kind-worker get pods

The above command will give an output similar to (it may take a couple of minutes)

NAME                                READY   STATUS    RESTARTS   AGE
jenkins-operator-7886c47f9c-zschr 1/1 Running 0 1m

Now you can delete the Jenkins Promise

kubectl --context kind-platform delete \
--filename "${KRATIX_REPO}/samples/jenkins/jenkins-promise.yaml"

Verify the Jenkins Promise is gone

kubectl --context kind-platform get promises

and the Jenkins Operator is deleted from the Worker Cluster (this might take a couple minutes)

kubectl --context kind-worker get pods

🎉   Congratulations!

   You have installed a Kratix Promise and used it to create on-demand instances of a service.
👉🏾   Now you will deploy a web app that uses multiple Kratix Promises.