Commit Graph
47 Commits
Author SHA1 Message Date
Erik Sundell 039f158950 helm: refactoring to modernize templates
This touches a lot where a typo could cause issues for someone, so I have self-
reviewed it many times line-by-line already.

There are a few types of changes:
- All resources get tied to their own YAML document separator (`---`)
  before their definition, reducing the risk of not separating resources
  correctly when rendering multiple into a file. I think the changes
  will fix edge case bugs for people with mutiple items listed in
  `cephFileSystems` and similar configuration.
- `toYaml ...` is made into `... | toYaml` consistently.
- `default A B` is made into `B | default A` consistently.
- Consistent whitespace chomping, so instead of `{{ end }}` you would
  find `{{- end }}` typically. The system is that you should chomp left
  almost all the time, and almost all the time _not_ chomp right. You
  would chomp right in the beginning of a file or helper function in
  order to clear some initial whitespace, otherwise not.
- Multiline helm template comments `{{- /* ... */ }}` get their content
  indented 2 spaces.
- List items are consistently rendered with two spaces of indentation.
- `kind` is put before `apiVersion` consistently, to follow a practice
  observed partially in the repo.
- Calls to the helm `template` function have been replaced with
  `include` to be consistent and to stick with modern practices.
- Use of `indent` have been replaced with `nindent #` and a left
  whitespace chomp for a consistent easy to follow practice that gets
  good result.
- Several `if` statements like `if X -> render X` have been replaced
  with `with X -> render .` to avoid repetition. The `with` statement
  won't render if the provided context, making it function also like an
  `if` statement.
- Fixed a bug with `if .Values.revisionHistoryLimit`, which should
  really be `if not (typeIs "<nil>" .Values.revisionHistoryLimit)` to
  handle situations when its set to `0`.

Signed-off-by: Erik Sundell <erik@sundellopensource.se>
2025-09-16 09:55:10 +02:00
Allen Conlon fa2e499727 ci: publish helm charts to oci repos
Signed-off-by: Allen Conlon <software@conlon.dev>
2025-03-21 20:15:59 -04:00
subhamkrai dd8c3c9974 build: remove csv related files
remove csv related files/content which are not used/required for
upstream uses.

Signed-off-by: subhamkrai <srai@redhat.com>
2024-03-11 21:01:53 +05:30
Redouane KachachandBlaine Gardner bd7477ec61 manifest: reduce CRD size by removing some descriptions
Reduce CRD size by removing some descriptions for things that
(a) are long, (b) are repeated, and (c) are commong kubernetes types.

Remove the `Status` field from VolumeClaimTemplates (a.k.a. PVCs) in
types.go to remove all unnecessary status-related fields.

Use `yq` to go through generated `crds.yaml` to strip out descriptions
for well-known k8s types that are long and repeated where we can't
remove them from types.go. This is mostly placement descriptions and
volumeSource descriptions.

The overall `crds.yaml` file is reduced to less than 60% of its original
size.

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
Co-authored-by: Blaine Gardner <blaine.gardner@ibm.com>
2024-02-20 10:08:44 +01:00
travisn 3c1b0692e4 manifest: shorten crd descriptions to 100 chars
Long CRD descriptions were pushing the size of the CRDs manifest
over 1MB, which causes issues when creating the CRDs. To shorten
the manifest, the descriptions are now limited to 100 chars.
This still gives some ability for dev tools to show a brief
description if needed. The generated CRD docs still contain
the full descriptions for reference.

Signed-off-by: travisn <tnielsen@redhat.com>
2024-01-05 09:10:36 -07:00
subhamkrai 1b652f8176 build: add check to validate crd in csv
In the past we had few cases where the new crd
was missed adding in metadata-common.yaml file.
So, now we'll check if crds.yaml and metadata-common.yaml
crd name are matching.

Signed-off-by: subhamkrai <srai@redhat.com>
2023-09-06 19:37:25 +05:30
parth-gr 8175bc0218 build: make crds should be able to build generated docs
Currently, if there is any change in the API we need to separately
run the make generate-crd-docs but with this change
make crds will also update the generated docs

Also improved the file locations

Closes: https://github.com/rook/rook/issues/12310

Signed-off-by: parth-gr <paarora@redhat.com>
2023-06-15 20:11:23 +05:30
Javier 9b3e5b10e7 docs: remove the line generated by gen-crd-api-reference-docs
removing the line added by gen-crd-api-reference-docs to avoid commit
specification.md with only the reference to the git commit

