Skip to content

Commit 1cf4f8f

Browse files
committed
wip
1 parent 518e1fd commit 1cf4f8f

File tree

5 files changed

+351
-1
lines changed

5 files changed

+351
-1
lines changed

web/console-extensions.json

+46
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,51 @@
287287
"$codeRef": "netflowDevTab.default"
288288
}
289289
}
290+
},
291+
{
292+
"type": "console.yaml-template",
293+
"properties": {
294+
"model": {
295+
"version": "v1beta2",
296+
"group": "flows.netobserv.io",
297+
"kind": "FlowCollector"
298+
},
299+
"name": "default",
300+
"template": {
301+
"$codeRef": "yamlTemplates.FlowCollector"
302+
}
303+
}
304+
},
305+
{
306+
"type": "console.page/route",
307+
"properties": {
308+
"path": "/k8s/cluster/flows.netobserv.io~v1beta2~FlowCollector/~new/form",
309+
"component": {
310+
"$codeRef": "flowCollectorForm.default"
311+
}
312+
}
313+
},
314+
{
315+
"type": "console.yaml-template",
316+
"properties": {
317+
"model": {
318+
"version": "v1alpha1",
319+
"group": "flows.netobserv.io",
320+
"kind": "FlowMetric"
321+
},
322+
"name": "default",
323+
"template": {
324+
"$codeRef": "yamlTemplates.FlowMetric"
325+
}
326+
}
327+
},
328+
{
329+
"type": "console.page/route",
330+
"properties": {
331+
"path": "/k8s/cluster/flows.netobserv.io~v1alpha1~FlowMetric/~new/form",
332+
"component": {
333+
"$codeRef": "flowMetricForm.default"
334+
}
335+
}
290336
}
291337
]

