Skip to content

Commit 5e40e85

Browse files
authored
docs: add finalized documentation to ghpages
1 parent d91d8e3 commit 5e40e85

File tree

11 files changed

+351
-31
lines changed

11 files changed

+351
-31
lines changed

.github/workflows/github-pages.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ jobs:
1919
uses: crazy-max/ghaction-chocolatey@v1
2020
with:
2121
args: install docfx -y
22-
- name: Restore Solution
23-
run: dotnet restore
2422
- name: Build Solution
25-
run: dotnet build
23+
run: .\build.ps1 --target Compile --no-logo
24+
shell: powershell
2625
- name: Build Documentation
2726
run: docfx docs/docfx.json
2827
- name: Upload docs artifact
@@ -34,6 +33,7 @@ jobs:
3433
runs-on: ubuntu-latest
3534
needs: build-gh-pages
3635
steps:
36+
- uses: actions/checkout@v2
3737
- name: Download docs artifact
3838
id: download
3939
uses: actions/download-artifact@v2
@@ -45,4 +45,4 @@ jobs:
4545
with:
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4747
BRANCH: gh-pages
48-
FOLDER: ${{ steps.download.outputs.download-path }}
48+
FOLDER: public

docs/docs/commands.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
1-
TODO
1+
# Commands
22

3-
## Commands
3+
For convenience, there are multiple commands added to the executable
4+
of your operator (through the KubeOps package).
45

