Skip to content

Commit 7183131

Browse files
committed
added getting started guides for choreo
1 parent ef4fd9b commit 7183131

File tree

7 files changed

+348
-24
lines changed

7 files changed

+348
-24
lines changed

docs/01-getting-started/01_install.md

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# Getting Started
2+
3+
First check the [prerequisites](./02_prereq.md).
4+
5+
## Setup environment
6+
7+
This exercise will walk through a basic Hello world example. The API is already generated
8+
9+
This exercise will walk through a basic Hello world example. The API is already generated
10+
11+
clone the choreo-examples git repo
12+
13+
```bash
14+
git clone https://github.com/kform-dev/choreo-examples
15+
```
16+
17+
Best to use 2 windows, one for the choreo server and one for the choreo client, since the choreo server will serve the system
18+
19+
## choreo server
20+
21+
start the choreoserver
22+
23+
```
24+
choreoctl server start choreo-examples/hello-world/
25+
```
26+
27+
The choreoserver support a version controlled backend but we dont explore this in this exercise.
28+
29+
```json
30+
{"time":"2024-09-30T19:26:06.771564+02:00","level":"INFO","message":"server started","logger":"choreoctl-logger","data":{"name":"choreoServer","address":"127.0.0.1:51000"}}
31+
branchstore update main oldstate <nil> -> newstate CheckedOut
32+
```
33+
34+
## choreo client
35+
36+
With the following command we can explore the api(s) supported by the system. We see the helloworlds api being present, which got loaded when we started the server
37+
38+
```bash
39+
choreoctl api-resources
40+
```
41+
42+
```bash
43+
&{upstreamrefs choreo.kform.dev v1alpha1 UpstreamRef false [pkg knet]}
44+
&{libraries choreo.kform.dev v1alpha1 Library false [choreo]}
45+
&{apiresources choreo.kform.dev v1alpha1 APIResources true []}
46+
&{configgenerators choreo.kform.dev v1alpha1 ConfigGenerator false [pkg knet]}
47+
&{customresourcedefinitions apiextensions.k8s.io v1 CustomResourceDefinition false []}
48+
&{reconcilers choreo.kform.dev v1alpha1 Reconciler false [choreo]}
49+
&{helloworlds example.com v1alpha1 HelloWorld HelloWorldList true []}
50+
```
51+
52+
When executing the following command no result should be shown, since no hello world resources are loaded
53+
54+
```
55+
choreoctl get customresourcedefinitions.apiextensions.k8s.io
56+
```
57+
58+
Autocompletion should work, maybe try TAB completion iso copying the full command
59+
60+
Now run the reconciler
61+
62+
```
63+
choreoctl run once
64+
```
65+
66+
you should see the reconciler `example.com.helloworlds.helloworld` being executed.
67+
68+
```
69+
execution success, time(sec) 0.0031725
70+
Reconciler Start Stop Requeue Error
71+
example.com.helloworlds.helloworld 2 2 0 0
72+
```
73+
74+
What just happened?
75+
76+
a. the reconciler got loaded
77+
78+
/// details | HelloWorld Reconciler
79+
80+
```yaml
81+
--8<--
82+
https://raw.githubusercontent.com/kform-dev/choreo-examples/main/hello-world/reconcilers/example.com.helloworlds.helloworld.star
83+
--8<--
84+
```
85+
86+
///
87+
88+
b. The reconciler registered to be informed on any HelloWorld resource change
89+
90+
```yaml
91+
group: example.com
92+
version: v1alpha1
93+
kind: HelloWorld
94+
```
95+
96+
/// details | HelloWorld Reconciler Hook
97+
98+
```yaml
99+
--8<--
100+
https://raw.githubusercontent.com/kform-dev/choreo-examples/main/hello-world/reconcilers/example.com.helloworlds.helloworld.yaml
101+
--8<--
102+
```
103+
104+
///
105+
106+
c. The reconciler business logic got triggered by adding this HelloWorld manifest
107+
108+
/// details | Hello World manifest
109+
110+
```yaml
111+
--8<--
112+
https://raw.githubusercontent.com/kform-dev/choreo-examples/main/hello-world/in/example.com.helloworlds.test.yaml
113+
--8<--
114+
```
115+
116+
///
117+
118+
let's see if it performed its job, by looking at the details of the HelloWorld manifest
119+
120+
```
121+
choreoctl get helloworlds.example.com test -o yaml
122+
```
123+
124+
We should see spec.greeting being changed to `hello choreo`
125+
126+
```yaml
127+
apiVersion: example.com/v1alpha1
128+
kind: HelloWorld
129+
metadata:
130+
annotations:
131+
api.choreo.kform.dev/origin: '{"kind":"File"}'
132+
creationTimestamp: "2024-09-30T17:49:34Z"
133+
generation: 1
134+
name: test
135+
namespace: default
136+
resourceVersion: "1"
137+
uid: deedbf64-b348-477e-9fbb-d2738ab4f3b0
138+
spec:
139+
greeting: hello choreo
140+
status:
141+
conditions:
142+
- lastTransitionTime: "2024-09-30T17:49:34Z"
143+
message: ""
144+
reason: Ready
145+
status: "True"
146+
type: Ready
147+
```
148+
149+
🎉 You ran you first choreo reconciler. 🤘
150+
151+
Did you notice none of this required a kubernetes cluster?
152+
Choreo applies the kubernetes principles w/o imposing all the kubernetes container orchestration primitives.
153+
154+
Try changing the business logic from `Hello Choreo` to `hello <your name>` and execute the business logic again
155+
156+
```python
157+
def reconcile(helloworld):
158+
spec = helloworld.get("spec", {})
159+
spec["greeting"] = "hello wim"
160+
helloworld['spec'] = spec
161+
return reconcile_result(helloworld, False, 0, conditionType, "", False)
162+
```
163+
164+
This should result in the following outcome if we run the business logic again.
165+
166+
```
167+
choreoctl run once
168+
```
169+
170+
```yaml
171+
apiVersion: example.com/v1alpha1
172+
kind: HelloWorld
173+
metadata:
174+
annotations:
175+
api.choreo.kform.dev/origin: '{"kind":"File"}'
176+
creationTimestamp: "2024-09-30T17:49:34Z"
177+
generation: 1
178+
name: test
179+
namespace: default
180+
resourceVersion: "1"
181+
uid: deedbf64-b348-477e-9fbb-d2738ab4f3b0
182+
spec:
183+
greeting: hello wim
184+
status:
185+
conditions:
186+
- lastTransitionTime: "2024-09-30T17:49:34Z"
187+
message: ""
188+
reason: Ready
189+
status: "True"
190+
type: Ready
191+
```
192+
193+
You can also introduce an error and see what happens; e.g. change `greeting` to `greetings` which is an invalid json key in the schema.
194+
195+
```python
196+
def reconcile(helloworld):
197+
spec = helloworld.get("spec", {})
198+
spec["greetings"] = "hello wim"
199+
helloworld['spec'] = spec
200+
return reconcile_result(helloworld, False, 0, conditionType, "", False)
201+
```
202+
203+
when executing
204+
205+
```
206+
choreoctl run once
207+
```
208+
209+
the following result is obtained, indicating the schema error
210+
211+
```bash
212+
execution failed example.com.helloworlds.helloworld.HelloWorld.example.com.test rpc error: code = InvalidArgument desc = fieldmanager apply failed err: failed to create typed patch object (default/test; example.com/v1alpha1, Kind=HelloWorld): .spec.greetings: field not declared in schema
213+
```
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Prerequisites
2+
3+
## CPU architecture
4+
5+
All the choreo components run on both AMD and ARM based CPU
6+
7+
## Operating system
8+
9+
We tested on WSL for windows and Linux and darwin OS.
10+
11+
## choreoctl
12+
13+
Choreoctl is a command line tool for communicating with a Choreo server.
14+
15+
choreoctl is a single binary built for linux and Mac OS, distributed via [ghreleases][ghreleases]. It
16+
17+
18+
/// tab | linux/Mac OS
19+
20+
To download & install the latest release the following automated [installation script][installscript] can be used.
21+
22+
```bash
23+
bash -c "$(curl -sL https://github.com/kform-dev/choreo/raw/main/install-choreoctl.sh)"
24+
```
25+
26+
As a result, the latest `choreoctl` version will be installed in the /usr/local/bin directory and the version information will be printed out.
27+
28+
To install a specific version of `choreoctl`, provide the version with -v flag to the installation script:
29+
30+
```bash
31+
bash -c "$(curl -sL https://github.com/kform-dev/choreo/raw/main/install-choreoctl.sh)" -- -v 0.0.1
32+
```
33+
34+
///
35+
36+
/// tab | Packages
37+
38+
Linux users running distributions with support for deb/rpm packages can install choreoctl using pre-built packages:
39+
40+
```bash
41+
bash -c "$(curl -sL https://github.com/kform-dev/choreo/raw/main/install-choreoctl.sh)" -- --use-pkg
42+
```
43+
44+
///
45+
46+
47+
## choreoctl autocomplete
48+
49+
50+
/// tab | bash
51+
52+
```bash
53+
source <(choreoctl completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed first.
54+
echo "source <(choreoctl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
55+
```
56+
57+
///
58+
59+
/// tab | zsh
60+
61+
```zsh
62+
source <(choreoctl completion zsh) # set up autocomplete in zsh into the current shell
63+
echo '[[ $commands[choreoctl] ]] && source <(choreoctl completion zsh)' >> ~/.zshrc # add autocomplete permanently to your zsh shell
64+
```
65+
66+
///
67+
68+
[ghreleases]: https://github.com/kform-dev/choreo/releases
69+
[installscript]: https://github.com/kform-dev/choreo/raw/main/install-choreoctl.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Getting Started
2+
3+
First check the [prerequisites](./02_prereq.md).
4+
5+
## Setup environment
6+
7+
see [kform-examples][kform-examples]
8+
9+
[kform-examples]: https://github.com/kform-dev/kform-examples
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Prerequisites
2+
3+
## CPU architecture
4+
5+
kform runs on both AMD and ARM based CPU
6+
7+
## Operating system
8+
9+
We tested on WSL for windows and Linux and darwin OS.
10+
11+
## kform
12+
13+
kform is a command line tool for executing kform plans/packages.
14+
15+
kform is a single binary built for linux and Mac OS, distributed via [ghreleases][ghreleases]. It
16+
17+
18+
/// tab | linux/Mac OS
19+
20+
To download & install the latest release the following automated [installation script][installscript] can be used.
21+
22+
```bash
23+
bash -c "$(curl -sL https://github.com/kform-dev/kform/raw/main/install.sh)"
24+
```
25+
26+
As a result, the latest `kform` version will be installed in the /usr/local/bin directory and the version information will be printed out.
27+
28+
To install a specific version of `kform`, provide the version with -v flag to the installation script:
29+
30+
```bash
31+
bash -c "$(curl -sL https://github.com/kform-dev/kform/raw/main/install.sh)" -- -v 0.0.1
32+
```
33+
34+
///
35+
36+
/// tab | Packages
37+
38+
Linux users running distributions with support for deb/rpm packages can install kform using pre-built packages:
39+
40+
```bash
41+
bash -c "$(curl -sL https://github.com/kform-dev/kform/raw/main/install.sh)" -- --use-pkg
42+
```
43+
44+
///
45+
46+
47+
48+
[ghreleases]: https://github.com/kform-dev/kform/releases
49+
[installscript]: https://github.com/kform-dev/kform/raw/main/install.sh

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs.kform-dev.dev

mkdocs.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
site_name: kform
22
nav:
33
- Home: index.md
4-
- Getting Started: 01-getting-started/01_install.md
4+
- Getting Started:
5+
- Choreo:
6+
- Getting started: 01-getting-started/choreo/01_getting_started.md
7+
- Prerequisites: 01-getting-started/choreo/02_prereq.md
8+
- Kform:
9+
- Getting started: 01-getting-started/kform/01_getting_started.md
10+
- Prerequisites: 01-getting-started/kform/02_prereq.md
511
- Kform Language:
612
- About: 02-language/01_about.md
713
- Files & Directories: 02-language/02_files_dirs.md

0 commit comments

Comments
 (0)