Skip to main content

Installing Kratix

This is Part 1 of a series illustrating how Kratix works.
👉🏾 Next: Install a Kratix Promise


In this tutorial, you will

What is Kratix?

Kratix is a framework used by platform teams to build the custom platforms tailored to their organisation.

Using Kratix to build your platform you can:

  • use GitOps workflow with Flux and familiar Kubernetes-native constructs.
  • co-create capabilities by providing a clear contract between application and platform teams through the definition and creation of “Promises”. We'll talk more about Kratix Promises in the next step.
  • create a flexible platform with your paved paths as Promises.
  • evolve your platform easily as your business needs change.
  • start small on a laptop and expand to multi-team, multi-cluster, multi-region, and multi-cloud with a consistent API everywhere.

Providing a Kratix-built platform allows your users to:

  • discover available services that are already fit-for-purpose.
  • consume services on demand using standard Kubernetes APIs.
  • move focus away from infrastructure toward adding product value.

Hands on: Installing Kratix

Before you begin installing Kratix:

System setup

For this workshop, we'll use Kratix on two local Kubernetes clusters. Install the prerequisites listed below if they aren't already on your system.

  1. kind CLI / Kubernetes-in-Docker(KinD):
    Used to create and manage local Kubernetes clusters in Docker.
    See the quick start guide to install.

  2. docker CLI / Docker:
    Used to orchestrate containers. kind (above) requires that you have Docker installed and configured.
    See Get Docker to install.

    caution

    Docker Desktop (For Mac) v4.13.0 has a known issue that crashes Docker Daemon on specific situations. Please ensure you are using an earlier or later version of Docker.

  3. kubectl / Kubernetes command-line tool:
    The CLI for Kubernetesallows you to run commands against Kubernetes clusters.
    See the install guide.

Update your Docker resource allocations

In order to complete all tutorials in this series, you must allocate enough resources to Docker. Docker requires:

  • 5 CPU
  • 12GB Memory
  • 4GB swap

This can be managed through your tool of choice (e.g. Docker Desktop, Rancher, etc).

Delete existing Kratix KinD clusters

Ensure no clusters are currently running.

kind get clusters

The above command will give an output similar to

No kind clusters found.

If you have clusters named platform or worker please delete them with

kind delete clusters platform worker

Clone Kratix

You will need the Kratix source code to complete this workhshop. Clone the repository to your local machine.

git clone https://github.com/syntasso/kratix.git
cd kratix

Installation

Now that your system is set up for the workshop, you can install Kratix! You should be in the kratix folder.

Steps:

  1. Set up your platform cluster
  2. Adjust networking for KinD, if required
  3. Set up your worker cluster

A complete installation of Kratix looks like the diagram below:

Overview



ReferenceComponentDescription
1️⃣platform  clusterThe first of two local Kubernetes clusters that Kratix will use. This allows your platform to have orchestration logic separated from application workloads.
2️⃣Kratix CRDsA set of CRDs that Kratix requires.
3️⃣kratixplatformcontroller  PodAt a very high level, this manages the lifecycle of Kratix resources.
4️⃣An installation of MinIOMinIO is a local document store, which is what the Kratix platform cluster needs for storing generated resource definitions. MinIO works well with KinD, but Kratix can use any storage mechanism that speaks either S3 or Git.
5️⃣worker clusterThe second of two local Kubernetes clusters that Kratix will use. In this workshop, you run one single separate cluster to manage application workloads, but Kratix allows you to design the cluster architecture that makes sense in your context.
6️⃣An installation of FluxKratix uses GitOps workflow, and Flux is the mechanism to continuously synchronise the resources defined in the document store (MinIO) to the worker clusters. Similar to document storage, this workshop uses Flux, but Kratix can use any tool that follows the GitOps pattern of using repositories as the source of truth for defining desired Kubernetes state.

Now that you know what the installation looks like, bring Kratix to life.

Set up your Kratix platform cluster

Create your platform cluster and install Kratix and MinIO.

