Skip to content

Commit ebd29b8

Browse files
kirederikSaphMB
andauthored
feat: add path to all destinations (#188)
Co-authored-by: Sapphire Mason-Brown <[email protected]>
1 parent 2339fa6 commit ebd29b8

File tree

4 files changed

+63
-62
lines changed

4 files changed

+63
-62
lines changed

docs/_partials/_writing-a-promise.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -773,4 +773,4 @@ kubectl --context $WORKER get pods
773773
## 🎉 &nbsp; Congratulations!
774774

775775
✅&nbsp;&nbsp; You have written a Kratix Promise. <br />
776-
👉🏾&nbsp;&nbsp; Let's [add a new Worker](./scheduling).
776+
👉🏾&nbsp;&nbsp; Let's [add a new Destination](./new-destination).

docs/main/03-reference/13-destinations/01-destinations.md

+24-33
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ metadata:
3939
labels:
4040
environment: dev
4141
spec:
42-
# Destination identifier: optional, appended path to be used within the State Store
42+
# Path within the State Store to write to.
43+
# Optional, defaults to the name of the Destination.
44+
# To write straight to the root of the State Store, set it to `/`.
4345
path: path/in/statestore
4446

45-
# Optional, defaults to false
46-
47+
# Optional, defaults to false.
4748
# By default, Kratix will schedule workloads for Promises without
4849
# `destinationSelectors` to all available Destinations.
4950
# If this property is set to true, Kratix will only schedule Workloads
@@ -73,41 +74,31 @@ spec:
7374
kind: BucketStateStore
7475
```
7576
76-
When a new Destination is registered in the platform cluster (i.e., a new Destination resource is
77-
created), Kratix will write to two paths in the [State
78-
Store](../statestore/intro):
79-
one for `resources`, one for `dependencies`. The path within the `State Store` follows the following pattern:
77+
When a new Destination is created in the platform cluster, Kratix will write to
78+
two paths in the [State Store](../statestore/intro): one for `resources`, one
79+
for `dependencies`. The path within the `State Store` follows the pattern:
8080

8181
For `dependencies`:
8282

83-
```yaml
83+
```
8484
statestore.Spec.Path/
8585
destination.Spec.Path/
86-
destination.Name/
87-
dependencies/
88-
promise.Name/
86+
dependencies/
87+
promise.Name/
8988
```
9089

9190
For `resources`:
9291

93-
```yaml
92+
```
9493
statestore.Spec.Path/
9594
destination.Spec.Path/
96-
destination.Name/
97-
resources/
98-
resource.Namespace/
99-
promise.Name/
100-
resource.Namespace/
101-
```
102-
103-
For example installing and requesting from a Promise that provides `Redis` as a service you would get:
104-
105-
```bash
106-
worker-cluster/dependencies/redis/static/dependencies.yaml
107-
worker-cluster/resources/default/redis/my-request/redis.yaml
95+
resources/
96+
resource.Namespace/
97+
promise.Name/
98+
resource.Namespace/
10899
```
109100

110-
For example:
101+
For example, for the following configuration:
111102

112103
```yaml
113104
---
@@ -137,18 +128,18 @@ spec:
137128
kind: BucketStateStore
138129
```
139130

140-
The above configuration would result in the following paths being written to:
141-
142-
- `destinations/dev/default/worker-1/dependencies/`
143-
- `destinations/dev/default/worker-1/resources/`
131+
The following directories would be created in the State Store:
144132

145-
<br/>
133+
- `destinations/dev/default/dependencies/`
134+
- `destinations/dev/default/resources/`
146135

147-
The paths should be used when setting up the workers to pull
148-
down from the `StateStore`.
136+
Kratix will, by default, write to unique directories within those paths depending on the
137+
Promise or Resource being requested. You can stop this behaviour by setting the `filepath.mode` to `none`.
149138

150139
:::info
151140

152-
The reason for two directories is that GitOps applies require any prerequisite workloads like CRDs to be ready before any dependent workloads are applied. By dividing the two directories you can configure your GitOps tool to manage this for you.
141+
Pre-requisites, like CRDs, are written to the `dependencies` subdirectory. This setup is
142+
often required by GitOps tools to ensure that all dependencies are ready before the
143+
resources themselves are applied.
153144

154145
:::

docs/main/03-reference/13-destinations/02-multidestination-management.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ In Kratix, scheduling happens in two stages:
1818
([Scheduling Workloads](#resources))
1919

2020
The following sections on this page document those stages. For hands-on scheduling guides,
21-
check the [Adding a new Destination](../../guides/scheduling) and [Compound
21+
check the [Adding a new Destination](../../guides/new-destination) and [Compound
2222
Promises](../../guides/compound-promises) pages.
2323

2424
## Scheduling Promises {#promises}
@@ -176,13 +176,13 @@ With the following `/kratix/metadata/destination-selectors.yaml`:
176176

177177
Kratix will schedule the documents as follows:
178178

179-
* `document-2.yaml`, `document-3.yaml` are scheduled to destinations with the
179+
- `document-2.yaml`, `document-3.yaml` are scheduled to destinations with the
180180
`workflow=subdir` label.
181-
* The scheduling config in `destination-selectors.yaml` has specifically scheduled this
181+
- The scheduling config in `destination-selectors.yaml` has specifically scheduled this
182182
directory.
183-
* `document-0.yaml`, `some-dir/document-1.yaml` are scheduled to destinations with
183+
- `document-0.yaml`, `some-dir/document-1.yaml` are scheduled to destinations with
184184
the `promise=label` label.
185-
* They are not contained within a directory associated with a specific scheduling, so
185+
- They are not contained within a directory associated with a specific scheduling, so
186186
revert to the [default scheduling](#default).
187187

188188
### Default scheduling {#default}
@@ -219,9 +219,11 @@ In the event of a label conflict, the Promise `spec.destinationSelectors` take p
219219
over any dynamic scheduling.
220220

221221
The order of precedence is as follows:
222+
222223
1. Promise `spec.destinationSelectors`
223224
2. Promise workflow `destination-selectors.yaml`
224225
3. Resource workflow `destination-selectors.yaml`
226+
225227
:::
226228

227229
:::important

docs/main/04-guides/04-scheduling.mdx docs/main/04-guides/04-new-destination.mdx

+31-23
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@ description: Guide on how to register a new Destination with Kratix
33
title: Adding a new Destination
44
---
55

6-
One of the most powerful features of Kratix is its ability to react when new Destinations are added to the platform. These Destinations can represent additional Kubernetes clusters, Kubernetes namespaces, or completely different infrastructure like a Terraform Cloud account or edge compute provider. By default, any Promise installed into Kratix will schedule it's Dependencies to new Destinations joining the platform.
6+
One of the most powerful features of Kratix is its ability to react when new
7+
Destinations are added to the platform. These Destinations can represent
8+
additional Kubernetes clusters, Kubernetes namespaces, or completely different
9+
infrastructure like a Terraform Cloud account or edge compute provider. By
10+
default, any Promise installed into Kratix will schedule it's Dependencies to
11+
new Destinations joining the platform.
712

813
## Prerequisites
914

10-
In this section, we will register a new Kubernetes cluster as a Destination with Kratix, and
11-
experience the Kratix multi-cluster capabilities. Before continuing, you will need a Platform
12-
Kubernetes cluster running Kratix, and a second worker Kubernetes cluster to
13-
register with the Platform. You also need at least one Promise installed on
14-
the Platform.
15+
In this section, we will register a new Kubernetes cluster as a Destination with
16+
Kratix, and experience the Kratix multi-cluster capabilities. Before continuing,
17+
you will need a Platform Kubernetes cluster running Kratix, and a second worker
18+
Kubernetes cluster to register with the Platform. You also need at least one
19+
Promise installed on the Platform.
1520

1621
For the context of this guide, we will assume the setup from [Installing Kratix
17-
with KinD](./installing-kratix-others) and that the following environment variables are
18-
set:
22+
with KinD](./installing-kratix-others) and that the following environment
23+
variables are set:
1924

2025
```bash
2126
export PLATFORM="kind-platform"
@@ -29,12 +34,12 @@ installed, if needed.
2934

3035
```shell-session
3136
$ kubectl --context $PLATFORM get destinations.platform.kratix.io
32-
NAME AGE
33-
worker-1 1h
37+
NAME READY
38+
worker-1 True
3439
3540
$ kubectl --context $PLATFORM get promises.platform.kratix.io
36-
NAME AGE
37-
jenkins-promise 1h
41+
NAME STATUS KIND API VERSION VERSION
42+
jenkins Available jenkins marketplace.kratix.io/v1alpha1
3843
```
3944

4045
On the worker, you should see the Jenkins Operator running:
@@ -49,8 +54,9 @@ If your setup is different, update the commands accordingly.
4954

5055
## Preparing the new cluster
5156

52-
You will now add the new cluster to the Platform as a Destination and watch Kratix reconcile the
53-
system. For that, you need to first create the new Kubernetes cluster:
57+
You will now add the new cluster to the Platform as a Destination and watch
58+
Kratix reconcile the system. For that, you need to first create the new
59+
Kubernetes cluster:
5460

5561
```bash
5662
kind create cluster --image kindest/node:v1.27.3 --name worker-2
@@ -70,8 +76,8 @@ cd /path/to/kratix
7076

7177
## Registering the Destination
7278

73-
You can now register your cluster with Kratix as a Destination. Create a file called `worker-2.yaml` with the
74-
following contents:
79+
You can now register your cluster with Kratix as a Destination. Create a file
80+
called `worker-2.yaml` with the following contents:
7581

7682
```yaml title="worker-2.yaml"
7783
apiVersion: platform.kratix.io/v1alpha1
@@ -97,9 +103,9 @@ Check the Destination was created:
97103

98104
```shell-session {4}
99105
$ kubectl --context $PLATFORM get destinations.platform.kratix.io
100-
NAME AGE
101-
worker-1 1h
102-
worker-2 1h
106+
NAME READY
107+
worker-1 True
108+
worker-2 True
103109
```
104110

105111
Kratix will react to the new Destination by scheduling the Jenkins Promise
@@ -112,14 +118,16 @@ NAME READY STATUS RESTARTS AGE
112118
jenkins-operator-778d6fc487-c9w8f 1/1 Running 0 1h
113119
```
114120

115-
When you request a new Jenkins, the Resources will be created in one of the available Destinations, by default this is selected in a non-deterministic way.
121+
When you request a new Jenkins, the Resources will be created in one of the
122+
available Destinations, by default this is selected in a non-deterministic way.
116123

117124
For further documentation on Destination scheduling, check the [Destination Reference
118125
documentation](../reference/destinations/intro).
119126

120-
:::info
121-
If you are specifically interested in making a Resource location deterministic, you can check out the [scheduling workloads](../reference/destinations/multidestination-management#resources) reference.
122-
:::
127+
:::info If you are specifically interested in making a Resource location
128+
deterministic, you can check out the [scheduling
129+
workloads](../reference/destinations/multidestination-management#resources)
130+
reference. :::
123131

124132
## 🎉 Congratulations
125133

0 commit comments

Comments
 (0)