diff --git a/Makefile b/Makefile index 8b917f316..2f9c08bdd 100644 --- a/Makefile +++ b/Makefile @@ -57,9 +57,10 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=config/crd/bases $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=charts/fluent-operator/charts/fluent-bit-crds/crds - $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=charts/fluent-operator/charts/fluentd-crds/crds + $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=charts/fluentd-crds/templates kubectl kustomize config/crd/bases/ | sed -e '/creationTimestamp/d' > manifests/setup/fluent-operator-crd.yaml kubectl kustomize manifests/setup/ | sed -e '/creationTimestamp/d' > manifests/setup/setup.yaml + hack/mutate-crds.sh .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. @@ -384,3 +385,7 @@ helm-e2e: ginkgo # make helm e2e tests update-helm-package: # update helm repo ./hack/update-helm-package.sh + +.PHONY: helm-docs +helm-docs: + cd charts/fluentd-crds && helm-docs diff --git a/charts/README.md b/charts/README.md index 1222b29de..e6f2635aa 100644 --- a/charts/README.md +++ b/charts/README.md @@ -1 +1 @@ -The Helm charts in this directory are considered "development" and are [synced](../RELEASE.md) to the [fluent/helm-charts](https://github.com/fluent/helm-charts/tree/main/charts/fluent-operator/) repository for each release. Users are instructed to install the Fluent Operator Helm chart from the [fluent/helm-charts](https://github.com/fluent/helm-charts/tree/main/charts/fluent-operator/) repo. \ No newline at end of file +The Helm charts in this directory are considered "development" and are [synced](../RELEASE.md) to the [fluent/helm-charts](https://github.com/fluent/helm-charts/tree/main/charts/fluent-operator/) repository for each release. Users are instructed to install the Fluent Operator Helm chart from the [fluent/helm-charts](https://github.com/fluent/helm-charts/tree/main/charts/fluent-operator/) repo. diff --git a/charts/fluent-operator/Chart.yaml b/charts/fluent-operator/Chart.yaml index 71933ae4b..623750bb7 100644 --- a/charts/fluent-operator/Chart.yaml +++ b/charts/fluent-operator/Chart.yaml @@ -27,6 +27,6 @@ dependencies: version: 3.5.0 condition: fluentbit.crdsEnable - name: fluentd-crds - repository: "file://charts/fluentd-crds" - version: 3.5.0 - condition: fluentd.crdsEnable + repository: https://fluent.github.io/helm-charts + condition: fluentd.enable && fluentd.crdsEnable + version: 0.1.0 diff --git a/charts/fluent-operator/MIGRATION-v4.md b/charts/fluent-operator/MIGRATION-v4.md index 0a3bf18a4..081b7ee7e 100644 --- a/charts/fluent-operator/MIGRATION-v4.md +++ b/charts/fluent-operator/MIGRATION-v4.md @@ -2,7 +2,11 @@ ## Overview -v4.0 simplifies container runtime configuration by removing dynamic detection for the `docker` runtime via initContainers and adopting static, configuration-based paths. The `docker` runtime has not been used widely since Kubernetes v1.24 (2022) and modern Kubernetes distributions now use the `containerd` runtime. +Major changes/themes for v4.0: + +1. **Container Runtime Simplification**: Removes dynamic detection for the `docker` runtime via initContainers and adopts static, configuration-based paths. The `docker` runtime has not been used widely since Kubernetes v1.24 (2022) and modern Kubernetes distributions now use the `containerd` runtime. + +2. **fluentd-crd lifecycle changes**: Fluentd CRDs have been moved from an embedded sub-chart to a separate, independently versioned `fluentd-crds` chart hosted in the Fluent Helm repository. CRDs are now in the `templates/` directory, enabling automatic upgrades via `helm upgrade`. **Important:** CRDs will now be deleted on `helm uninstall` unless protected with the `helm.sh/resource-policy: keep` annotation (see below for details). ## Breaking Changes @@ -25,7 +29,6 @@ v4.0 simplifies container runtime configuration by removing dynamic detection fo **Migration:** - The containerRuntime now defaults to `containerd`. In `v3.x` the implicit default was `docker`. Use `containerRuntime: docker` to maintain `v3.x` behavior. ```diff @@ -102,7 +105,7 @@ v4.0 uses the following default paths based on the configured `containerRuntime` ## Migration Scenarios -### Scenario 1: Using Containerd (Default) - No Changes Needed ✅ +### Scenario 1: Using Containerd (Default) - No Changes Needed ```yaml # v3.x @@ -140,6 +143,53 @@ containerRuntime: docker # to use the standard path ``` +## Fluentd CRDs Moved to Separate Chart with Automatic Upgrades + +**What Changed:** + +- Fluentd CRDs moved from embedded sub-chart to separate `fluentd-crds` chart in the Fluent Helm repository +- CRDs relocated from `crds/` directory to `templates/` directory, changing their lifecycle behavior + +**Impact:** + +- **CRDs now upgrade automatically** with `helm upgrade` (previously required manual upgrade) +- **CRDs will be deleted on `helm uninstall`** (previously they were preserved). + +**Who Is Affected:** + +- All users who use Fluentd with the fluent-operator +- Users who rely on CRDs and custom resources persisting after chart uninstall + +**Migration:** + +Before installing or upgrading, ensure the Fluent Helm repository is added: + +```bash +# Add the Fluent Helm repository (required for the dependency) +helm repo add fluent https://fluent.github.io/helm-charts +helm repo update + +# Install or upgrade fluent-operator (CRDs installed automatically via dependency) +helm upgrade --install fluent-operator fluent/fluent-operator \ + --version 4.0.0 \ + --set fluentd.enable=true +``` + +**Note:** Helm will automatically manage the `fluentd-crds` dependency when `fluentd.enable=true` and `fluentd.crdsEnable=true` (default). + +**Protecting CRDs from Deletion:** + +To prevent CRDs from being deleted when the `fluentd-crds` chart is uninstalled, add the `helm.sh/resource-policy: keep` annotation: + +```bash +helm upgrade --install fluent-operator fluent/fluent-operator \ + --version 4.0.0 \ + --set fluentd.enable=true \ + --set fluentd-crds.additionalAnnotations."helm\.sh/resource-policy"=keep +``` + +With this annotation, Helm will preserve the CRDs and all Fluentd custom resources even if the chart is uninstalled. + ## Forward Looking: Planned Changes in v5.0 **Future Change (v5.0):** diff --git a/charts/fluent-operator/charts/fluentd-crds/Chart.yaml b/charts/fluent-operator/charts/fluentd-crds/Chart.yaml deleted file mode 100644 index 2fc40af30..000000000 --- a/charts/fluent-operator/charts/fluentd-crds/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: fluentd-crds -description: A Helm chart delivering fluentd controller CRDS -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -#type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 3.5.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -# renovate: datasource=docker depName=ghcr.io/fluent/fluent-operator/fluent-operator -appVersion: "3.5.0" diff --git a/charts/fluent-operator/charts/fluentd-crds/values.yaml b/charts/fluent-operator/charts/fluentd-crds/values.yaml deleted file mode 100644 index 58196662a..000000000 --- a/charts/fluent-operator/charts/fluentd-crds/values.yaml +++ /dev/null @@ -1 +0,0 @@ -# Default values for fluentd-crds. diff --git a/charts/fluent-operator/charts/fluentd-crds/.helmignore b/charts/fluentd-crds/.helmignore similarity index 100% rename from charts/fluent-operator/charts/fluentd-crds/.helmignore rename to charts/fluentd-crds/.helmignore diff --git a/charts/fluentd-crds/Chart.yaml b/charts/fluentd-crds/Chart.yaml new file mode 100644 index 000000000..08fcd34ce --- /dev/null +++ b/charts/fluentd-crds/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: fluentd-crds +description: A helm chart for Fluentd custom resource definitions (CRDs) used by fluent-operator. +type: application +version: 0.1.0 +appVersion: 0.1.0 +keywords: + - logging + - fluentd + - fluent-bit + - fluent-operator +home: https://github.com/fluent/fluent-operator +icon: https://raw.githubusercontent.com/fluent/fluent-operator/master/docs/images/fluent-operator-icon.svg +sources: + - https://github.com/fluent/fluent-operator/tree/master/charts/fluentd-crds +maintainers: + - name: cw-guo + - name: marcofranssen + email: marco.franssen@gmail.com + url: https://marcofranssen.nl + - name: joshuabaird + email: joshbaird@gmail.com diff --git a/charts/fluentd-crds/README.md b/charts/fluentd-crds/README.md new file mode 100644 index 000000000..fd4d9d8b4 --- /dev/null +++ b/charts/fluentd-crds/README.md @@ -0,0 +1,29 @@ +# fluentd-crds + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) + +A helm chart for Fluentd custom resource definitions (CRDs) used by fluent-operator. + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| cw-guo | | | +| marcofranssen | | | +| joshuabaird | | | + +## Source Code + +* + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| additionalAnnotations | object | `{}` | Additional annotations for the custom resource definitions. | + +---------------------------------------------- + +Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/). diff --git a/charts/fluentd-crds/README.md.gotmpl b/charts/fluentd-crds/README.md.gotmpl new file mode 100644 index 000000000..7991d3c23 --- /dev/null +++ b/charts/fluentd-crds/README.md.gotmpl @@ -0,0 +1,20 @@ +{{ template "chart.header" . }} +{{ template "chart.deprecationWarning" . }} + +{{ template "chart.badgesSection" . }} + +{{ template "chart.description" . }} + +{{ template "chart.homepageLine" . }} + +{{ template "chart.maintainersSection" . }} + +{{ template "chart.sourcesSection" . }} + +{{ template "chart.requirementsSection" . }} + +{{ template "chart.valuesSection" . }} + +---------------------------------------------- + +Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/). diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterfilters.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_clusterfilters.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterfilters.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_clusterfilters.yaml index 578f676c8..37b1891b0 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterfilters.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_clusterfilters.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: clusterfilters.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterfluentdconfigs.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_clusterfluentdconfigs.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterfluentdconfigs.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_clusterfluentdconfigs.yaml index 4ad0c465a..0bd8ee9d8 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterfluentdconfigs.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_clusterfluentdconfigs.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: clusterfluentdconfigs.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterinputs.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_clusterinputs.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterinputs.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_clusterinputs.yaml index 3b3afb8c5..e3c23b601 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusterinputs.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_clusterinputs.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: clusterinputs.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusteroutputs.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_clusteroutputs.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusteroutputs.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_clusteroutputs.yaml index 2a0447000..47c95755c 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_clusteroutputs.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_clusteroutputs.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: clusteroutputs.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_filters.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_filters.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_filters.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_filters.yaml index cc1d4d07d..f38d3c83a 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_filters.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_filters.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: filters.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentdconfigs.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_fluentdconfigs.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentdconfigs.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_fluentdconfigs.yaml index 0e5a8215a..cba2b3c56 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentdconfigs.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_fluentdconfigs.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: fluentdconfigs.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_fluentds.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_fluentds.yaml index 36ce3f749..81ee4f911 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_fluentds.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_fluentds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: fluentds.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_inputs.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_inputs.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_inputs.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_inputs.yaml index 40bd48a26..cc73eeab8 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_inputs.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_inputs.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: inputs.fluentd.fluent.io spec: diff --git a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_outputs.yaml b/charts/fluentd-crds/templates/fluentd.fluent.io_outputs.yaml similarity index 99% rename from charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_outputs.yaml rename to charts/fluentd-crds/templates/fluentd.fluent.io_outputs.yaml index f7c023b33..cbae4a559 100644 --- a/charts/fluent-operator/charts/fluentd-crds/crds/fluentd.fluent.io_outputs.yaml +++ b/charts/fluentd-crds/templates/fluentd.fluent.io_outputs.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.additionalAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.18.0 name: outputs.fluentd.fluent.io spec: diff --git a/charts/fluentd-crds/values.yaml b/charts/fluentd-crds/values.yaml new file mode 100644 index 000000000..8d422f6cd --- /dev/null +++ b/charts/fluentd-crds/values.yaml @@ -0,0 +1,2 @@ +# -- Additional annotations for the custom resource definitions. +additionalAnnotations: {} diff --git a/hack/mutate-crds.sh b/hack/mutate-crds.sh new file mode 100755 index 000000000..e9b568e0c --- /dev/null +++ b/hack/mutate-crds.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Support additional annotations for CRDs + +CRDS=( + charts/fluentd-crds/templates/*.yaml +) +for CRD in "${CRDS[@]}" +do + [[ -f "$CRD" ]] || continue + awk '{print} / annotations:/ && !n {print " {{- with .Values.additionalAnnotations }}\n {{- toYaml . | nindent 4 }}\n {{- end }}"; n++}' "$CRD" > "$CRD.new" && mv "$CRD.new" "$CRD" +done