Skip to content

Commit 57280ac

Browse files
david-yuclaudeJakeSCahill
authored
docs (k8s): Move inline YAML examples to feature files for schema and topic controllers (#1650)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: JakeSCahill <jake@redpanda.com> Co-authored-by: Jake Cahill <45230295+JakeSCahill@users.noreply.github.com>
1 parent 2c85927 commit 57280ac

5 files changed

Lines changed: 169 additions & 73 deletions

File tree

modules/manage/examples/kubernetes/schema-crds.feature

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,105 @@ Feature: Schema CRDs
104104
"""
105105
And schema "order-event" is successfully synced
106106
Then I should be able to check compatibility against "order-event" in cluster "basic"
107+
108+
@skip:gke @skip:aks @skip:eks
109+
Scenario: Manage fully compatible schema (Avro)
110+
Given there is no schema "fully-compatible-schema" in cluster "basic"
111+
When I apply Kubernetes manifest:
112+
"""
113+
# tag::full-compatibility-schema-manifest[]
114+
# This manifest creates an Avro schema named "fully-compatible-schema" in the "basic" cluster.
115+
# The schema uses Full compatibility, ensuring backward and forward compatibility across versions.
116+
---
117+
apiVersion: cluster.redpanda.com/v1alpha2
118+
kind: Schema
119+
metadata:
120+
name: fully-compatible-schema
121+
namespace: redpanda
122+
spec:
123+
cluster:
124+
clusterRef:
125+
name: basic
126+
schemaType: avro
127+
compatibilityLevel: Full
128+
text: |
129+
{
130+
"type": "record",
131+
"name": "ExampleRecord",
132+
"fields": [
133+
{ "type": "string", "name": "field1" },
134+
{ "type": "int", "name": "field2" }
135+
]
136+
}
137+
# end::full-compatibility-schema-manifest[]
138+
"""
139+
And schema "fully-compatible-schema" is successfully synced
140+
Then I should be able to check compatibility against "fully-compatible-schema" in cluster "basic"
141+
142+
@skip:gke @skip:aks @skip:eks
143+
Scenario: Manage product schema (Avro)
144+
Given there is no schema "product-schema" in cluster "basic"
145+
When I apply Kubernetes manifest:
146+
"""
147+
# This manifest creates an Avro schema named "product-schema" in the "basic" cluster.
148+
# This schema will be referenced by other schemas to demonstrate schema references.
149+
---
150+
apiVersion: cluster.redpanda.com/v1alpha2
151+
kind: Schema
152+
metadata:
153+
name: product-schema
154+
namespace: redpanda
155+
spec:
156+
cluster:
157+
clusterRef:
158+
name: basic
159+
schemaType: avro
160+
compatibilityLevel: Backward
161+
text: |
162+
{
163+
"type": "record",
164+
"name": "Product",
165+
"fields": [
166+
{ "type": "string", "name": "product_id" },
167+
{ "type": "string", "name": "name" }
168+
]
169+
}
170+
"""
171+
And schema "product-schema" is successfully synced
172+
Then I should be able to check compatibility against "product-schema" in cluster "basic"
173+
174+
@skip:gke @skip:aks @skip:eks
175+
Scenario: Manage order schema with references (Avro)
176+
Given there is a schema "product-schema" in cluster "basic"
177+
And there is no schema "order-schema" in cluster "basic"
178+
When I apply Kubernetes manifest:
179+
"""
180+
# tag::schema-references-manifest[]
181+
# This manifest creates an Avro schema named "order-schema" that references another schema.
182+
# Schema references enable modular and reusable schema components for complex data structures.
183+
---
184+
apiVersion: cluster.redpanda.com/v1alpha2
185+
kind: Schema
186+
metadata:
187+
name: order-schema
188+
namespace: redpanda
189+
spec:
190+
cluster:
191+
clusterRef:
192+
name: basic
193+
references:
194+
- name: product-schema
195+
subject: product
196+
version: 1
197+
text: |
198+
{
199+
"type": "record",
200+
"name": "Order",
201+
"fields": [
202+
{ "name": "product", "type": "Product" }
203+
]
204+
}
205+
# end::schema-references-manifest[]
206+
"""
207+
And schema "order-schema" is successfully synced
208+
Then I should be able to check compatibility against "order-schema" in cluster "basic"

modules/manage/examples/kubernetes/topic-crds.feature

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,55 @@ Feature: Topic CRDs
2525
"""
2626
And topic "topic1" is successfully synced
2727
Then I should be able to produce and consume from "topic1" in cluster "basic"
28+
29+
@skip:gke @skip:aks @skip:eks
30+
Scenario: Manage topic with write caching
31+
Given there is no topic "chat-room" in cluster "basic"
32+
When I apply Kubernetes manifest:
33+
"""
34+
# tag::write-caching-topic-example[]
35+
# This manifest creates a topic called "chat-room" with write caching enabled.
36+
# Write caching provides better performance at the expense of durability.
37+
---
38+
apiVersion: cluster.redpanda.com/v1alpha2
39+
kind: Topic
40+
metadata:
41+
name: chat-room
42+
spec:
43+
cluster:
44+
clusterRef:
45+
name: basic
46+
partitions: 3
47+
replicationFactor: 1
48+
additionalConfig:
49+
write.caching: "true"
50+
# end::write-caching-topic-example[]
51+
"""
52+
And topic "chat-room" is successfully synced
53+
Then I should be able to produce and consume from "chat-room" in cluster "basic"
54+
55+
@skip:gke @skip:aks @skip:eks
56+
Scenario: Manage topic with cleanup policy
57+
Given there is no topic "delete-policy-topic" in cluster "basic"
58+
When I apply Kubernetes manifest:
59+
"""
60+
# tag::cleanup-policy-topic-example[]
61+
# This manifest creates a topic with the cleanup policy set to "delete".
62+
# The cleanup policy determines how partition log files are managed when they reach a certain size.
63+
---
64+
apiVersion: cluster.redpanda.com/v1alpha2
65+
kind: Topic
66+
metadata:
67+
name: delete-policy-topic
68+
spec:
69+
cluster:
70+
clusterRef:
71+
name: basic
72+
partitions: 3
73+
replicationFactor: 1
74+
additionalConfig:
75+
cleanup.policy: "delete"
76+
# end::cleanup-policy-topic-example[]
77+
"""
78+
And topic "delete-policy-topic" is successfully synced
79+
Then I should be able to produce and consume from "delete-policy-topic" in cluster "basic"

modules/manage/pages/kubernetes/k-manage-topics.adoc

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ The Redpanda Operator automatically configures the Topic controller to connect t
119119

120120
The `clusterRef` method automatically discovers connection details from the referenced Redpanda resource:
121121

122+
.`topic.yaml`
122123
[,yaml]
123124
----
124125
apiVersion: cluster.redpanda.com/v1alpha2
@@ -138,6 +139,7 @@ spec:
138139

139140
The `staticConfiguration` method requires manually specifying all connection details:
140141

142+
.`topic.yaml`
141143
[,yaml]
142144
----
143145
apiVersion: cluster.redpanda.com/v1alpha2
@@ -220,6 +222,7 @@ In addition to the general prerequisites for managing topics, you must have the
220222

221223
To create an Iceberg topic, set the `redpanda.iceberg.mode` configuration in the `additionalConfig` property of the `Topic` resource.
222224

225+
.`iceberg-topic.yaml`
223226
[source,yaml]
224227
----
225228
apiVersion: cluster.redpanda.com/v1alpha2
@@ -326,21 +329,9 @@ With `write_caching` enabled at the cluster level, Redpanda fsyncs to disk accor
326329
To override the cluster-level setting at the topic level, set the topic-level property xref:reference:topic-properties.adoc#writecaching[`write.caching`]:
327330

328331
.`example-topic.yaml`
329-
[,yaml,lines=9]
332+
[,yaml,indent=0]
330333
----
331-
apiVersion: cluster.redpanda.com/v1alpha2
332-
kind: Topic
333-
metadata:
334-
name: chat-room
335-
namespace: <namespace>
336-
spec:
337-
cluster:
338-
clusterRef:
339-
name: <cluster-name>
340-
partitions: 3
341-
replicationFactor: 3
342-
additionalConfig:
343-
write.caching: true
334+
include::manage:example$kubernetes/topic-crds.feature[tags=write-caching-topic-example,indent=0]
344335
----
345336

346337
With `write.caching` enabled at the topic level, Redpanda fsyncs to disk according to xref:reference:topic-properties.adoc#flushms[`flush.ms`] and xref:reference:topic-properties.adoc#flushbytes[`flush.bytes`], whichever is reached first.
@@ -627,21 +618,9 @@ CAUTION: Do not use `rpk` or any other Kafka clients to edit topics that you cre
627618
The following example changes the cleanup policy for a topic:
628619

629620
.`example-topic.yaml`
630-
[,yaml,lines=8-9]
621+
[,yaml,indent=0]
631622
----
632-
apiVersion: cluster.redpanda.com/v1alpha2
633-
kind: Topic
634-
metadata:
635-
name: <topic-name>
636-
namespace: <namespace>
637-
spec:
638-
cluster:
639-
clusterRef:
640-
name: <cluster-name>
641-
partitions: 3
642-
replicationFactor: 3
643-
additionalConfig:
644-
cleanup.policy: "delete"
623+
include::manage:example$kubernetes/topic-crds.feature[tags=cleanup-policy-topic-example,indent=0]
645624
----
646625

647626
[,bash]

modules/manage/pages/kubernetes/k-schema-controller.adoc

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -172,28 +172,10 @@ Compatibility modes determine how schema versions within a subject can evolve wi
172172

173173
For example, to set full compatibility, configure the Schema resource with:
174174

175-
[source,yaml]
175+
.`schema.yaml`
176+
[,yaml,indent=0]
176177
----
177-
apiVersion: cluster.redpanda.com/v1alpha2
178-
kind: Schema
179-
metadata:
180-
name: fully-compatible-schema
181-
namespace: redpanda
182-
spec:
183-
cluster:
184-
clusterRef:
185-
name: basic
186-
schemaType: avro
187-
compatibilityLevel: Full
188-
text: |
189-
{
190-
"type": "record",
191-
"name": "ExampleRecord",
192-
"fields": [
193-
{ "type": "string", "name": "field1" },
194-
{ "type": "int", "name": "field2" }
195-
]
196-
}
178+
include::manage:example$kubernetes/schema-crds.feature[tags=full-compatibility-schema-manifest,indent=0]
197179
----
198180

199181
Compatibility settings are essential for maintaining data consistency, especially when updating schemas over time.
@@ -206,29 +188,10 @@ NOTE: This feature is supported for Avro and Protobuf schemas.
206188

207189
Define a schema reference using the `references` field. The reference includes the name, subject, and version of the referenced schema:
208190

209-
[source,yaml]
191+
.`schema.yaml`
192+
[,yaml,indent=0]
210193
----
211-
apiVersion: cluster.redpanda.com/v1alpha2
212-
kind: Schema
213-
metadata:
214-
name: order-schema
215-
namespace: redpanda
216-
spec:
217-
cluster:
218-
clusterRef:
219-
name: basic
220-
references:
221-
- name: product-schema
222-
subject: product
223-
version: 1
224-
text: |
225-
{
226-
"type": "record",
227-
"name": "Order",
228-
"fields": [
229-
{ "name": "product", "type": "Product" }
230-
]
231-
}
194+
include::manage:example$kubernetes/schema-crds.feature[tags=schema-references-manifest,indent=0]
232195
----
233196

234197
== Update a schema

modules/manage/pages/kubernetes/security/authentication/k-schema-registry-acls.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ In this example, a RedpandaRole called `read-only-role` is created in the cluste
5757

5858
The Group resource supports Schema Registry ACLs for OIDC groups.
5959

60+
In this example, ACLs are created for an OIDC group called `engineering` in the cluster called `sasl`. The authorization rules grant `Read` and `Describe` access to all topics with names starting with `team-` using a `prefixed` pattern type, and the same `Read` and `Describe` access to Schema Registry subjects matching the same prefix.
61+
6062
.`group-with-sr-acls.yaml`
6163
[,yaml,indent=0]
6264
----
6365
include::manage:example$kubernetes/group-crds.feature[tags=manage-group-acls,indent=0]
6466
----
6567

66-
In this example, ACLs are created for an OIDC group called `engineering` in the cluster called `sasl`. The authorization rules grant `Read` and `Describe` access to all topics with names starting with `team-` using a `prefixed` pattern type, and the same `Read` and `Describe` access to Schema Registry subjects matching the same prefix.
67-
6868
== Common use cases
6969

7070
The following examples show common patterns for configuring Schema Registry ACLs using the User resource.

0 commit comments

Comments
 (0)