Signed-off-by: Javier <sjavierlopez@gmail.com>
2023-06-14 11:35:29 -06:00
Javier 661e476969 docs: auto-generate the documentation for CRDs
add generate-crd-docs.sh tool for auto-generate the documentation for CRDs automatically

Closes: #1873
Signed-off-by: Javier <sjavierlopez@gmail.com>
2023-05-01 19:23:27 -06:00
parth-grandBlaine Gardner 69ae9569cd build: update k8s version to 1.26.1
Update the Kubernetes API version used to 1.26.1, and start testing
against Kubernetes version 1.26.1 in CI.

Co-authored-by: parth-gr <paarora@redhat.com>
Co-authored-by: Blaine Gardner <blaine.gardner@redhat.com>

Signed-off-by: parth-gr <paarora@redhat.com>
Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2023-02-23 20:18:47 -07:00
Khris Richardson fca7d44c3f manifest: revert fix unexpected end of stream
Signed-off-by: Khris Richardson <khris.richardson@gmail.com>
2022-12-07 13:40:35 -08:00
Travis Nielsen 7863d3161c build: fix intermittent gen-rbac failure
The crds generation for the helm crds is intermittently hitting a build
error due to multiple builds generating the crds at the same time.
We avoid this race condition by first writing the crds to a temp file
then move the file to the helm crd resources file.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2022-09-14 16:10:51 -06:00
Travis Nielsen 08c787e8d6 Merge pull request #10777 from yati1998/remove-vol-rep
rbd-mirror: remove volume replication sidecar
2022-09-07 08:27:07 -06:00
yati1998 69a233be4e build: remove volume replication crd from build
This commit removes the creation of volume
replication crds from build.

Signed-off-by: yati1998 <ypadia@redhat.com>
2022-09-07 14:49:32 +05:30
Khris Richardson 9614428f54 manifest: fix unexpected end of stream
Signed-off-by: Khris Richardson <khris.richardson@gmail.com>
2022-09-06 15:04:06 -07:00
Travis Nielsen c75f6ffd82 build: clean the olm dir for crd generation
The volume replication crds were being added to the generation directory
and causing subsequent builds to pick up those crds in the generation
of crds.yaml and the helm generation. To keep the volume replication
crds out of the generation, the directory needs to be cleaned
with each run.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2022-03-10 14:15:31 -07:00
Travis Nielsen 2453a5a71b build: allow overriding the volume replication crd url
Custom builds such as downstream may need to use an alternate
version, fork, or branch for the volume replication CRDs.
If the build sets the env var VOLUME_REPLICATION_URL, this
value will be used. The default url is
https://raw.githubusercontent.com/csi-addons/volume-replication-operator/v0.3.0/config/crd/bases

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2022-03-09 16:17:09 -07:00
Travis Nielsen 75a385e187 csi: update volume replication to v0.3.0
Update to the latest volume replication crd version of
v0.3.0

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2022-03-09 15:53:45 -07:00
Travis Nielsen d86bb78f11 build: add volume replication crds to csv ownership
The volume replication crds are not owned by rook, but if installing
with the csv, ownership must be specified for the CRDs. Thus, we limit
ownership to the csv for the volume replication crds.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2022-03-09 15:53:43 -07:00
Sébastien Han 8512b6a0e1 build: set LC_ALL on the make target
Simply applying `LC_ALL=C` will work for the current shell only. For all
the shells and sub-shell to use it, we must set it globally.
Making it the first thing in the Make entrypoint now so the CRD and RBAC
sorting works on all the platforms.

Signed-off-by: Sébastien Han <seb@redhat.com>
2022-01-18 12:01:04 +01:00
Blaine Gardner 6f4a23694d build: make crd/rbac generation order deterministic
Linux doesn't guarantee file ordering, so when dealing with files in
order, we can use 'sort' to make sure the order is deterministic. For
yq's usage of files, we need to keep file names in an intermediate
variable, and this should be an array to support file paths with spaces.
'readarray' is not available on MacOS's built-in bash, so a longer
'while read' loop is needed for the array creation.

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2022-01-13 09:24:07 -07:00
Blaine Gardner 113e2f849d build: use yq for RBAC yaml parsing
Use yq instead of Python for parsing RBAC from the Helm chart. We need
to use yq v4.14.1 or higher to fix yq's handling of the yaml header
markers ('---'). Update the Makefile's yq version to v4, which also
requires updating the script to update the CRDs. This was quite easy.

It is very difficult, however, to change the version of yq used by the
CSV generating/parsing scripts, which already used their own yq
download. Continue using yq v3 for this.

