Skip to main content

Quick Start

One of the most powerful features of Kratix is its ability to handle requests for resources, and deploy them to a remote specific cluster. However, Kratix also works well in a single cluster environment. This quick-start guide will walk you through the steps to install Kratix on a single cluster.

Prerequisite: Kubernetes Cluster

Kratix requires a Kubernetes cluster to run. If you don't already have a cluster, we recommend starting with a local cluster tool like KinD or minikube.

1. Install Kratix

Install Kratix and its dependencies with the command below:

kubectl apply --filename https://raw.githubusercontent.com/syntasso/kratix/main/distribution/single-cluster/install-all-in-one.yaml

The above will install Kratix, MinIO, and FluxCD. MinIO will be the StateStore for the Kratix to write to and FluxCD will watch the MinIO Bucket for any changes that need to be applied to the cluster. Kratix supports a variety of StateStores and multiple different StateStores can be used.

Configure

Once Kratix is installed, you can register Kubernetes clusters where workloads should run. On single cluster installations, the same cluster performs the role of the Platform and the Worker clusters. The commands below will register the cluster, as well as configure FluxCD to watch for the cluster's StateStore:

kubectl apply --filename https://raw.githubusercontent.com/syntasso/kratix/main/distribution/single-cluster/config-all-in-one.yaml

Once the system reconciles, the Kratix resources should now be visible on your cluster. You can verify its readiness by observing the kratix-worker-system namespace appearing in the cluster (it may take a couple of minutes):

$ kubectl get namespace kratix-worker-system
NAME STATUS AGE
kratix-worker-system Active 1m

2. Provide Postgres-as-a-Service via a Kratix Promise

Install the sample Postgres Promise with the command below:

kubectl apply --filename https://raw.githubusercontent.com/syntasso/promise-postgresql/main/promise.yaml

Installing the Promise will eventually start the Postgres Operator on your cluster. You can verify by running:

kubectl get pods

It may take a few seconds, but you should eventually see something similar to:

NAME                                 READY   STATUS    RESTARTS   AGE
postgres-operator-7dccdbff7c-2hqhc 1/1 Running 0 1m

3. Self serve a Postgres

Once the Postgres Operator is up and running, you can request a new Postgres instance with the command below:

kubectl apply --filename https://raw.githubusercontent.com/syntasso/promise-postgresql/main/resource-request.yaml

You can verify the pipeline pod by running:

$ kubectl get pods
NAME READY STATUS RESTARTS AGE
request-pipeline-postgresql-default-8f012 0/1 Completed 0 72s
postgres-operator-6c6dbd4459-pbcjp 1/1 Running 0 6m55s

Eventually, the Postgres instance pods will come up as well:

$ kubectl get pods
NAME READY STATUS RESTARTS AGE
acid-example-postgresql-0 1/1 Running 0 113s
postgres-operator-6c6dbd4459-pbcjp 1/1 Running 0 6m55s
request-pipeline-postgresql-default-8f012 0/1 Completed 0 2m17s

You are now ready to use your Postgres instance! To validate, you can run:

kubectl exec -it acid-example-postgresql-0 -- sh -c "
PGPASSWORD=$(kubectl get secret postgres.acid-example-postgresql.credentials.postgresql.acid.zalan.do -o 'jsonpath={.data.password}' | base64 -d) \
PGUSER=$(kubectl get secret postgres.acid-example-postgresql.credentials.postgresql.acid.zalan.do -o 'jsonpath={.data.username}' | base64 -d) \
psql bestdb"

Clean up

To clean up the created resources, run:

kubectl delete --filename https://raw.githubusercontent.com/syntasso/promise-postgresql/main/promise.yaml
kubectl delete --filename https://raw.githubusercontent.com/syntasso/kratix/main/distribution/single-cluster/install-all-in-one.yaml

🎉 Congratulations!

You have successfully installed Kratix and used it to deliver Postgres-as-a-Service to your platform. Check out our guides to learn more about Kratix capabilities.