Skip to content

Commit ffdbfad

Browse files
chrissetoRafalKorepta
authored andcommitted
v2: update CRD docs and doc generation
This commit transplants the documentation for the recent redpanda helm chart update to their relevant place in the Redpanda CRD. In addition, it adds a configuration for crd-doc-ref to allow developers to review how documentation changes will be presented in our public docs ahead of merging. This commit also proactively changes instances of markdown URLs to asciidoc compatible links and adds a linter to prevent regressions.
1 parent 4911bfb commit ffdbfad

File tree

13 files changed

+3444
-16
lines changed

13 files changed

+3444
-16
lines changed

.changes/unreleased/chart-redpanda-Added-20250108-153147.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ body: |
1313
1414
```yaml
1515
resources:
16-
limits: {} # Specified but no cpu or memory values provided
17-
requests:
18-
cpu: 5 # Only CPU requests
16+
limits: {} # Specified but no cpu or memory values provided
17+
requests:
18+
cpu: 5 # Only CPU requests
1919
```
2020
2121
For more details see [redpanda's values.yaml](./charts/redpanda/values.yaml).
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
project: operator
2+
kind: Added
3+
body: |
4+
Added `resources.limits` and `resources.requests` as an alternative method of managing the redpanda container's resources.
5+
6+
When both `resources.limits` and `resources.requests` are specified, the
7+
redpanda container's `resources` will be set to the provided values and all
8+
other keys of `resources` will be ignored. Instead, all other values will be
9+
inferred from the limits and requests.
10+
11+
This allows fine grain control of resources. i.e. It is now possible to set
12+
CPU requests without setting limits:
13+
14+
```yaml
15+
resources:
16+
limits: {} # Specified but no cpu or memory values provided
17+
requests:
18+
cpu: 5 # Only CPU requests
19+
```
20+
time: 2025-01-15T16:21:58.898733-05:00

charts/redpanda/CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
1919

2020
```yaml
2121
resources:
22-
limits: {} # Specified but no cpu or memory values provided
23-
requests:
24-
cpu: 5 # Only CPU requests
22+
limits: {} # Specified but no cpu or memory values provided
23+
requests:
24+
cpu: 5 # Only CPU requests
2525
```
2626
2727
For more details see [redpanda's values.yaml](./charts/redpanda/values.yaml).

ci/crd-ref-docs.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{ buildGoModule
2+
, fetchFromGitHub
3+
, lib
4+
}:
5+
6+
buildGoModule rec {
7+
pname = "crd-ref-docs";
8+
version = "0.1.0";
9+
10+
# Don't run tests.
11+
doCheck = false;
12+
doInstallCheck = false;
13+
14+
src = fetchFromGitHub {
15+
owner = "elastic";
16+
repo = pname;
17+
rev = "v${version}";
18+
hash = "sha256-Vp4HrT6Fj+stj2xasyz7i+UuogsFHeHOT8Ro0HeoGpI=";
19+
};
20+
21+
subPackages = [
22+
"."
23+
"./config"
24+
];
25+
26+
vendorHash = "sha256-kNynNSa7xi5BL2oWBq7A2SWtjm1E+CyJd5f0FXkHAII=";
27+
28+
meta = with lib; {
29+
description = "Generates Kubernetes CRD API reference documentation";
30+
homepage = "https://github.com/elastic/crd-ref-docs";
31+
license = licenses.asl20;
32+
mainProgram = "crd-ref-docs";
33+
};
34+
}

ci/overlay.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{ pkgs
22
}: (final: prev: {
33
applyconfiguration-gen = pkgs.callPackage ./applyconfiguration-gen.nix { };
4+
chart-testing = pkgs.callPackage ./chart-testing.nix { };
45
controller-gen = pkgs.callPackage ./controller-gen.nix { };
6+
crd-ref-docs = pkgs.callPackage ./crd-ref-docs.nix { };
57
docker-tag-list = pkgs.callPackage ./docker-tag-list.nix { };
8+
helm-3-10-3 = pkgs.callPackage ./helm.nix { };
69
kuttl = pkgs.callPackage ./kuttl.nix { };
710
setup-envtest = pkgs.callPackage ./setup-envtest.nix { };
8-
helm-3-10-3 = pkgs.callPackage ./helm.nix { };
9-
chart-testing = pkgs.callPackage ./chart-testing.nix { };
1011
})

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
pkgs.changie # Changelog manager
4949
pkgs.chart-testing
5050
pkgs.controller-gen
51+
pkgs.crd-ref-docs # Generates documentation from CRD definitions. Used by our docs but present here to let us control and test the config.yaml
5152
pkgs.diffutils # Provides `diff`, used by golangci-lint.
5253
pkgs.docker-client
5354
pkgs.docker-tag-list

operator/CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
1616
* Console
1717
* Connectors
1818

19+
* Added `resources.limits` and `resources.requests` as an alternative method of managing the redpanda container's resources.
20+
21+
When both `resources.limits` and `resources.requests` are specified, the
22+
redpanda container's `resources` will be set to the provided values and all
23+
other keys of `resources` will be ignored. Instead, all other values will be
24+
inferred from the limits and requests.
25+
26+
This allows fine grain control of resources. i.e. It is now possible to set
27+
CPU requests without setting limits:
28+
29+
```yaml
30+
resources:
31+
limits: {} # Specified but no cpu or memory values provided
32+
requests:
33+
cpu: 5 # Only CPU requests
34+
```
35+
1936
### Changed
2037
* For any user that is mirroring configurator image (air-gapped environment) and changes entrypoint
2138
or wraps configurator with additional script the following constraint need to be meet:

operator/api/redpanda/v1alpha2/redpanda_clusterspec_types.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,27 @@ type UsageStats struct {
497497
ClusterID *string `json:"clusterId,omitempty"`
498498
}
499499

500-
// Resources configures resource allocation. The default values are for a development environment. Production-level values and other considerations are documented, where those values are different from the default.
500+
// RedpandaResources encapsulates the calculation of the redpanda container's
501+
// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#resourcerequirements-v1-core[corev1.ResourceRequirements]
502+
// and parameters such as `--memory`, `--reserve-memory`, and `--smp`. This
503+
// calculation supports two modes:
504+
//
505+
// - Explicit mode (recommended): Activated when `Limits` and `Requests` are
506+
// set. In this mode, the CLI flags are calculated directly based on the
507+
// provided `Limits` and `Requests`. This mode ensures predictable resource
508+
// allocation and is recommended for production environments. If additional
509+
// tuning is required, the CLI flags can be manually overridden using
510+
// `statefulset.additionalRedpandaCmdFlags`.
511+
//
512+
// - Legacy mode (default): Used when `Limits` and `Requests` are not set.
513+
// In this mode, the container resources and CLI flags are calculated using
514+
// built-in default logic, where 80% of the container's memory is allocated
515+
// to Redpanda and the rest is reserved for system overhead. Legacy mode is
516+
// intended for backward compatibility and less controlled environments.
517+
//
518+
// Explicit mode offers better control and aligns with Kubernetes best
519+
// practices. Legacy mode is a fallback for users who have not defined `Limits`
520+
// and `Requests`.
501521
type Resources struct {
502522
Limits *map[corev1.ResourceName]resource.Quantity `json:"limits,omitempty"`
503523
Requests *map[corev1.ResourceName]resource.Quantity `json:"requests,omitempty"`
@@ -641,9 +661,8 @@ type PostInstallJob struct {
641661
Enabled *bool `json:"enabled,omitempty"`
642662
// Applies labels to the job to facilitate identification and selection based on custom criteria.
643663
Labels map[string]string `json:"labels,omitempty"`
644-
645664
// Affinity constraints for scheduling Pods. For details, see the
646-
// [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).
665+
// https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity[Kubernetes' documentation].
647666
Affinity *corev1.Affinity `json:"affinity,omitempty"`
648667
// SecurityContext is deprecated. Prefer [PodTemplate.Spec.SecurityContext]
649668
// or [PodTemplate.Spec.Containers[*].SecurityContext].
@@ -672,7 +691,7 @@ type PostUpgradeJob struct {
672691
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
673692

674693
// Affinity constraints for scheduling Pods. For details, see the
675-
// [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).
694+
// https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity[Kubernetes' documentation].
676695
Affinity *corev1.Affinity `json:"affinity,omitempty"`
677696
// SecurityContext is deprecated. Prefer [PodTemplate.Spec.SecurityContext]
678697
// or [PodTemplate.Spec.Containers[*].SecurityContext].

operator/api/redpanda/v1alpha2/redpanda_types_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import (
1313
"context"
1414
"encoding/json"
1515
"fmt"
16+
"os"
1617
"reflect"
18+
"regexp"
1719
"testing"
1820
"time"
1921

@@ -276,3 +278,15 @@ func AssertJSONCompat[From, To any](t *rapid.T, cfg rapid.MakeConfig, fn func(*F
276278

277279
require.JSONEq(t, string(original), string(through), "%s (%T) should have serialized to %s (%T)", through, to, original, from)
278280
}
281+
282+
func TestNoMarkdownLinks(t *testing.T) {
283+
data, err := os.ReadFile("testdata/crd-docs.adoc")
284+
require.NoError(t, err)
285+
286+
re := regexp.MustCompile(`\[(.+)\]\((.+)\)`)
287+
288+
matches := re.FindAllSubmatch(data, -1)
289+
for _, match := range matches {
290+
t.Errorf("public CRD docs use Ascii doc but found markdown link: %s\nDid you mean: %s[%s]\n(Or do you need to run task generate?)", match[0], match[2], match[1])
291+
}
292+
}

0 commit comments

Comments
 (0)