Skip to content

Commit 72dc12b

Browse files
committed
NETOBSERV-2429: add UI schema for consumer replicas
- Add unmanagedReplicas / consumerReplicas - Hide autoscalers & deprecated settings - Some reordering in processor schema - Add a note in README describing what should be done when updating CRDs
1 parent 215e805 commit 72dc12b

File tree

7 files changed

+89
-258
lines changed

7 files changed

+89
-258
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,19 @@ make cypress
178178
```
179179

180180
4. Click on "Run N integration specs"
181+
182+
## Updating schemas
183+
184+
This console plugin comes with several panels allowing GUI-based configuration for `FlowCollector` and other managed resources, including:
185+
186+
- Comprehensive forms for each of the resources (includes most supported settings that are pretty common to configure).
187+
- Simplified wizards for faster configuration.
188+
189+
When you update the operator CRDs, you may have to update some schemas here as well, which contain some rules that drive how forms are displayed. Especially:
190+
191+
- [uiSchema.ts](./web/src/components/forms/config/uiSchema.ts) contains a display-oriented description of every CRD field, including whether or not they should be hidden, or if they have relationships with other fields.
192+
- [< CRD name >-wizard.tsx](./web/src/components/forms/flowCollector-wizard.tsx) contains specific fields to be displayed in wizards.
193+
194+
When a CRD field is added, consider whether you need to update these files.
195+
196+
Additionally, [schema.ts](./web/moduleMapper/schemas.ts) contains the full CRD schema as JSON, used in tests and in standalone mode, and should also be kept up to date.

web/moduleMapper/dummy.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// File only used in tests or dev console
2+
13
/* eslint-disable @typescript-eslint/no-unused-vars */
24
/* eslint-disable @typescript-eslint/no-explicit-any */
35
import {
@@ -18,8 +20,8 @@ import { useK8sModelsWithColors } from '../src/utils/k8s-models-hook';
1820
import { useTheme } from '../src/utils/theme-hook';
1921
import { safeJSToYAML } from '../src/utils/yaml';
2022
import { k8sModels } from './k8s-models';
21-
import { FlowCollectorSchema, FlowMetricSchema } from './schemas';
22-
import { GetFlowCollectorJS, GetFlowMetricJS } from './templates';
23+
import { flowCollectorSchema, flowMetricSchema } from './schemas';
24+
import { getFlowCollectorJS, getFlowMetricJS } from './templates';
2325

2426
// This dummy file is used to resolve @Console imports from @openshift-console for JEST / Standalone
2527
// You can add any exports needed here
@@ -130,7 +132,7 @@ export function useK8sWatchResource(req: any) {
130132
served: true,
131133
storage: true,
132134
schema: {
133-
openAPIV3Schema: FlowCollectorSchema,
135+
openAPIV3Schema: flowCollectorSchema,
134136
}
135137
}]
136138
}
@@ -154,15 +156,15 @@ export function useK8sWatchResource(req: any) {
154156
served: true,
155157
storage: true,
156158
schema: {
157-
openAPIV3Schema: FlowMetricSchema
159+
openAPIV3Schema: flowMetricSchema
158160
}
159161
}]
160162
}
161163
});
162164
}
163165
break;
164166
case 'FlowCollector':
165-
const fc = _.cloneDeep(GetFlowCollectorJS());
167+
const fc = _.cloneDeep(getFlowCollectorJS());
166168
fc.spec!.loki.enable = false;
167169
fc.spec!.exporters = [{ type: "Kafka" }, { type: "OpenTelemetry" }]
168170
fc.status = {
@@ -236,7 +238,7 @@ export function useK8sWatchResource(req: any) {
236238
break;
237239
case 'FlowMetric':
238240
if (req.name === 'flowmetric-sample') {
239-
const fm = _.cloneDeep(GetFlowMetricJS());
241+
const fm = _.cloneDeep(getFlowMetricJS());
240242
fm.spec!.metricName = 'test_metric';
241243
setResource(fm);
242244
}

web/moduleMapper/k8s-models.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//these values comes from original useK8sModels using debug
1+
// File only used in tests or dev console
2+
3+
// These values come from original useK8sModels using debug
24
export const k8sModels = {
35
"ImageStreamImport": {
46
"label": "ImageStreamImport",

web/moduleMapper/schemas.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
// File only used in tests or dev console
2+
13
/* eslint-disable @typescript-eslint/no-explicit-any */
24
/* eslint-disable max-len */
35
import { RJSFSchema } from '@rjsf/utils';
46

5-
export const FlowCollectorSchema: RJSFSchema | any = {
7+
// flowCollectorSchema is only used in tests or dev console
8+
export const flowCollectorSchema: RJSFSchema | any = {
69
title: 'FlowCollector',
710
description:
811
'The schema for the network flows collection API, which pilots and configures the underlying deployments.',
@@ -51,10 +54,10 @@ export const FlowCollectorSchema: RJSFSchema | any = {
5154
},
5255
deploymentModel: {
5356
description:
54-
'`deploymentModel` defines the desired type of deployment for flow processing. Possible values are:\n- `Direct` (default) to make the flow processor listen directly from the agents.\n- `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.\nKafka can provide better scalability, resiliency, and high availability (for more details, see https://www.redhat.com/en/topics/integration/what-is-apache-kafka).',
57+
'`deploymentModel` defines the desired type of deployment for flow processing. Possible values are:\n - `Direct` (default) to make the flow processor listen directly from the agents using the host network, backed by a DaemonSet.\n - `Service` to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.\n - `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.\n Kafka can provide better scalability, resiliency, and high availability (for more details, see https://www.redhat.com/en/topics/integration/what-is-apache-kafka).<br> `Direct` is not recommended on large clusters as it is less memory efficient.',
5558
type: 'string',
5659
default: 'Direct',
57-
enum: ['Direct', 'Kafka']
60+
enum: ['Direct', 'Service', 'Kafka']
5861
},
5962
kafka: {
6063
description:
@@ -3329,9 +3332,21 @@ export const FlowCollectorSchema: RJSFSchema | any = {
33293332
default: 'Flows',
33303333
enum: ['Flows', 'Conversations', 'EndedConversations', 'All']
33313334
},
3335+
unmanagedReplicas: {
3336+
description:
3337+
'If `unmanagedReplicas` is `true`, the operator will not reconcile `consumerReplicas`. This is useful when using a pod autoscaler.',
3338+
type: 'boolean'
3339+
},
3340+
consumerReplicas: {
3341+
description:
3342+
'`consumerReplicas` defines the number of replicas (pods) to start for `flowlogs-pipeline`, default is 3. This setting is ignored when `spec.deploymentModel` is `Direct` or when `spec.processor.unmanagedReplicas` is `true`.',
3343+
type: 'integer',
3344+
format: 'int32',
3345+
minimum: 0
3346+
},
33323347
kafkaConsumerReplicas: {
33333348
description:
3334-
'`kafkaConsumerReplicas` defines the number of replicas (pods) to start for `flowlogs-pipeline-transformer`, which consumes Kafka messages.\nThis setting is ignored when Kafka is disabled.',
3349+
'`kafkaConsumerAutoscaler` [deprecated (*)] is the spec of a horizontal pod autoscaler to set up for `flowlogs-pipeline-transformer`, which consumes Kafka messages. This setting is ignored when Kafka is disabled. Deprecation notice: managed autoscaler will be removed in a future version. You may configure instead an autoscaler of your choice, and set `spec.processor.unmanagedReplicas` to `true`.',
33353350
type: 'integer',
33363351
format: 'int32',
33373352
default: 3,
@@ -5127,7 +5142,7 @@ export const FlowCollectorSchema: RJSFSchema | any = {
51275142
enum: ['IfNotPresent', 'Always', 'Never']
51285143
},
51295144
autoscaler: {
5130-
description: '`autoscaler` spec of a horizontal pod autoscaler to set up for the plugin Deployment.',
5145+
description: '`autoscaler` [deprecated (*)] spec of a horizontal pod autoscaler to set up for the plugin Deployment. Deprecation notice: managed autoscaler will be removed in a future version. You may configure instead an autoscaler of your choice, and set `spec.consolePlugin.unmanagedReplicas` to `true`.',
51315146
type: 'object',
51325147
properties: {
51335148
maxReplicas: {
@@ -5547,6 +5562,10 @@ export const FlowCollectorSchema: RJSFSchema | any = {
55475562
}
55485563
}
55495564
},
5565+
unmanagedReplicas: {
5566+
description: 'If `unmanagedReplicas` is `true`, the operator will not reconcile `replicas`. This is useful when using a pod autoscaler.',
5567+
type: 'boolean',
5568+
},
55505569
replicas: {
55515570
description: '`replicas` defines the number of replicas (pods) to start.',
55525571
type: 'integer',
@@ -5936,7 +5955,8 @@ export const FlowCollectorSchema: RJSFSchema | any = {
59365955
}
59375956
};
59385957

5939-
export const FlowMetricSchema: RJSFSchema | any = {
5958+
// flowMetricSchema is only used in tests or dev console
5959+
export const flowMetricSchema: RJSFSchema | any = {
59405960
title: 'FlowMetric',
59415961
description: 'The API allowing to create custom metrics from the collected flow logs.',
59425962
type: 'object',
@@ -6127,4 +6147,4 @@ export const FlowMetricSchema: RJSFSchema | any = {
61276147
}
61286148
}
61296149
}
6130-
};
6150+
};

web/moduleMapper/templates.ts

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// File only used in tests or dev console
2+
13
import { K8sResourceKind } from '@openshift-console/dynamic-plugin-sdk';
24
import { safeYAMLToJS } from '../src/utils/yaml';
35

4-
export const FlowCollector = `
6+
const flowCollector = `
57
apiVersion: flows.netobserv.io/v1beta2
68
kind: FlowCollector
79
metadata:
@@ -123,60 +125,15 @@ spec:
123125
`;
124126

125127
let flowCollectorJS: K8sResourceKind | null = null;
126-
export const GetFlowCollectorJS = (): K8sResourceKind => {
128+
export const getFlowCollectorJS = (): K8sResourceKind => {
127129
if (flowCollectorJS === null) {
128-
flowCollectorJS = safeYAMLToJS(FlowCollector);
130+
flowCollectorJS = safeYAMLToJS(flowCollector);
129131
}
130132
return flowCollectorJS!;
131133
};
132134

133-
export const FlowMetric = `
134-
apiVersion: flows.netobserv.io/v1alpha1
135-
kind: FlowMetric
136-
metadata:
137-
labels:
138-
app.kubernetes.io/name: flowmetric
139-
app.kubernetes.io/instance: flowmetric-sample
140-
app.kubernetes.io/part-of: netobserv-operator
141-
app.kubernetes.io/managed-by: kustomize
142-
app.kubernetes.io/created-by: netobserv-operator
143-
name: flowmetric-sample
144-
namespace: netobserv
145-
spec:
146-
metricName: cluster_external_ingress_bytes_total
147-
type: Counter
148-
valueField: Bytes
149-
direction: Ingress
150-
labels:
151-
- DstK8S_HostName
152-
- DstK8S_Namespace
153-
- DstK8S_OwnerName
154-
- DstK8S_OwnerType
155-
filters:
156-
- field: SrcSubnetLabel
157-
matchType: Absence
158-
charts:
159-
- dashboardName: Main
160-
title: External ingress traffic
161-
unit: Bps
162-
type: SingleStat
163-
queries:
164-
- promQL: 'sum(rate($METRIC[2m]))'
165-
legend: ''
166-
- dashboardName: Main
167-
sectionName: External
168-
title: Top external ingress traffic per workload
169-
unit: Bps
170-
type: StackArea
171-
queries:
172-
- promQL: >-
173-
sum(rate($METRIC{DstK8S_Namespace!=""}[2m])) by (DstK8S_Namespace,
174-
DstK8S_OwnerName)
175-
legend: '{{DstK8S_Namespace}} / {{DstK8S_OwnerName}}'
176-
`;
177-
178135
// use an alternative sample for forms to avoid forcing the user to remove the filters / queries
179-
export const FlowMetricDefaultForm = `
136+
export const flowMetricDefaultForm = `
180137
apiVersion: flows.netobserv.io/v1alpha1
181138
kind: FlowMetric
182139
metadata:
@@ -189,9 +146,9 @@ spec:
189146
`;
190147

191148
let flowMetricJS: K8sResourceKind | null = null;
192-
export const GetFlowMetricJS = (): K8sResourceKind => {
149+
export const getFlowMetricJS = (): K8sResourceKind => {
193150
if (flowMetricJS === null) {
194-
flowMetricJS = safeYAMLToJS(FlowMetricDefaultForm);
151+
flowMetricJS = safeYAMLToJS(flowMetricDefaultForm);
195152
}
196153
return flowMetricJS!;
197154
};

0 commit comments

Comments
 (0)