kind create cluster --name platform --image kindest/node:v1.24.0
kubectl apply --filename distribution/kratix.yaml
kubectl apply --filename hack/platform/minio-install.yaml

Verify that the Kratix API is now available.

kubectl get crds

You should see something similar to

NAME                                   CREATED AT
clusters.platform.kratix.io 2022-05-10T12:00:00Z
promises.platform.kratix.io 2022-05-10T12:00:00Z
workplacements.platform.kratix.io 2022-05-10T12:00:00Z
works.platform.kratix.io 2022-05-10T12:00:00Z

Verify Kratix and MinIO are installed and healthy.
(This may take a few minutes so --watch will watch the command. Press Ctrl+C to stop watching)

kubectl --context $PLATFORM get pods --namespace kratix-platform-system --watch

You should see something similar to

NAME                                                  READY   STATUS       RESTARTS   AGE
kratix-platform-controller-manager-769855f9bb-8srtj 2/2 Running 0 1h
minio-6f75d9fbcf-5cn7w 1/1 Running 0 1h

Adjust multi-cluster networking for KinD

Some KinD installations use non-standard networking. To ensure cross-cluster communication you need to run this script:

PLATFORM_CLUSTER_IP=`docker inspect platform-control-plane | grep '"IPAddress": "172' | awk '{print $2}' | awk -F '"' '{print $2}'`
sed -i'' -e "s/172.18.0.2/$PLATFORM_CLUSTER_IP/g" hack/worker/gitops-tk-resources.yaml
note

Running the above command will not change your local configuration, but rather update Kratix-provided configuration to use the appropriate KinD network.


Set up your Kratix worker cluster

Create your Kratix worker cluster and install Flux. This will create a cluster for running the X as-a-Service workloads:

kind create cluster --name worker --image kindest/node:v1.24.0

# Register the Worker Cluster with the Platform Cluster
kubectl apply \
--filename config/samples/platform_v1alpha1_worker_cluster.yaml\
--context $PLATFORM

# Install Flux on the Worker Cluster
kubectl apply \
--filename hack/worker/gitops-tk-install.yaml \
--context $WORKER
kubectl apply \
--filename hack/worker/gitops-tk-resources.yaml \
--context $WORKER

Verify Flux is installed and configured (i.e., Flux knows where in MinIO to look for resources to install).
(This may take a few minutes so --watch will watch the command. Press Ctrl+C to stop watching)

kubectl get buckets.source.toolkit.fluxcd.io \
--context $WORKER \
--namespace flux-system \
--watch

You should see something similar to

NAME                        URL   READY   STATUS                                                       AGE
kratix-workload-crds True Fetched revision: 9343bf26ec16db995d7b53ff63c64b7dfb9789c4 1m
kratix-workload-resources True Fetched revision: f2d918e21d4c5cc65791d121f4a3375ad80a3eac 1m

Once Flux is running, the Kratix running on the platform cluster will have the ability to manage resources on the worker cluster.

Verify that you can deploy resources to the worker cluster—Kratix will always create a `kratix-worker-cluster` namespace, so you can check the namespace to ensure the installation has been successful.
(This may take a few minutes so --watch will watch the command. Press Ctrl+C to stop watching)

kubectl --context $WORKER get namespaces --watch

You should see something similar to

NAME                   STATUS   AGE
kratix-worker-system Active 1m
default Active 3m32s
flux-system Active 3m23s
kube-node-lease Active 3m33s
kube-public Active 3m33s
kube-system Active 3m33s
...

Summary

You created a platform using Kratix. Well done!

To recap the steps we took:

  1.   Setup your machine to run multiple Kubernetes clusters via KinD
  2.   Installed Kratix on the platform cluster
  3.   Installed MinIO on the platform cluster as the document store for our GitOps solution
  4.   Confirmed that local networking allows those clusters to communicate
  5.   Registered the worker cluster with Kratix
  6.   Installed Flux on the worker cluster to continuously synchronise documents in MinIO to the worker cluster

Next you will install your first Kratix Promise.

🎉   Congratulations!

  Kratix is now installed.
👉🏾   Next you will install an sample Kratix Promise.