Skip to content

Commit cc3d0cc

Browse files
authored
docs: new structure of docs (#2737)
1 parent 0dc0f6a commit cc3d0cc

File tree

27 files changed

+974
-1203
lines changed

27 files changed

+974
-1203
lines changed

docs/content/en/blog/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Blog
3-
menu: {main: {weight: 30}}
3+
menu: {main: {weight: 2}}
44
---
55

66
This is the **blog** section. It has two categories: News and Releases.

docs/content/en/blog/news/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Posts
3-
weight: 20
3+
weight: 220
44
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Releases
3-
weight: 20
3+
weight: 230
44
---

docs/content/en/community/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Community
3-
menu: {main: {weight: 40}}
3+
menu: {main: {weight: 3}}
44
---
55

66
<!--add blocks of content here to add more sections to the community page -->

docs/content/en/docs/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: Documentation
33
linkTitle: Docs
4-
menu: {main: {weight: 20}}
5-
weight: 20
4+
menu: {main: {weight: 1}}
5+
weight: 1
66
---
77

88

docs/content/en/docs/contributing/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Contributing To Java Operator SDK
3-
weight: 100
3+
weight: 110
44
---
55

66
First of all, we'd like to thank you for considering contributing to the project! We really
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Documentation
3+
weight: 40
4+
---

docs/content/en/docs/architecture/_index.md renamed to docs/content/en/docs/documentation/architecture.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
22
title: Architecture and Internals
3-
weight: 90
3+
weight: 85
44
---
55

6-
76
This document gives an overview of the internal structure and components of Java Operator SDK core,
87
in order to make it easier for developers to understand and contribute to it. This document is
98
not intended to be a comprehensive reference, rather an introduction to the core concepts and we

docs/content/en/docs/configuration/_index.md renamed to docs/content/en/docs/documentation/configuration.md

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
---
2-
title: Configuring JOSDK
3-
layout: docs
4-
permalink: /docs/configuration
2+
title: Configurations
3+
weight: 55
54
---
65

7-
# Configuration options
8-
96
The Java Operator SDK (JOSDK) provides several abstractions that work great out of the
107
box. However, while we strive to cover the most common cases with the default behavior, we also
118
recognize that that default behavior is not always what any given user might want for their
@@ -52,6 +49,68 @@ operator.register(reconciler, configOverrider ->
5249
configOverrider.withFinalizer("my-nifty-operator/finalizer").withLabelSelector("foo=bar"));
5350
```
5451

52+
## Dynamically Changing Target Namespaces
53+
54+
A controller can be configured to watch a specific set of namespaces in addition of the
55+
namespace in which it is currently deployed or the whole cluster. The framework supports
56+
dynamically changing the list of these namespaces while the operator is running.
57+
When a reconciler is registered, an instance of
58+
[`RegisteredController`](https://github.com/java-operator-sdk/java-operator-sdk/blob/ec37025a15046d8f409c77616110024bf32c3416/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/RegisteredController.java#L5)
59+
is returned, providing access to the methods allowing users to change watched namespaces as the
60+
operator is running.
61+
62+
A typical scenario would probably involve extracting the list of target namespaces from a
63+
`ConfigMap` or some other input but this part is out of the scope of the framework since this is
64+
use-case specific. For example, reacting to changes to a `ConfigMap` would probably involve
65+
registering an associated `Informer` and then calling the `changeNamespaces` method on
66+
`RegisteredController`.
67+
68+
```java
69+
70+
public static void main(String[] args) {
71+
KubernetesClient client = new DefaultKubernetesClient();
72+
Operator operator = new Operator(client);
73+
RegisteredController registeredController = operator.register(new WebPageReconciler(client));
74+
operator.installShutdownHook();
75+
operator.start();
76+
77+
// call registeredController further while operator is running
78+
}
79+
80+
```
81+
82+
If watched namespaces change for a controller, it might be desirable to propagate these changes to
83+
`InformerEventSources` associated with the controller. In order to express this,
84+
`InformerEventSource` implementations interested in following such changes need to be
85+
configured appropriately so that the `followControllerNamespaceChanges` method returns `true`:
86+
87+
```java
88+
89+
@ControllerConfiguration
90+
public class MyReconciler implements Reconciler<TestCustomResource> {
91+
92+
@Override
93+
public Map<String, EventSource> prepareEventSources(
94+
EventSourceContext<ChangeNamespaceTestCustomResource> context) {
95+
96+
InformerEventSource<ConfigMap, TestCustomResource> configMapES =
97+
new InformerEventSource<>(InformerEventSourceConfiguration.from(ConfigMap.class, TestCustomResource.class)
98+
.withNamespacesInheritedFromController(context)
99+
.build(), context);
100+
101+
return EventSourceUtils.nameEventSources(configMapES);
102+
}
103+
104+
}
105+
```
106+
107+
As seen in the above code snippet, the informer will have the initial namespaces inherited from
108+
controller, but also will adjust the target namespaces if it changes for the controller.
109+
110+
See also
111+
the [integration test](https://github.com/operator-framework/java-operator-sdk/tree/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/changenamespace)
112+
for this feature.
113+
55114
## DependentResource-level configuration
56115

57116
`DependentResource` implementations can implement the `DependentResourceConfigurator` interface
@@ -61,7 +120,7 @@ provides specific support for the `KubernetesDependentResource`, which can be co
61120
`KubernetesDependentResourceConfig` instance, which is then passed to the `configureWith` method
62121
implementation.
63122

64-
TODO: still subject to change / uniformization
123+
TODO
65124

66125
## EventSource-level configuration
67126

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Dependent resources and workflows
3+
weight: 70
4+
---
5+
6+
Dependent resources and workflows are features sometimes referenced as higher
7+
level abstractions. These two related concepts provides an abstraction
8+
over reconciliation of a single resource (Dependent resource) and the
9+
orchestration of such resources (Workflows).

0 commit comments

Comments
 (0)