|
| 1 | +# Getting Started with Kadras Engineering Platform |
| 2 | + |
| 3 | +This guide describes how to install the Kadras Engineering Platform on a local Kubernetes cluster and deploy a sample application workload that will take advantage of the platform capabilities such as serverless runtime, ingress and certificate management, and GitOps. |
| 4 | + |
| 5 | +## Objectives |
| 6 | + |
| 7 | +* Install Kadras on a Kubernetes cluster |
| 8 | +* Deploy a sample application |
| 9 | +* Explore the capabilities provided by the platform |
| 10 | + |
| 11 | +## Before you begin |
| 12 | + |
| 13 | +To follow the guide, Ensure you have the following tools installed in your local environment: |
| 14 | + |
| 15 | +* Kubernetes [`kubectl`](https://kubectl.docs.kubernetes.io/installation/kubectl) |
| 16 | +* Carvel [`kctrl`](https://carvel.dev/kapp-controller/docs/latest/install) |
| 17 | +* Carvel [`kapp`](https://carvel.dev/kapp-controller/docs/latest/install/#installing-kapp-controller-cli-kctrl). |
| 18 | + |
| 19 | +Then, create a local Kubernetes cluster with [kind](https://kind.sigs.k8s.io). |
| 20 | + |
| 21 | +```shell |
| 22 | +cat <<EOF | kind create cluster --config=- |
| 23 | +kind: Cluster |
| 24 | +apiVersion: kind.x-k8s.io/v1alpha4 |
| 25 | +name: kadras |
| 26 | +nodes: |
| 27 | +- role: control-plane |
| 28 | + extraPortMappings: |
| 29 | + - containerPort: 80 |
| 30 | + hostPort: 80 |
| 31 | + protocol: TCP |
| 32 | + - containerPort: 443 |
| 33 | + hostPort: 443 |
| 34 | + protocol: TCP |
| 35 | +EOF |
| 36 | +``` |
| 37 | + |
| 38 | +## Deploy Carvel kapp-controller |
| 39 | + |
| 40 | +The platform relies on the Kubernetes-native package management capabilities offered by Carvel [kapp-controller](https://carvel.dev/kapp-controller). You can install it with Carvel [`kapp`](https://carvel.dev/kapp/docs/latest/install) (recommended choice) or `kubectl`. |
| 41 | + |
| 42 | +```shell |
| 43 | +kapp deploy -a kapp-controller -y \ |
| 44 | + -f https://github.com/carvel-dev/kapp-controller/releases/latest/download/release.yml |
| 45 | +``` |
| 46 | + |
| 47 | +## Add the Kadras Package Repository |
| 48 | + |
| 49 | +Add the Kadras repository to make the platform packages available to the cluster. |
| 50 | + |
| 51 | + ```shell |
| 52 | + kctrl package repository add -r kadras-packages \ |
| 53 | + --url ghcr.io/kadras-io/kadras-packages:0.14.2 \ |
| 54 | + -n kadras-packages --create-namespace |
| 55 | + ``` |
| 56 | + |
| 57 | +## Configure the Platform |
| 58 | + |
| 59 | +The installation of the Kadras Engineering Platform can be configured via YAML. Create a `values.yml` file with any configuration you need for the platform. The following is a minimal configuration example for a local environment, based on the `run` installation profile. |
| 60 | + |
| 61 | +```yaml title="values.yml" |
| 62 | +platform: |
| 63 | + profile: run |
| 64 | + infrastructure_provider: local |
| 65 | + ingress: |
| 66 | + domain: 127.0.0.1.sslip.io |
| 67 | +``` |
| 68 | +
|
| 69 | +The Ingress is configured with the special domain `127.0.0.1.sslip.io` which will resolve to your localhost and be accessible via the kind cluster. |
| 70 | + |
| 71 | +## Install the Platform |
| 72 | + |
| 73 | +Reference the `values.yml` file you created in the previous step and install the Kadras Engineering Platform. |
| 74 | + |
| 75 | + ```shell |
| 76 | + kctrl package install -i engineering-platform \ |
| 77 | + -p engineering-platform.packages.kadras.io \ |
| 78 | + -v 0.12.2 \ |
| 79 | + -n kadras-packages \ |
| 80 | + --values-file values.yml |
| 81 | + ``` |
| 82 | + |
| 83 | +## Verify the Installation |
| 84 | + |
| 85 | +Verify that all the platform components have been installed and properly reconciled. |
| 86 | + |
| 87 | + ```shell |
| 88 | + kctrl package installed list -n kadras-packages |
| 89 | + ``` |
| 90 | + |
| 91 | +## Run an Application via CLI |
| 92 | + |
| 93 | +Kadras Engineering Platform provides capabilities to support application deployment workflows from image to URL based on Knative or plain Kubernetes. Furthermore, you can optionally use the built-in GitOps capabilities provided by Flux or Carvel. |
| 94 | + |
| 95 | +For this example, let's use the [kn](https://knative.dev/docs/client) CLI to deploy an application workload in a serverless runtime provided by Knative. |
| 96 | + |
| 97 | +```shell |
| 98 | +kn service create band-service \ |
| 99 | + --image ghcr.io/thomasvitale/band-service \ |
| 100 | + --security-context strict |
| 101 | +``` |
| 102 | + |
| 103 | +The application will be available through a local URL with a self-signed certificate (via Contour and cert-manager) and autoscaling capabilities (thanks to Knative). You can open the URL in the browser or use a CLI like [httpie](https://httpie.io). |
| 104 | + |
| 105 | +```shell |
| 106 | +https band-service.default.127.0.0.1.sslip.io --verify no |
| 107 | +``` |
| 108 | + |
| 109 | +After testing the application, remember to delete it. |
| 110 | + |
| 111 | +```shell |
| 112 | +kn service delete band-service |
| 113 | +``` |
| 114 | + |
| 115 | +## Run an Application via GitOps |
| 116 | + |
| 117 | +Let's now deploy the same application using a GitOps workflow powered by Flux. You can either apply the Flux resources directly to the cluster or use the convenient [Flux CLI](https://fluxcd.io/flux/installation/#install-the-flux-cli). We'll use the second approach. |
| 118 | + |
| 119 | +First, configure a Git repository for Flux to monitor. |
| 120 | + |
| 121 | +```shell |
| 122 | +flux create source git band-service \ |
| 123 | + --url=https://github.com/ThomasVitale/band-service \ |
| 124 | + --branch=main \ |
| 125 | + --interval=1m |
| 126 | +``` |
| 127 | + |
| 128 | +Then, create a Flux Kustomization that will deploy the application. |
| 129 | + |
| 130 | +```shell |
| 131 | +flux create kustomization band-service \ |
| 132 | + --target-namespace=default \ |
| 133 | + --source=band-service \ |
| 134 | + --path="./k8s" \ |
| 135 | + --wait=true |
| 136 | +``` |
| 137 | + |
| 138 | +The application will be available through a local URL with a self-signed certificate (via Contour and cert-manager) and autoscaling capabilities (thanks to Knative). You can open the URL in the browser or use a CLI like [httpie](https://httpie.io). |
| 139 | + |
| 140 | +```shell |
| 141 | +https band-service.default.127.0.0.1.sslip.io --verify no |
| 142 | +``` |
0 commit comments