Skip to content

Commit eab602e

Browse files
helm chart: v4 refactor (#1869)
* Bundle CRDs in main chart. Signed-off-by: Josh Baird <jbaird@galileo.io> * Create fluent-operator-crds chart. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove legacy sub-chart dependencies. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove legacy CRD charts. Signed-off-by: Josh Baird <jbaird@galileo.io> * Reformat fluent-operator values. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update fluent-operator chart README. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update v4 MIGRATION doc. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update v4 MIGRATION doc. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update fluent-operator chart README. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update fluent-operator-crds README. Signed-off-by: Josh Baird <jbaird@galileo.io> * Add ToC to MIGRATION. Signed-off-by: Josh Baird <jbaird@galileo.io> * Reformat more values. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update CRDs. Signed-off-by: Josh Baird <jbaird@galileo.io> * Use dev versions for both charts. Signed-off-by: Josh Baird <jbaird@galileo.io> * Strip YAML separators and controller-version annotation. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update READMEs. Signed-off-by: Josh Baird <jbaird@galileo.io> * Render docs in helm-charts. Signed-off-by: Josh Baird <jbaird@galileo.io> * Strip separators from fluent-operator CRDs. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update chart verisons. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove helm-docs target. Signed-off-by: Josh Baird <jbaird@galileo.io> * Fix fluent-bit values key causing helm template parse error. Rename values key from 'fluent-bit' to 'fluentbit' in fluent-operator-crds chart. Hyphenated keys cannot be accessed via dot notation in Go templates (.Values.fluent-bit.enabled is parsed as arithmetic subtraction), causing a hard parse error on helm template/lint. Signed-off-by: Josh Baird <jbaird@galileo.io> * Fix spacing. Signed-off-by: Josh Baird <jbaird@galileo.io> * GNU sed. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update CRDs. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update CRDs. Signed-off-by: Josh Baird <jbaird@galileo.io> * Add Helm v4 E2E tests. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove dead code. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove tests. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove tests. Signed-off-by: Josh Baird <jbaird@galileo.io> * Update README. Signed-off-by: Josh Baird <jbaird@galileo.io> * Remove gitkeeps. Signed-off-by: Josh Baird <jbaird@galileo.io> * Fix RBAC. Signed-off-by: Josh Baird <jbaird@galileo.io> * Cleanup helmignore. Signed-off-by: Josh Baird <jbaird@galileo.io> * Bump fluentbit image. Signed-off-by: Josh Baird <jbaird@galileo.io> * Bump fluent-bit. Signed-off-by: Josh Baird <jbaird@galileo.io> --------- Signed-off-by: Josh Baird <jbaird@galileo.io> Co-authored-by: Marco Franssen <marco.franssen@gmail.com>
1 parent 5e34dd9 commit eab602e

File tree

66 files changed

+42195
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+42195
-593
lines changed

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ shellcheck:
5555
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
5656
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases
5757
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=config/crd/bases
58-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=charts/fluent-bit-crds/templates
59-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=charts/fluentd-crds/templates
58+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=charts/fluent-operator/crds
59+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=charts/fluent-operator/crds
60+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=charts/fluent-operator-crds/templates/fluent-bit
61+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=charts/fluent-operator-crds/templates/fluentd
6062
kubectl kustomize config/crd/bases/ | sed -e '/creationTimestamp/d' > manifests/setup/fluent-operator-crd.yaml
6163
kubectl kustomize manifests/setup/ | sed -e '/creationTimestamp/d' > manifests/setup/setup.yaml
6264
hack/mutate-crds.sh
@@ -378,7 +380,3 @@ docs-update: # update api docs
378380
update-helm-package: # update helm repo
379381
./hack/update-helm-package.sh
380382

381-
.PHONY: helm-docs
382-
helm-docs:
383-
cd charts/fluentd-crds && helm-docs
384-
cd charts/fluent-bit-crds && helm-docs

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,30 +152,42 @@ kubectl apply -f https://raw.githubusercontent.com/fluent/fluentbit-operator/mas
152152

153153
#### Deploy Fluent Operator with Helm
154154

155-
> NOTE: For the helm based install, Helm v3.2.1 or higher is needed.
155+
> NOTE: Helm v3.2.1 or higher is required.
156156
157-
To install or upgrade Fluent Operator using Helm:
157+
**Standard installation** (CRDs bundled in chart):
158158

159159
```shell
160-
export FLUENT_OPERATOR_CONTAINER_RUNTIME="containerd" # or "cri-o", "docker" depending on the container runtime being used (see `values.yaml`)
161-
162160
helm repo add fluent https://fluent.github.io/helm-charts
163-
helm upgrade --install fluent-operator fluent/fluent-operator \
164-
--create-namespace \
165-
--set containerRuntime=${FLUENT_OPERATOR_CONTAINER_RUNTIME}
161+
helm repo update
162+
163+
helm install fluent-operator fluent/fluent-operator \
164+
--create-namespace -n fluent
166165
```
167166

168-
By default, all CRDs required for Fluent Operator will be installed. To prevent `helm install` from installing CRDs, you can set `fluent-bit.crdsEnable` or `fluentd.crdsEnable` to `false`.
167+
The default container runtime is `containerd`. Set `--set containerRuntime=docker` or `--set containerRuntime=crio` if your cluster uses a different runtime.
169168

170-
Helm [does not manage the lifecycle of CRDs](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/), so if the Fluent Operator CRDs already exist, subsequent
171-
chart upgrades will not add or remove CRDs even if they have changed. During upgrades, users should manually update CRDs:
169+
Helm installs CRDs on first install but [does not upgrade or delete them](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/) on subsequent `helm upgrade` or `helm uninstall` calls. To update CRDs when upgrading the chart:
172170

171+
```shell
172+
helm pull fluent/fluent-operator --untar
173+
kubectl apply --server-side --force-conflicts -f fluent-operator/crds/
174+
helm upgrade fluent-operator fluent/fluent-operator -n fluent
173175
```
174-
wget https://github.com/fluent/fluent-operator/releases/download/<version>/fluent-operator.tgz
175-
tar -xf fluent-operator.tgz
176-
kubectl replace -f fluent-operator/crds
176+
177+
**Advanced installation** — full Helm lifecycle management of CRDs via the separate `fluent-operator-crds` chart:
178+
179+
```shell
180+
# Step 1: install CRDs as a separately managed release
181+
helm install fluent-operator-crds fluent/fluent-operator-crds -n fluent --create-namespace
182+
183+
# Step 2: install the operator, skipping CRDs (already installed above)
184+
helm install fluent-operator fluent/fluent-operator -n fluent --skip-crds
177185
```
178186

187+
With this approach, CRDs are upgraded with `helm upgrade fluent-operator-crds` and can be protected from deletion with `--set additionalAnnotations."helm\.sh/resource-policy"=keep`.
188+
189+
See the [MIGRATION-v4.md](charts/fluent-operator/MIGRATION-v4.md) guide for more information on upgrading from v3.x.
190+
179191
### Fluent Operator Walkthrough
180192

181193
For more info on various use cases of Fluent Operator, you can refer to [Fluent-Operator-Walkthrough](https://github.com/kubesphere-sigs/fluent-operator-walkthrough).
@@ -200,16 +212,10 @@ kubectl apply -f manifests/logging-stack
200212

201213
#### Deploy the Kubernetes logging pipeline with Helm
202214

203-
You can also deploy the Kubernetes logging pipeline with Helm, just need to set the `Kubernetes` parameter to `true` (default):
204-
205-
```shell
206-
helm upgrade fluent-operator --create-namespace -n fluent charts/fluent-operator/ --set containerRuntime=docker
207-
```
208-
209-
If you want to deploy `fluentd`, just need to set the `fluentd.enable` parameter to `true`:
215+
The Kubernetes logging pipeline (container log collection via Fluent Bit) is enabled by default (`Kubernetes: true`). To also deploy Fluentd as a log aggregation layer:
210216

211217
```shell
212-
helm upgrade fluent-operator --create-namespace -n fluent charts/fluent-operator/ --set containerRuntime=docker,fluentd.enable=true
218+
helm upgrade fluent-operator fluent/fluent-operator -n fluent --set fluentd.enable=true
213219
```
214220

215221
Within a couple of minutes, you should observe an index available:

charts/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
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.
1+
# Helm Charts
2+
3+
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.
4+
5+
To install these helm charts and view their documentation, visit the official [fluent/helm-charts](https://github.com/fluent/helm-charts/tree/main/charts/fluent-operator/) repo.

charts/fluent-bit-crds/README.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

charts/fluent-bit-crds/README.md.gotmpl

Lines changed: 0 additions & 20 deletions
This file was deleted.

charts/fluent-bit-crds/values.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
apiVersion: v2
2-
name: fluent-bit-crds
3-
description: A helm chart for Fluent-Bit custom resource definitions (CRDs) used by fluent-operator.
2+
name: fluent-operator-crds
3+
description: Custom Resource Definitions (CRDs) for Fluent Operator. Includes both Fluent Bit and Fluentd CRDs with Helm lifecycle management.
44
type: application
5-
version: 0.2.3
6-
appVersion: v3.6.0
5+
version: 0.0.0-dev.0 # This is a development chart which gets released and versioned in the fluent/helm-charts repo
6+
# renovate: datasource=docker depName=ghcr.io/fluent/fluent-operator/fluent-operator
7+
appVersion: 3.7.0
78
keywords:
89
- logging
910
- fluentd
1011
- fluent-bit
1112
- fluent-operator
13+
- crds
1214
home: https://github.com/fluent/fluent-operator
1315
icon: https://raw.githubusercontent.com/fluent/fluent-operator/master/docs/images/fluent-operator-icon.svg
1416
sources:
15-
- https://github.com/fluent/fluent-operator/tree/master/charts/fluent-bit-crds
17+
- https://github.com/fluent/fluent-operator/tree/master/charts/fluent-operator-crds
1618
maintainers:
17-
- name: cw-guo
18-
email: cwguoz@gmail.com
19+
- name: wenchajun
20+
email: dehaocheng@kubesphere.io
1921
- name: marcofranssen
2022
email: marco.franssen@gmail.com
2123
url: https://marcofranssen.nl
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Advanced Installation
2+
3+
### Install All CRDs
4+
5+
```bash
6+
helm install fluent-operator-crds fluent/fluent-operator-crds
7+
```
8+
9+
### Install Only Fluent Bit CRDs
10+
11+
```bash
12+
helm install fluent-operator-crds fluent/fluent-operator-crds \
13+
--set fluentd.enabled=false
14+
```
15+
16+
### Install Only Fluentd CRDs
17+
18+
```bash
19+
helm install fluent-operator-crds fluent/fluent-operator-crds \
20+
--set fluentbit.enabled=false
21+
```
22+
23+
## Protecting CRDs from Deletion
24+
25+
To prevent CRDs from being deleted on `helm uninstall`:
26+
27+
```bash
28+
helm install fluent-operator-crds fluent/fluent-operator-crds \
29+
--set additionalAnnotations."helm\.sh/resource-policy"=keep
30+
```
31+
32+
With this annotation, Helm will preserve the CRDs even if the chart is uninstalled.
33+
34+
## Using with fluent-operator
35+
36+
After installing the CRDs with this chart, install the operator with `--skip-crds`:
37+
38+
```bash
39+
# Step 1: Install CRDs
40+
helm install fluent-operator-crds fluent/fluent-operator-crds
41+
42+
# Step 2: Install operator (skip CRDs since already installed)
43+
helm install fluent-operator fluent/fluent-operator --skip-crds
44+
```

charts/fluent-bit-crds/templates/fluentbit.fluent.io_clusterfilters.yaml renamed to charts/fluent-operator-crds/templates/fluent-bit/fluentbit.fluent.io_clusterfilters.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
---
1+
{{- if .Values.fluentbit.enabled }}
22
apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
66
{{- with .Values.additionalAnnotations }}
77
{{- toYaml . | nindent 4 }}
88
{{- end }}
9-
controller-gen.kubebuilder.io/version: v0.18.0
109
name: clusterfilters.fluentbit.fluent.io
1110
spec:
1211
group: fluentbit.fluent.io
@@ -977,3 +976,4 @@ spec:
977976
type: object
978977
served: true
979978
storage: true
979+
{{- end }}

0 commit comments

Comments
 (0)