5-
There are default command line commands which you can see when using
6+
Those are implemented with the [CommandLineUtils by NateMcMaster](https://github.com/natemcmaster/CommandLineUtils).
7+
8+
you can see the help and overview when using
69
`dotnet run -- --help` in your project. As you can see, you can run
710
multiple commands. Some of them do install / uninstall your crds in
811
your currently selected kubernetes cluster or can generate code.
912

13+
> [!NOTE]
14+
> For the normal "dotnet run" command exists a `--namespaced`
15+
> option that starts the operator in namespaced mode. This means
16+
> that only the given namespace is watched for entities.
17+
18+
## Available Commands
19+
20+
Here is a brief overview over the available commands:
21+
22+
> [!NOTE]
23+
> all commands assume either the compiled dll or you using
24+
> `dotnet run -- ` as prepended command.
25+
26+
- ` ` (empty): runs the operator (normal `dotnet run`)
27+
- `version`: prints the version information for the actual connected kubernetes cluster
28+
- `install`: install the CRDs for the solution into the cluster
29+
- `uninstall`: uninstall the CRDs for the solution from the cluster
30+
- `generator`: entry command for generator commands (i.e. has subcommands), all commands
31+
output their result to the stdout or the given output path
32+
- `crd`: Generate the CRDs
33+
- `docker`: Generate the dockerfile
34+
- `installer`: Generate the installer files (i.e. kustomization yaml) for the operator
35+
- `operator`: Generate the deployment for the operator
36+
- `rbac`: Generate the needed rbac roles / role bindings for the operator
37+
1038
## Code Generation
1139

1240
When installing this package, you also reference the default Targets and Props
@@ -22,3 +50,6 @@ The dockerfile will not be overwritten in case you have custom elements in there
2250
The installation files won't be overwritten as well if you have custom elements in there.
2351

2452
To regenerate those two elements, just delete them and rebuild your code.
53+
54+
For the customization on those build targets, header over to the
55+
[ms build extensions](./ms_build.md).

docs/docs/controller.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ resources on kubernetes and queueing of the events.
77
When you want to create a controller for your (or any) entity,
88
read the following instructions.
99

10+
When you have controllers, don't forget to register them with
11+
<xref:KubeOps.Operator.Builder.IOperatorBuilder.AddController``1>
12+
to the DI system.
13+
1014
## Controller instance
1115

1216
After you created a custom entity (like described in [Entities](./entities.md))
1317
or you want to reconcile a given entity (from the `k8s.Models` namespace,
1418
e.g. `V1ConfigMap`) you need to create a controller class
1519
as you would do for a MVC or API controller in asp.net.
1620

17-
Make sure you have the correct baseclass (`ResourceControllerBase<TEntity>`)
21+
Make sure you have the correct baseclass
22+
(<xref:KubeOps.Operator.Controller.ResourceControllerBase`1>)
1823
inherited.
1924

2025
```csharp
@@ -32,6 +37,17 @@ public class FooCtrl: ResourceControllerBase<MyCustomEntity>
3237
}
3338
```
3439

40+
## Namespaced controller
41+
42+
To limit the operator (and therefore all controllers) to a specific
43+
namespace in kubernetes, use the @"KubeOps.Operator.OperatorSettings"
44+
and configure a specific namespace when it is predefined.
45+
46+
To use namespacing dynamically, run the application with the `--namespaced`
47+
option. When given a name (i.e. `--namespaced=foobar`) the defined
48+
namespace is used. When only the option is provided (i.e. `--namespaced`)
49+
then the actual namespace is used that the pod runs in.
50+
3551
## RBAC
3652

3753
The entity rbac attribute does provide the information needed about

docs/docs/entities.md

Lines changed: 115 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ You can use the various validator attributes to customize your crd:
8484
- `Required`: The field is listed in the required fields
8585
- `PreserveUnknownFields`: Set the `X-Kubernetes-Preserve-Unknown-Fields` to `true`
8686

87-
_NOTE on `Description`_: if your project generates the XML documentation files
88-
for the result, the crd generator also searches for those files and a possible
89-
`<summary>` tag in the xml documentation. The attribute will take precedence though.
87+
> [!NOTE]
88+
> For `Description`: if your project generates the XML documentation files
89+
> for the result, the crd generator also searches for those files and a possible
90+
> `<summary>` tag in the xml documentation. The attribute will take precedence though.
9091
9192
```csharp
9293
public class MappingSpec
@@ -101,4 +102,114 @@ In the example above, the text of the attribute will be used.
101102

102103
## Multi-Version Entities
103104

104-
TODO
105+
You can manage multiple versions of a CRD. To do this, you can
106+
specify multiple classes as the "same" entity, but with different
107+
versions.
108+
109+
To mark multiple entity classes as the same, use exactly the same
110+
`Kind`, `Group` and `PluralName` and differ in the `ApiVersion`
111+
field.
112+
113+
### Version priority
114+
115+
Sorting of the versions - and therefore determine which version should be
116+
the `storage version` if no attribute is provided - is done by the kubernetes
117+
rules of version sorting:
118+
119+
Priority is as follows:
120+
121+
1. General Availablility (i.e. `V1Foobar`, `V2Foobar`)
122+
2. Beta Versions (i.e. `V11Beta13Foobar`, `V2Beta1Foobar`)
123+
3. Alpha Versions (i.e. `V16Alpha13Foobar`, `V2Alpha10Foobar`)
124+
125+
The parsed version numbers are sorted by the highest first, this leads
126+
to the following version priority:
127+
128+
```
129+
- v10
130+
- v2
131+
- v1
132+
- v11beta2
133+
- v10beta3
134+
- v3beta1
135+
- v12alpha1
136+
- v11alpha2
137+
```
138+
139+
This can also be seen over at the
140+
[kubernetes documentation](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#version-priority).
141+
142+
### Storage Version
143+
144+
To determine the storage version (of which one, and exactly one must exist)
145+
the system uses the previously mentioned version priority to sort the versions
146+
and picking the first one. To overwrite this behaviour, use the
147+
<xref:KubeOps.Operator.Entities.Annotations.StorageVersionAttribute>.
148+
149+
> [!WARNING]
150+
> when multiple <xref:KubeOps.Operator.Entities.Annotations.StorageVersionAttribute>
151+
> are used, the system will thrown an error.
152+
153+
To overwrite a version, annotate the entity class with the attribute.
154+
155+
### Example
156+
157+
#### Normal multiversion entity
158+
159+
Note that the `Kind`
160+
161+
```csharp
162+
[KubernetesEntity(
163+
ApiVersion = "v1",
164+
Kind = "VersionedEntity",
165+
Group = "kubeops.test.dev",
166+
PluralName = "versionedentities")]
167+
public class V1VersionedEntity : CustomKubernetesEntity
168+
{
169+
}
170+
171+
[KubernetesEntity(
172+
ApiVersion = "v1beta1",
173+
Kind = "VersionedEntity",
174+
Group = "kubeops.test.dev",
175+
PluralName = "versionedentities")]
176+
public class V1Beta1VersionedEntity : CustomKubernetesEntity
177+
{
178+
}
179+
180+
[KubernetesEntity(
181+
ApiVersion = "v1alpha1",
182+
Kind = "VersionedEntity",
183+
Group = "kubeops.test.dev",
184+
PluralName = "versionedentities")]
185+
public class V1Alpha1VersionedEntity : CustomKubernetesEntity
186+
{
187+
}
188+
```
189+
190+
The resulting storage version would be `V1VersionedEntity`.
191+
192+
#### Overwritten storage version multiversion entity
193+
194+
```csharp
195+
[KubernetesEntity(
196+
ApiVersion = "v1",
197+
Kind = "AttributeVersionedEntity",
198+
Group = "kubeops.test.dev",
199+
PluralName = "attributeversionedentities")]
200+
[StorageVersion]
201+
public class V1AttributeVersionedEntity : CustomKubernetesEntity
202+
{
203+
}
204+
205+
[KubernetesEntity(
206+
ApiVersion = "v2",
207+
Kind = "AttributeVersionedEntity",
208+
Group = "kubeops.test.dev",
209+
PluralName = "attributeversionedentities")]
210+
public class V2AttributeVersionedEntity : CustomKubernetesEntity
211+
{
212+
}
213+
```
214+
215+
The resulting storage version would be `V1AttributeVersionedEntity`.

docs/docs/features.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ at the sections.
55

66
As of now, the operator sdk supports - roughly - the following features:
77

8+
- Entities
9+
- Normal entities
10+
- Multi version entities
811
- Controller with all operations of an entity
912
- Created
1013
- Updated

docs/docs/finalizer.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
TODO
1+
# Finalizers
22

3-
### Write Finalizers
3+
A finalizer is a special type of software that can asynchronously
4+
cleanup stuff for an entity that is beeing deleted.
5+
6+
A finalizer is registered as an identifier in the kubernetes
7+
resource (i.e. in the yaml / json structure) and an object
8+
wont be removed from the api until all finalizers are removed.
9+
10+
If you write finalizer, don't forget to register them with
11+
<xref:KubeOps.Operator.Builder.IOperatorBuilder.AddFinalizer``1>
12+
to the DI system.
13+
14+
## Write a finalizer
15+
16+
Use the correct base class (<xref:KubeOps.Operator.Finalizer.ResourceFinalizerBase`1>).
417

518
A finalizer can be as simple as:
619

@@ -10,16 +23,28 @@ public class FooFinalizer : ResourceFinalizerBase<Foo>
1023
public override async Task Finalize(Foo resource)
1124
{
1225
// do something with the resource.
26+
// like deleting a database.
1327
}
1428
}
1529
```
1630

17-
And can be added to a resource with:
31+
When the finalizer successfully completed his job, it is automatically removed
32+
from the finalizers list of the resource. The finalizers are registered
33+
as transient resources in DI.
34+
35+
## Register a finalizer
36+
37+
To attach a finalizer for a resource, call the
38+
<xref:KubeOps.Operator.Controller.ResourceControllerBase`1.AttachFinalizer``1(`0)>
39+
method in the controller during reconciliation.
1840

1941
```csharp
20-
// in a resource controller
21-
await AttachFinalizer<TestEntityFinalizer>(resource);
42+
public class TestController : ResourceControllerBase<V1TestEntity>
43+
{
44+
protected override async Task<TimeSpan?> Created(V1TestEntity resource)
45+
{
46+
await AttachFinalizer<TestEntityFinalizer>(resource);
47+
return await base.Created(resource);
48+
}
49+
}
2250
```
23-
24-
After the finalizer ran successfully on a resource, it is unregistered
25-
on the resource.

docs/docs/getting_started.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ public static class Program
6262
This adds the default commands (like run and the code generators) to your app.
6363
The commands are documentated under the [CLI Commands](./commands.md) section.
6464

65-
_NOTE_: Technically you don't need to replace the function,
66-
but if you don't, the other commands like yaml generation
67-
are not available to your application. Also namespaceing is not
68-
possible via run flag.
65+
> [!NOTE]
66+
> Technically you don't need to replace the function,
67+
> but if you don't, the other commands like yaml generation
68+
> are not available to your application. Also namespaceing is not
69+
> possible via run flag.
6970
7071
### Add to Startup.cs
7172

docs/docs/ms_build.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
TODO
1+
# MS Build extensions
2+
3+
This project extends the default build process of dotnet with some
4+
code generation targets before the build.
5+
6+
You'll find those two files here:
7+
8+
- [KubeOps.props](https://github.com/buehler/dotnet-operator-sdk/blob/master/src/KubeOps/Build/KubeOps.props): defines the build properties
9+
- [KubeOps.targets](https://github.com/buehler/dotnet-operator-sdk/blob/master/src/KubeOps/Build/KubeOps.targets): defines the additional build targets
10+
11+
They can be configured with the prop settings described below.
12+
The props file just defines the defaults.
213

314
## Prop Settings
415

docs/docs/settings.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
TODO
1+
# Settings
2+
3+
To configure the operator, use the @"KubeOps.Operator.OperatorSettings"
4+
that are configurable during the generic host extension method
5+
@"KubeOps.Operator.ServiceCollectionExtensions.AddKubernetesOperator(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{KubeOps.Operator.OperatorSettings})"
6+
or @"KubeOps.Operator.ServiceCollectionExtensions.AddKubernetesOperator(Microsoft.Extensions.DependencyInjection.IServiceCollection,KubeOps.Operator.OperatorSettings)".
7+
8+
You can configure things like the name of the operator,
9+
if it should use namespacing, and other elements like the
10+
urls of metrics and lease durations for the leader election.
11+
12+
Please look at the documention over at: @"KubeOps.Operator.OperatorSettings"
13+
to know what the fields mean.

0 commit comments

Comments
 (0)