web/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@
9696
"exposedModules": {
9797
"netflowParent": "./components/netflow-traffic-parent.tsx",
9898
"netflowTab": "./components/netflow-traffic-tab.tsx",
99-
"netflowDevTab": "./components/netflow-traffic-dev-tab.tsx"
99+
"netflowDevTab": "./components/netflow-traffic-dev-tab.tsx",
100+
"yamlTemplates": "./components/forms/templates.ts",
101+
"flowCollectorForm": "./components/forms/flowCollector.tsx",
102+
"flowMetricForm": "./components/forms/flowMetric.tsx"
103+
100104
},
101105
"dependencies": {
102106
"@console/pluginAPI": "*"
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { FC } from 'react';
2+
3+
import { PageSection, PageSectionVariants } from '@patternfly/react-core';
4+
5+
type UserDefinedNetworkFormProps = {
6+
formData: any;
7+
onChange: (newFormData: any) => void;
8+
};
9+
10+
const FlowCollectorForm: FC<UserDefinedNetworkFormProps> = ({ formData, onChange }) => {
11+
console.log(formData);
12+
return (
13+
<PageSection variant={PageSectionVariants.light}>{'FlowCollector form'}</PageSection>
14+
);
15+
};
16+
17+
export default FlowCollectorForm;
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { FC } from 'react';
2+
3+
import { PageSection, PageSectionVariants } from '@patternfly/react-core';
4+
5+
type UserDefinedNetworkFormProps = {
6+
formData: any;
7+
onChange: (newFormData: any) => void;
8+
};
9+
10+
const FlowMetricForm: FC<UserDefinedNetworkFormProps> = ({ formData, onChange }) => {
11+
console.log(formData);
12+
return (
13+
<PageSection variant={PageSectionVariants.light}>{'FlowMetric form'}</PageSection>
14+
);
15+
};
16+
17+
export default FlowMetricForm;

web/src/components/forms/templates.ts

+266
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
export const FlowCollector = `
2+
apiVersion: flows.netobserv.io/v1beta2
3+
kind: FlowCollector
4+
metadata:
5+
name: cluster
6+
spec:
7+
namespace: netobserv
8+
deploymentModel: Direct
9+
networkPolicy:
10+
enable: false
11+
additionalNamespaces: []
12+
agent:
13+
type: eBPF
14+
ebpf:
15+
imagePullPolicy: IfNotPresent
16+
logLevel: info
17+
sampling: 50
18+
cacheActiveTimeout: 5s
19+
cacheMaxFlows: 100000
20+
# Change privileged to "true" on old kernel version not knowing CAP_BPF or when using "PacketDrop" feature
21+
privileged: false
22+
# features:
23+
# - "PacketDrop"
24+
# - "DNSTracking"
25+
# - "FlowRTT"
26+
# - "NetworkEvents"
27+
# - "PacketTranslation"
28+
# - "EbpfManager"
29+
# - "UDNMapping"
30+
interfaces: []
31+
excludeInterfaces: ["lo"]
32+
kafkaBatchSize: 1048576
33+
#flowFilter:
34+
# enable: true
35+
# rules:
36+
# - action: Accept
37+
# cidr: 0.0.0.0/0
38+
# - action: Accept
39+
# cidr: 10.128.0.1/24
40+
# peerCIDR: 0.0.0.0/0
41+
# ports: 6443
42+
# protocol: TCP
43+
# sampling: 10
44+
# - action: Accept
45+
# cidr: 10.129.0.1/24
46+
# ports: 53
47+
# protocol: UDP
48+
# sampling: 20
49+
# sourcePorts: 443
50+
# - action: Accept
51+
# tcpFlags: "SYN"
52+
# cidr: 2.2.2.2/24
53+
# protocol: TCP
54+
# sourcePorts: 53
55+
metrics:
56+
server:
57+
port: 9400
58+
# Custom optionnal resources configuration
59+
resources:
60+
requests:
61+
memory: 50Mi
62+
cpu: 100m
63+
limits:
64+
memory: 800Mi
65+
kafka:
66+
address: "kafka-cluster-kafka-bootstrap.netobserv"
67+
topic: network-flows
68+
tls:
69+
enable: false
70+
caCert:
71+
type: secret
72+
name: kafka-cluster-cluster-ca-cert
73+
certFile: ca.crt
74+
userCert:
75+
type: secret
76+
name: flp-kafka
77+
certFile: user.crt
78+
certKey: user.key
79+
processor:
80+
imagePullPolicy: IfNotPresent
81+
logLevel: info
82+
# Change logTypes to "Conversations", "EndedConversations" or "All" to enable conversation tracking
83+
logTypes: Flows
84+
# Append a unique cluster name to each record
85+
# clusterName: <CLUSTER NAME>
86+
# addZone: true
87+
# subnetLabels:
88+
# openShiftAutoDetect: true
89+
# customLabels:
90+
# - cidrs: []
91+
# name: ""
92+
metrics:
93+
server:
94+
port: 9401
95+
disableAlerts: []
96+
# includeList:
97+
# - "node_ingress_bytes_total"
98+
# - "workload_ingress_bytes_total"
99+
# - "namespace_flows_total"
100+
# - "namespace_drop_packets_total"
101+
# - "namespace_rtt_seconds"
102+
# Kafka consumer stage configuration
103+
kafkaConsumerReplicas: 3
104+
kafkaConsumerAutoscaler: null
105+
kafkaConsumerQueueCapacity: 1000
106+
kafkaConsumerBatchSize: 10485760
107+
# Custom optionnal resources configuration
108+
resources:
109+
requests:
110+
memory: 100Mi
111+
cpu: 100m
112+
limits:
113+
memory: 800Mi
114+
# deduper:
115+
# mode: Sample
116+
# sampling: 100
117+
# filters:
118+
# - allOf:
119+
# - matchType: Equal
120+
# field: SrcK8S_Namespace
121+
# value: netobserv
122+
# outputTarget: Loki
123+
# sampling: 10
124+
# advanced:
125+
# secondaryNetworks:
126+
# - name: "my-vms/custom-nad"
127+
# # Any of: MAC, IP, Interface
128+
# index: [MAC]
129+
loki:
130+
enable: true
131+
# Change mode to "LokiStack" to use with the loki operator
132+
mode: Monolithic
133+
monolithic:
134+
url: 'http://loki.netobserv.svc:3100/'
135+
tenantID: netobserv
136+
tls:
137+
enable: false
138+
caCert:
139+
type: configmap
140+
name: loki-gateway-ca-bundle
141+
certFile: service-ca.crt
142+
lokiStack:
143+
name: loki
144+
# Change loki operator instance namespace
145+
# namespace: loki-operator
146+
# Console plugin read timeout
147+
readTimeout: 30s
148+
# Write stage configuration
149+
writeTimeout: 10s
150+
writeBatchWait: 1s
151+
writeBatchSize: 10485760
152+
prometheus:
153+
querier:
154+
enable: true
155+
mode: Auto
156+
timeout: 30s
157+
consolePlugin:
158+
enable: true
159+
imagePullPolicy: IfNotPresent
160+
logLevel: info
161+
# Scaling configuration
162+
replicas: 1
163+
autoscaler:
164+
status: Disabled
165+
minReplicas: 1
166+
maxReplicas: 3
167+
metrics:
168+
- type: Resource
169+
resource:
170+
name: cpu
171+
target:
172+
type: Utilization
173+
averageUtilization: 50
174+
# Custom optionnal port-to-service name translation
175+
portNaming:
176+
enable: true
177+
portNames:
178+
"3100": loki
179+
# Custom optionnal filter presets
180+
quickFilters:
181+
- name: Applications
182+
filter:
183+
flow_layer: '"app"'
184+
default: true
185+
- name: Infrastructure
186+
filter:
187+
flow_layer: '"infra"'
188+
- name: Pods network
189+
filter:
190+
src_kind: '"Pod"'
191+
dst_kind: '"Pod"'
192+
default: true
193+
- name: Services network
194+
filter:
195+
dst_kind: '"Service"'
196+
# Custom optionnal resources configuration
197+
resources:
198+
requests:
199+
memory: 50Mi
200+
cpu: 100m
201+
limits:
202+
memory: 100Mi
203+
exporters: []
204+
# - type: Kafka
205+
# kafka:
206+
# address: "kafka-cluster-kafka-bootstrap.netobserv"
207+
# topic: netobserv-flows-export
208+
# or
209+
# - type: IPFIX
210+
# ipfix:
211+
# targetHost: "ipfix-collector.ipfix.svc.cluster.local"
212+
# targetPort: 4739
213+
# transport: TCP or UDP (optional - defaults to TCP)
214+
# or
215+
# - type: OpenTelemetry
216+
# openTelemetry:
217+
# targetHost: "1.2.3.4:443"
218+
# targetPort: 4317
219+
# protocol: grpc
220+
# logs:
221+
# enable: true
222+
# metrics:
223+
# enable: true
224+
# prefix: netobserv
225+
# pushTimeInterval: 20s
226+
# expiryTime: 2m
227+
`;
228+
229+
export const FlowMetric = `
230+
apiVersion: flows.netobserv.io/v1alpha1
231+
kind: FlowMetric
232+
metadata:
233+
labels:
234+
app.kubernetes.io/name: flowmetric
235+
app.kubernetes.io/instance: flowmetric-sample
236+
app.kubernetes.io/part-of: netobserv-operator
237+
app.kubernetes.io/managed-by: kustomize
238+
app.kubernetes.io/created-by: netobserv-operator
239+
name: flowmetric-sample
240+
spec:
241+
# More examples in https://github.com/netobserv/network-observability-operator/tree/main/config/samples/flowmetrics
242+
metricName: cluster_external_ingress_bytes_total
243+
type: Counter
244+
valueField: Bytes
245+
direction: Ingress
246+
labels: [DstK8S_HostName,DstK8S_Namespace,DstK8S_OwnerName,DstK8S_OwnerType]
247+
filters:
248+
- field: SrcSubnetLabel
249+
matchType: Absence
250+
charts:
251+
- dashboardName: Main
252+
title: External ingress traffic
253+
unit: Bps
254+
type: SingleStat
255+
queries:
256+
- promQL: "sum(rate($METRIC[2m]))"
257+
legend: ""
258+
- dashboardName: Main
259+
sectionName: External
260+
title: Top external ingress traffic per workload
261+
unit: Bps
262+
type: StackArea
263+
queries:
264+
- promQL: "sum(rate($METRIC{DstK8S_Namespace!=\"\"}[2m])) by (DstK8S_Namespace, DstK8S_OwnerName)"
265+
legend: "{{DstK8S_Namespace}} / {{DstK8S_OwnerName}}"
266+
`;

0 commit comments

Comments
 (0)