Skip to content

Commit 5d1a524

Browse files
committed
docs: add tc-routing sample
Signed-off-by: Bence Csati <bence.csati@axoflow.com>
1 parent 26d3ee2 commit 5d1a524

File tree

5 files changed

+318
-0
lines changed

5 files changed

+318
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# TC-routing
2+
3+
## Setup
4+
5+
```shell
6+
make kind-cluster
7+
make docker-build
8+
kind load docker-image controller:local
9+
10+
helm upgrade --install \
11+
--wait \
12+
--create-namespace \
13+
--namespace logging \
14+
logging-operator ./charts/logging-operator/ \
15+
--set image.repository=controller \
16+
--set image.tag=local \
17+
--set extraArgs='{"-enable-leader-election=true","-enable-telemetry-controller-route"}' \
18+
--set telemetry-controller.install=true \
19+
--set testReceiver.enabled=true
20+
21+
kubectl apply -f config/samples/telemetry-controller-routing/
22+
23+
helm upgrade --install --namespace customer-a log-generator oci://ghcr.io/kube-logging/helm-charts/log-generator
24+
helm upgrade --install --namespace customer-b log-generator oci://ghcr.io/kube-logging/helm-charts/log-generator
25+
helm upgrade --install --namespace infra log-generator oci://ghcr.io/kube-logging/helm-charts/log-generator
26+
```
27+
28+
## Switching between logging-routes or TC routing
29+
30+
To use only logging-routes (This is the default behaviour!):
31+
32+
- Don't set anything.
33+
34+
```yaml
35+
apiVersion: logging.banzaicloud.io/v1beta1
36+
kind: Logging
37+
spec:
38+
routeConfig:
39+
enableTelemetryControllerRoute: false
40+
disableLoggingRoute: false
41+
```
42+
43+
To use logging-routes and TC routing in parallel:
44+
45+
```yaml
46+
apiVersion: logging.banzaicloud.io/v1beta1
47+
kind: Logging
48+
spec:
49+
routeConfig:
50+
enableTelemetryControllerRoute: true
51+
disableLoggingRoute: false
52+
```
53+
54+
To use only TC routing:
55+
56+
```yaml
57+
apiVersion: logging.banzaicloud.io/v1beta1
58+
kind: Logging
59+
spec:
60+
routeConfig:
61+
enableTelemetryControllerRoute: true
62+
disableLoggingRoute: true
63+
```
64+
65+
NOTE: You can change these setting on the fly, the only requirement is to have the necessary components deployed.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: customer-a
5+
labels:
6+
tenant: customer-a
7+
---
8+
apiVersion: v1
9+
kind: Namespace
10+
metadata:
11+
name: customer-a-infra
12+
---
13+
apiVersion: logging.banzaicloud.io/v1beta1
14+
kind: Logging
15+
metadata:
16+
name: customer-a
17+
labels:
18+
tenant: customer-a
19+
spec:
20+
fluentd:
21+
disablePvc: true
22+
logLevel: trace
23+
controlNamespace: customer-a-infra
24+
watchNamespaceSelector:
25+
matchLabels:
26+
tenant: customer-a
27+
routeConfig:
28+
enableTelemetryControllerRoute: true
29+
disableLoggingRoute: true
30+
tenantLabels:
31+
tenant: customer-a
32+
---
33+
apiVersion: logging.banzaicloud.io/v1beta1
34+
kind: Flow
35+
metadata:
36+
name: all
37+
namespace: customer-a
38+
spec:
39+
match:
40+
- select:
41+
labels:
42+
app.kubernetes.io/name: log-generator
43+
localOutputRefs:
44+
- http-a
45+
---
46+
apiVersion: logging.banzaicloud.io/v1beta1
47+
kind: Output
48+
metadata:
49+
name: http-a
50+
namespace: customer-a
51+
spec:
52+
http:
53+
endpoint: http://logging-operator-test-receiver.logging:8080
54+
content_type: application/json
55+
buffer:
56+
type: memory
57+
tags: time
58+
timekey: 1s
59+
timekey_wait: 0s
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: customer-b
5+
labels:
6+
tenant: customer-b
7+
---
8+
apiVersion: v1
9+
kind: Namespace
10+
metadata:
11+
name: customer-b-infra
12+
---
13+
apiVersion: logging.banzaicloud.io/v1beta1
14+
kind: Logging
15+
metadata:
16+
name: customer-b
17+
labels:
18+
tenant: customer-b
19+
spec:
20+
fluentd:
21+
disablePvc: true
22+
logLevel: trace
23+
controlNamespace: customer-b-infra
24+
watchNamespaceSelector:
25+
matchLabels:
26+
tenant: customer-b
27+
routeConfig:
28+
enableTelemetryControllerRoute: true
29+
disableLoggingRoute: true
30+
tenantLabels:
31+
tenant: customer-b
32+
---
33+
apiVersion: logging.banzaicloud.io/v1beta1
34+
kind: Flow
35+
metadata:
36+
name: all
37+
namespace: customer-b
38+
spec:
39+
match:
40+
- select:
41+
labels:
42+
app.kubernetes.io/name: log-generator
43+
localOutputRefs:
44+
- http-b
45+
---
46+
apiVersion: logging.banzaicloud.io/v1beta1
47+
kind: Output
48+
metadata:
49+
name: http-b
50+
namespace: customer-b
51+
spec:
52+
http:
53+
endpoint: http://logging-operator-test-receiver.logging:8080
54+
content_type: application/json
55+
buffer:
56+
type: memory
57+
tags: time
58+
timekey: 1s
59+
timekey_wait: 0s
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
apiVersion: telemetry.kube-logging.dev/v1alpha1
2+
kind: Collector
3+
metadata:
4+
name: cluster
5+
spec:
6+
controlNamespace: infra
7+
debug: true
8+
tenantSelector:
9+
matchExpressions:
10+
- key: tenant
11+
operator: Exists
12+
---
13+
apiVersion: v1
14+
kind: Namespace
15+
metadata:
16+
name: infra
17+
labels:
18+
tenant: infra
19+
---
20+
apiVersion: logging.banzaicloud.io/v1beta1
21+
kind: Logging
22+
metadata:
23+
name: infra
24+
labels:
25+
tenant: infra
26+
spec:
27+
loggingRef: infra
28+
fluentd:
29+
disablePvc: true
30+
logLevel: trace
31+
controlNamespace: infra
32+
watchNamespaceSelector:
33+
matchLabels:
34+
tenant: infra
35+
routeConfig:
36+
enableTelemetryControllerRoute: true
37+
disableLoggingRoute: true
38+
tenantLabels:
39+
tenant: infra
40+
---
41+
apiVersion: logging.banzaicloud.io/v1beta1
42+
kind: ClusterFlow
43+
metadata:
44+
name: all
45+
namespace: infra
46+
spec:
47+
loggingRef: infra
48+
match:
49+
- select:
50+
labels:
51+
app.kubernetes.io/name: log-generator
52+
globalOutputRefs:
53+
- http-infra
54+
---
55+
apiVersion: logging.banzaicloud.io/v1beta1
56+
kind: ClusterOutput
57+
metadata:
58+
name: http-infra
59+
namespace: infra
60+
spec:
61+
loggingRef: infra
62+
http:
63+
endpoint: http://test-receiver.infra:8080/infra
64+
content_type: application/json
65+
buffer:
66+
type: memory
67+
timekey: 1s
68+
timekey_wait: 0s
69+
---
70+
apiVersion: logging.banzaicloud.io/v1beta1
71+
kind: FluentbitAgent
72+
metadata:
73+
name: infra
74+
spec:
75+
loggingRef: infra
76+
inputTail:
77+
storage.type: filesystem
78+
positiondb:
79+
hostPath:
80+
path: ""
81+
bufferStorageVolume:
82+
hostPath:
83+
path: ""
84+
network:
85+
connectTimeout: 2
86+
metrics: {}
87+
---
88+
apiVersion: logging.banzaicloud.io/v1beta1
89+
kind: LoggingRoute
90+
metadata:
91+
name: tenants
92+
spec:
93+
source: infra
94+
targets:
95+
matchExpressions:
96+
- key: tenant
97+
operator: Exists
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: test-receiver
5+
namespace: infra
6+
spec:
7+
type: ClusterIP
8+
ports:
9+
- port: 8080
10+
targetPort: receiver
11+
protocol: TCP
12+
name: receiver
13+
selector:
14+
app.kubernetes.io/name: test-receiver
15+
---
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
metadata:
19+
name: test-receiver
20+
namespace: infra
21+
spec:
22+
selector:
23+
matchLabels:
24+
app.kubernetes.io/name: test-receiver
25+
template:
26+
metadata:
27+
labels:
28+
app.kubernetes.io/name: test-receiver
29+
annotations:
30+
fluentbit.io/exclude: "true"
31+
spec:
32+
containers:
33+
- name: fluentbit
34+
image: fluent/fluent-bit
35+
args: ["-i", "http", "-p", "port=8080", "-o", "stdout"]
36+
ports:
37+
- name: receiver
38+
containerPort: 8080

0 commit comments

Comments
 (0)