In order to make sure the scripts are using the right version of yq, add
basic validation to them to verify they are running v3 or v4 as required
for their operation.

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2021-11-30 08:08:08 -07:00
Sébastien Han c890710b63 core: change directory layout
As per discussion, proposing a new layout for the charts/yaml/olm files.

./deploy
├── charts
│   ├── rook-ceph
│   │   └── templates
│   └── rook-ceph-cluster
│       └── templates
├── examples
│   ├── csi
│   │   ├── cephfs
│   │   └── rbd
│   ├── flex
│   ├── monitoring
│   ├── pre-k8s-1.16
└── olm
    └── assemble

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-11-30 09:12:53 +01:00
Travis Nielsen c420f2309c csi: no longer install the volumereplication crds from rook
The volume replication CRDs are an external component, not owned by Rook.
Therefore, they should be installed as any other independent component
in case the admin will install other consumers of the volumereplication CRDs
in the future in addition to Rook and the CSI driver.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-10-06 16:27:44 +00:00
Travis Nielsen f5c1543ddf build: update min k8s version to 1.16
In Rook v1.8 the min version of K8s supported is updated to 1.16.
Users running on older versions of K8s are recommended to update
to 1.16 or newer before updating to Rook v1.8.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-09-23 16:17:56 -06:00
Travis Nielsen 0a0b9c98bd build: remove obsolete flex driver
The flex driver has been fully deprecated and thus removed from Rook.
Before upgrading to v1.8, users will need to convert existing flex volumes
from flex to csi volumes.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-09-23 16:17:20 -06:00
Blaine Gardner 1b1736a3c5 ceph: remove NFS and Cassandra example manifests
Additionally remove NFS and Cassandra from CRD generator script.

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2021-08-31 14:05:34 -06:00
Sébastien Han cd9754e2f1 core: do not format deepcopy-gen files
deepcopy-gen appends a header starting with `// +build` which makes
gofmt to complain in Go 1.17 so until this is fixed in
https://github.com/kubernetes/gengo/pull/210 let's skip those files for
formatting.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-08-24 12:03:17 +02:00
subhamkrai 1681cfe89d ceph: add -0 for helm k8s version check
to use prerelease of kubernetes it requires
to have `-0` added in kubernetes version check
ex:
```{{- if semverCompare ">=1.16.0-0" .Capabilities.KubeVersion.GitVersion }}```

Closes: https://github.com/rook/rook/issues/8548
Signed-off-by: subhamkrai <srai@redhat.com>
2021-08-18 19:15:48 +05:30
Blaine Gardner 9138732c81 build: stage CSV files into tmp while building
If a user were to `make build` Rook, and after the Ceph CSV was
generated and before make had finished, the Rook repo would be left with
changes caused by the build modifying files temporarily in-place.

All CSV template generation in the Ceph makefile is now self-contained
and can be configured to operate outside of the main repo so that files
are not modified in-place.

In-place modification of files was also incorrect. On Mac some files
with `-e` trailing were left, and in-place backups were also present in
the form `<filename>''`. Therefore, also fix the generation to fix
in-place modifications.

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2021-07-27 16:11:58 -06:00
Travis NielsenandNicolaj Græsholt f114db952b nfs: generate the crds from types for v1
The CRDs v1 requires the full schema for all settings, so we now
generate the CRDs for nfs for full fidelity of all settings.

Co-authored-by: Nicolaj Græsholt <figaw@hotmail.com>
Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-07-20 08:18:05 -06:00
Travis Nielsen 093cf6dbbd cassandra: generate the crds from types for v1
The CRDs v1 requires the full schema for all settings, so we now
generate the CRDs for cassandra for full fidelity of all the
settings.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-07-20 08:18:05 -06:00
Travis Nielsen 08d720f450 ceph: preserve volume claim template annotations during upgrade
The upgrade of the csv is failing to the latest schema when
the crushDeviceClass is specified and when the volumeClaimTemplate
annotations do not preserve the unknown fields. To fix the upgrade,
we preserve the fields even though it should not be necessary
from the strict schema.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-05-05 16:33:40 -06:00
Blaine Gardner d260b81e97 core: persist VolumeClaimTemplate metadtata
Allow metadata on VolumeClaimTemplates in StorageClassDeviceSets to be
persisted. The latest changes to controller-gen allows us to embed
objectmeta for embedded types.

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2021-04-27 13:37:48 -06:00
Satoru Takeuchi 8a48dbb00d ceph: stop vendoring
We generate vendor directory in building process. It doesn't reduce
build time. In addition, we have encountered some vendoring-related
problems. So let's stop vendoring.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
2021-04-21 02:01:56 +00:00
Blaine Gardner 02e2a3d2eb build: fix new sed line to work on mac
The POSIX spec for sed requires the flag -i to have a string specified.
`sed -i'' -e '<expression>'` is portable

