Skip to content

Commit

Permalink
feat: add TC migration option (#1876)
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
Signed-off-by: Peter Wilcsinszky <[email protected]>
Co-authored-by: Peter Wilcsinszky <[email protected]>
  • Loading branch information
csatib02 and pepov authored Dec 17, 2024
2 parents f3eca81 + 9c964ef commit 23d4606
Show file tree
Hide file tree
Showing 31 changed files with 1,171 additions and 123 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ jobs:
id: oci-chart-name
run: echo "value=${{ steps.oci-registry-name.outputs.value }}/${{ steps.chart-name.outputs.value }}" >> "$GITHUB_OUTPUT"

- name: Helm dependency update
run: helm dependency update charts/${{ steps.chart-name.outputs.value }}

- name: Helm lint
run: helm lint charts/${{ steps.chart-name.outputs.value }}

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ testbin
example/tls-cluster-forward/*.pem
example/tls-cluster-forward/*.csr
example/tls-cluster-forward/*.key

charts/logging-operator/charts/*.tgz
.licensei.cache

.DS_Store
Expand Down
9 changes: 9 additions & 0 deletions charts/logging-operator/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: logging-operator-crds
repository: ""
version: 0.0.0
- name: telemetry-controller
repository: oci://ghcr.io/kube-logging/helm-charts
version: 0.0.15
digest: sha256:8ff43abc414a65d3069a1c6b697826e639134c1791bb84b1fbde054ff7de450c
generated: "2024-12-16T17:13:49.863948+01:00"
4 changes: 4 additions & 0 deletions charts/logging-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ dependencies:
- name: logging-operator-crds
version: 0.0.0
condition: logging-operator-crds.install
- name: telemetry-controller
version: "0.0.15"
repository: oci://ghcr.io/kube-logging/helm-charts
condition: telemetry-controller.install
1 change: 1 addition & 0 deletions charts/logging-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Use `createCustomResource=false` with Helm v3 to avoid trying to create CRDs fro
| createCustomResource | bool | `false` | Deploy CRDs used by Logging Operator. |
| logging-operator-crds.install | bool | `false` | Toggle to install and upgrade CRDs from a subchart. Make sure to use it with `--skip-crds` to avoid conflicts. [More info about limitations on CRDs in Helm 3](https://helm.sh/docs/topics/charts/#limitations-on-crds) |
| logging-operator-crds.annotations | object | `{}` | Annotations to be added to all CRDs |
| telemetry-controller.install | bool | `false` | Toggle to install and upgrade Telemetry Controller from a subchart. |
| http.port | int | `8080` | HTTP listen port number. |
| http.service | object | `{"annotations":{},"clusterIP":"None","labels":{},"type":"ClusterIP"}` | Service definition for query http service. |
| rbac.enabled | bool | `true` | Create rbac service account and roles. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ spec:
type: object
controlNamespace:
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
image:
properties:
imagePullSecrets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ spec:
type: object
controlNamespace:
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
defaultFlow:
properties:
filters:
Expand Down Expand Up @@ -12597,6 +12600,17 @@ spec:
type: string
type: object
type: array
routeConfig:
properties:
disableLoggingRoute:
type: boolean
enableTelemetryControllerRoute:
type: boolean
tenantLabels:
additionalProperties:
type: string
type: object
type: object
skipInvalidResources:
type: boolean
syslogNG:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ spec:
type: object
controlNamespace:
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
image:
properties:
imagePullSecrets:
Expand Down
14 changes: 14 additions & 0 deletions charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ spec:
type: object
controlNamespace:
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
defaultFlow:
properties:
filters:
Expand Down Expand Up @@ -12594,6 +12597,17 @@ spec:
type: string
type: object
type: array
routeConfig:
properties:
disableLoggingRoute:
type: boolean
enableTelemetryControllerRoute:
type: boolean
tenantLabels:
additionalProperties:
type: string
type: object
type: object
skipInvalidResources:
type: boolean
syslogNG:
Expand Down
16 changes: 16 additions & 0 deletions charts/logging-operator/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,20 @@ rules:
- patch
- update
- watch
- apiGroups:
- telemetry.kube-logging.dev
resources:
- bridges
- collectors
- outputs
- subscriptions
- tenants
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
{{- end }}
5 changes: 5 additions & 0 deletions charts/logging-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ logging-operator-crds:
# -- Annotations to be added to all CRDs
annotations: {}

## Telemetry Controller defined as a dependency chart
telemetry-controller:
# -- Toggle to install and upgrade Telemetry Controller from a subchart.
install: false

http:
# -- HTTP listen port number.
port: 8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ spec:
type: object
controlNamespace:
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
image:
properties:
imagePullSecrets:
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ spec:
type: object
controlNamespace:
type: string
x-kubernetes-validations:
- message: Value is immutable, please recreate the resource
rule: self == oldSelf
defaultFlow:
properties:
filters:
Expand Down Expand Up @@ -12594,6 +12597,17 @@ spec:
type: string
type: object
type: array
routeConfig:
properties:
disableLoggingRoute:
type: boolean
enableTelemetryControllerRoute:
type: boolean
tenantLabels:
additionalProperties:
type: string
type: object
type: object
skipInvalidResources:
type: boolean
syslogNG:
Expand Down
16 changes: 16 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,19 @@ rules:
- patch
- update
- watch
- apiGroups:
- telemetry.kube-logging.dev
resources:
- bridges
- collectors
- outputs
- subscriptions
- tenants
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
71 changes: 71 additions & 0 deletions config/samples/telemetry-controller-routing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# TC-routing

## Setup

In this setup customer-a sends logs over the traditional path (fluentbit -> fluentd) while
customer-b sends over the telemetry-controller path (opentelemetry collector -> fluentd).

In both cases, flows and outputs should work and behave the same.

```shell
make kind-cluster
make docker-build
kind load docker-image controller:local

helm dependency update charts/logging-operator
helm upgrade --install \
--wait \
--create-namespace \
--namespace logging \
logging-operator ./charts/logging-operator/ \
--set image.repository=controller \
--set image.tag=local \
--set extraArgs='{"-enable-leader-election=true","-enable-telemetry-controller-route"}' \
--set telemetry-controller.install=true \
--set testReceiver.enabled=true

kubectl apply -f config/samples/telemetry-controller-routing/

helm upgrade --install --namespace customer-a log-generator oci://ghcr.io/kube-logging/helm-charts/log-generator
helm upgrade --install --namespace customer-b log-generator oci://ghcr.io/kube-logging/helm-charts/log-generator
helm upgrade --install --namespace infra log-generator oci://ghcr.io/kube-logging/helm-charts/log-generator
```

## Switching between logging-routes or TC routing

To use only logging-routes (This is the default behaviour!):

- Don't set anything.

```yaml
apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
spec:
routeConfig:
enableTelemetryControllerRoute: false
disableLoggingRoute: false
```
To use logging-routes and TC routing in parallel:
```yaml
apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
spec:
routeConfig:
enableTelemetryControllerRoute: true
disableLoggingRoute: false
```
To use only TC routing:
```yaml
apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
spec:
routeConfig:
enableTelemetryControllerRoute: true
disableLoggingRoute: true
```
NOTE: You can change these setting on the fly, the only requirement is to have the necessary components deployed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: v1
kind: Namespace
metadata:
name: customer-a
labels:
tenant: customer-a
---
apiVersion: v1
kind: Namespace
metadata:
name: customer-a-infra
---
apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
metadata:
name: customer-a
labels:
tenant: customer-a
spec:
fluentd:
disablePvc: true
logLevel: trace
controlNamespace: customer-a-infra
watchNamespaceSelector:
matchLabels:
tenant: customer-a
routeConfig:
enableTelemetryControllerRoute: false
disableLoggingRoute: false
tenantLabels:
tenant: customer-a
---
apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
name: all
namespace: customer-a
spec:
match:
- select:
labels:
app.kubernetes.io/name: log-generator
localOutputRefs:
- http-a
---
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
name: http-a
namespace: customer-a
spec:
http:
endpoint: http://logging-operator-test-receiver.logging:8080/customer-a
content_type: application/json
buffer:
type: memory
tags: time
timekey: 1s
timekey_wait: 0s
Loading

0 comments on commit 23d4606

Please sign in to comment.