The POSIX spec for sed also requires the insert "i" option to have
newlines. The following is portable:
```
sed -i'' -e '<line-num>i\
text'
```

Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
2021-04-20 17:20:05 +02:00
Sébastien Han 21d6001ed2 ceph: preserve volume claim template metadata in schema
The schema generation was not generating the metadata properties
under the VolumeClaimTemplate type, resulting in the properties being
ignored by the api server. The preserve unknown fields tag was
not working recursively on the volumeClaimTemplates since the subtypes
were defined. Now we post-process the schema so we can preserve
the unknown fields for the volume claim templates metadata.

We now use 'yq' to hot-fix the CRDs, the only 'downside' is that 'yq'
will not preserve the existing formatting, this is a known problem:

https://github.com/mikefarah/yq/issues/465

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-04-19 19:03:13 +02:00
Sébastien Han 341aefc95d ceph: revert "ceph: preserve volume claim template metadata in schema"
This reverts commit a9fb9d20bb. During the
CSV generation we strip the description lines from the CRD spec, however
the 'sed' command relies on the 'descrition' section to operate. Next
commit will fix this.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-04-19 19:01:13 +02:00
Sébastien Han 9416e52250 Merge pull request #7619 from leseb/add-vol-rep-crds
ceph: add volume replication crds
2021-04-15 15:15:02 +02:00
Sébastien Han 83a44ae4df ceph: add volume replication crds
With the help of https://github.com/rook/rook/pull/7403/, rook will soon
integrate the volume replication controller as a side-car. Thus Rook
needs to inject the new CRDs.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-04-15 13:18:13 +02:00
Travis Nielsen a9fb9d20bb ceph: preserve volume claim template metadata in schema
The schema generation was not generating the metadata properties
under the VolumeClaimTemplate type, resulting in the properties being
ignored by the api server. The preserve unknown fields tag was
not working recursively on the volumeClaimTemplates since the subtypes
were defined. Now we post-process the schema so we can preserve
the unknown fields for the volume claim templates metadata.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-04-14 21:41:12 -06:00
Sébastien Han 3d1d659e28 ci: do not include ob/obc/volumes crds in csv
We don't want to include those CRDs anymore, as they get imported from
another operator.
This trims further down the size of our CSV generation.

Additionally, we always clean the csv directory before proceeding.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-04-06 17:08:39 +02:00
Sébastien Han 5a194af3b1 ceph: strip crd description for csv generation
The CSV file size cannot be bigger than 1MB so let's remove all the
description fields make it lighter.

With that change the CRDs size went from 692K to 372K so the size was
reduced by almost 50%.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-04-06 14:13:07 +02:00
Travis Nielsen c73a2e943d ceph: compatibility for generating crds without sed
On mac the make crds command was failing on the sed commands.
Now we remove the dependency on sed and just append the files
to generate the helm resources

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-03-30 14:18:17 -06:00
Sébastien Han cf00a86fc2 ceph: force yq and controller-gen versions
Let's not use any controllen-gen version we might find on the system,
always pull the version we need.
Same goes for yq.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-03-26 09:21:33 +01:00
Travis Nielsen deb7c21f98 ceph: install pre-1.16 crds with helm chart
The helm chart was not installing the CRDs on pre-1.16 k8s due
to a regression in the conditionals for the chart that was introduced
with 7103.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-03-17 13:10:53 -06:00
Sébastien Han 31db03fece ceph: auto-gen crds
Finally! We can now stop editing manually our crds definition. Simply
run `make crds-gen`. These two files:

* `cluster/examples/kubernetes/ceph/crds.yaml`
* `cluster/charts/rook-ceph/templates/resources.yaml`

will be autogenerated for us.

We rely on the controller-gen tool, it reads our API definitions from
`pkg/apis/` and produces the CRD files accordingly.

It uses "markers" to add extra yaml fields to the CRD, for instance we
have a lot fields with:

```
nullable: true
x-kubernetes-preserve-unknown-fields: true
```

The corresponding API type markers are:

```
// +kubebuilder:pruning:PreserveUnknownFields
// +nullable
```

For more API convention see
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#optional-vs-required
and for the markers see: https://book.kubebuilder.io/reference/markers/crd-validation.html

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-03-16 09:16:24 +01:00