Skip to content

Commit be1847a

Browse files
committed
Back to a single Service mode
Always use TLS, except if SERVER_NOTLS env is set on FLP
1 parent ef550e2 commit be1847a

13 files changed

+53
-63
lines changed

api/flowcollector/v1beta2/flowcollector_types.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ import (
2727
type FlowCollectorDeploymentModel string
2828

2929
const (
30-
DeploymentModelDirect FlowCollectorDeploymentModel = "Direct"
31-
DeploymentModelKafka FlowCollectorDeploymentModel = "Kafka"
32-
DeploymentModelServiceNoTLS FlowCollectorDeploymentModel = "Service-NoTLS"
33-
DeploymentModelServiceTLS FlowCollectorDeploymentModel = "Service-TLS"
30+
DeploymentModelDirect FlowCollectorDeploymentModel = "Direct"
31+
DeploymentModelKafka FlowCollectorDeploymentModel = "Kafka"
32+
DeploymentModelService FlowCollectorDeploymentModel = "Service"
3433
)
3534

3635
// Please notice that the FlowCollectorSpec's properties MUST redefine one of the default
@@ -71,15 +70,14 @@ type FlowCollectorSpec struct {
7170
ConsolePlugin FlowCollectorConsolePlugin `json:"consolePlugin,omitempty"`
7271

7372
// `deploymentModel` defines the desired type of deployment for flow processing. Possible values are:<br>
74-
// - `Service-TLS` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
75-
// - `Service-NoTLS` to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment. Version without TLS.<br>
73+
// - `Service` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
7674
// - `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.<br>
7775
// - `Direct` to make the flow processor listen directly from the agents using the host network, backed by a DaemonSet. Only recommended on small clusters, below 15 nodes.<br>
7876
// 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>
7977
// `Direct` is not recommended on large clusters as it is less memory efficient.
8078
// +unionDiscriminator
81-
// +kubebuilder:validation:Enum:="Service-TLS";"Service-NoTLS";"Direct";"Kafka"
82-
// +kubebuilder:default:=Service-TLS
79+
// +kubebuilder:validation:Enum:="Service";"Direct";"Kafka"
80+
// +kubebuilder:default:=Service
8381
DeploymentModel FlowCollectorDeploymentModel `json:"deploymentModel,omitempty"`
8482

8583
// Kafka configuration, allowing to use Kafka as a broker as part of the flow collection pipeline. Available when the `spec.deploymentModel` is `Kafka`.

api/flowcollector/v1beta2/flowcollector_validation_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (v *validator) validateFLPLogTypes() {
276276
if !v.fc.UseLoki() {
277277
v.errors = append(v.errors, errors.New("enabling conversation tracking without Loki is not allowed, as it generates extra processing for no benefit"))
278278
}
279-
if v.fc.UseServiceNetwork() {
279+
if v.fc.DeploymentModel == DeploymentModelService {
280280
v.errors = append(v.errors, errors.New("cannot enable conversation tracking when spec.deploymentModel is Service: you must disable it, or change the deployment model"))
281281
}
282282
}

api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ func TestValidateConntrack(t *testing.T) {
516516
Name: "cluster",
517517
},
518518
Spec: FlowCollectorSpec{
519-
DeploymentModel: DeploymentModelServiceNoTLS,
519+
DeploymentModel: DeploymentModelService,
520520
Processor: FlowCollectorFLP{
521521
LogTypes: ptr.To(LogTypeConversations),
522522
},

api/flowcollector/v1beta2/helper.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ func (spec *FlowCollectorSpec) UseConsolePlugin() bool {
5555

5656
func (spec *FlowCollectorSpec) UseTestConsolePlugin() bool {
5757
if spec.ConsolePlugin.Advanced != nil {
58-
env := spec.ConsolePlugin.Advanced.Env[constants.EnvTestConsole]
59-
// Use ParseBool to allow common variants ("true", "True", "1"...) and ignore non-bools
60-
b, err := strconv.ParseBool(env)
61-
return err == nil && b
58+
return IsEnvEnabled(spec.ConsolePlugin.Advanced.Env, constants.EnvTestConsole)
6259
}
6360
return false
6461
}
@@ -67,11 +64,6 @@ func (spec *FlowCollectorSpec) UseHostNetwork() bool {
6764
return spec.DeploymentModel == DeploymentModelDirect
6865
}
6966

70-
func (spec *FlowCollectorSpec) UseServiceNetwork() bool {
71-
return spec.DeploymentModel == DeploymentModelServiceNoTLS ||
72-
spec.DeploymentModel == DeploymentModelServiceTLS
73-
}
74-
7567
func (spec *FlowCollectorEBPF) IsAgentFeatureEnabled(feature AgentFeature) bool {
7668
for _, f := range spec.Features {
7769
if f == feature {
@@ -190,10 +182,7 @@ func (spec *FlowCollectorFLP) GetMetricsPort() int32 {
190182

191183
func (spec *FlowCollectorSpec) HasExperimentalAlertsHealth() bool {
192184
if spec.Processor.Advanced != nil {
193-
env := spec.Processor.Advanced.Env["EXPERIMENTAL_ALERTS_HEALTH"]
194-
// Use ParseBool to allow common variants ("true", "True", "1"...) and ignore non-bools
195-
b, err := strconv.ParseBool(env)
196-
return err == nil && b
185+
return IsEnvEnabled(spec.Processor.Advanced.Env, "EXPERIMENTAL_ALERTS_HEALTH")
197186
}
198187
return false
199188
}
@@ -232,3 +221,10 @@ func (spec *FlowCollectorConsolePlugin) IsUnmanagedConsolePluginReplicas() bool
232221
}
233222
return spec.Autoscaler.IsHPAEnabled()
234223
}
224+
225+
func IsEnvEnabled(vars map[string]string, key string) bool {
226+
env := vars[key]
227+
// Use ParseBool to allow common variants ("true", "True", "1"...) and ignore non-bools
228+
b, err := strconv.ParseBool(env)
229+
return err == nil && b
230+
}

bundle/manifests/flows.netobserv.io_flowcollectors.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,18 +3217,16 @@ spec:
32173217
type: boolean
32183218
type: object
32193219
deploymentModel:
3220-
default: Service-TLS
3220+
default: Service
32213221
description: |-
32223222
`deploymentModel` defines the desired type of deployment for flow processing. Possible values are:<br>
3223-
- `Service-TLS` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
3224-
- `Service-NoTLS` to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment. Version without TLS.<br>
3223+
- `Service` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
32253224
- `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.<br>
32263225
- `Direct` to make the flow processor listen directly from the agents using the host network, backed by a DaemonSet. Only recommended on small clusters, below 15 nodes.<br>
32273226
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>
32283227
`Direct` is not recommended on large clusters as it is less memory efficient.
32293228
enum:
3230-
- Service-TLS
3231-
- Service-NoTLS
3229+
- Service
32323230
- Direct
32333231
- Kafka
32343232
type: string

config/crd/bases/flows.netobserv.io_flowcollectors.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,18 +3011,16 @@ spec:
30113011
type: boolean
30123012
type: object
30133013
deploymentModel:
3014-
default: Service-TLS
3014+
default: Service
30153015
description: |-
30163016
`deploymentModel` defines the desired type of deployment for flow processing. Possible values are:<br>
3017-
- `Service-TLS` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
3018-
- `Service-NoTLS` to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment. Version without TLS.<br>
3017+
- `Service` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
30193018
- `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.<br>
30203019
- `Direct` to make the flow processor listen directly from the agents using the host network, backed by a DaemonSet. Only recommended on small clusters, below 15 nodes.<br>
30213020
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>
30223021
`Direct` is not recommended on large clusters as it is less memory efficient.
30233022
enum:
3024-
- Service-TLS
3025-
- Service-NoTLS
3023+
- Service
30263024
- Direct
30273025
- Kafka
30283026
type: string

docs/FlowCollector.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,14 @@ for these features as a best effort only.
112112
<td>enum</td>
113113
<td>
114114
`deploymentModel` defines the desired type of deployment for flow processing. Possible values are:<br>
115-
- `Service-TLS` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
116-
- `Service-NoTLS` to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment. Version without TLS.<br>
115+
- `Service` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
117116
- `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.<br>
118117
- `Direct` to make the flow processor listen directly from the agents using the host network, backed by a DaemonSet. Only recommended on small clusters, below 15 nodes.<br>
119118
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>
120119
`Direct` is not recommended on large clusters as it is less memory efficient.<br/>
121120
<br/>
122-
<i>Enum</i>: Service-TLS, Service-NoTLS, Direct, Kafka<br/>
123-
<i>Default</i>: Service-TLS<br/>
121+
<i>Enum</i>: Service, Direct, Kafka<br/>
122+
<i>Default</i>: Service<br/>
124123
</td>
125124
<td>false</td>
126125
</tr><tr>

helm/crds/flows.netobserv.io_flowcollectors.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,18 +3015,16 @@ spec:
30153015
type: boolean
30163016
type: object
30173017
deploymentModel:
3018-
default: Service-TLS
3018+
default: Service
30193019
description: |-
30203020
`deploymentModel` defines the desired type of deployment for flow processing. Possible values are:<br>
3021-
- `Service-TLS` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
3022-
- `Service-NoTLS` to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment. Version without TLS.<br>
3021+
- `Service` (default) to make the flow processor listen as a Kubernetes Service, backed by a scalable Deployment.<br>
30233022
- `Kafka` to make flows sent to a Kafka pipeline before consumption by the processor.<br>
30243023
- `Direct` to make the flow processor listen directly from the agents using the host network, backed by a DaemonSet. Only recommended on small clusters, below 15 nodes.<br>
30253024
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>
30263025
`Direct` is not recommended on large clusters as it is less memory efficient.
30273026
enum:
3028-
- Service-TLS
3029-
- Service-NoTLS
3027+
- Service
30303028
- Direct
30313029
- Kafka
30323030
type: string

internal/controller/ebpf/agent_controller.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ func (c *AgentController) envConfig(ctx context.Context, coll *flowslatest.FlowC
482482
Value: strconv.Itoa(int(*advancedConfig.Port)),
483483
})
484484
} else {
485-
// Send to FLP service...
486-
if coll.Spec.DeploymentModel == flowslatest.DeploymentModelServiceTLS {
487-
// ... using TLS
485+
skipTLS := flowslatest.IsEnvEnabled(advancedConfig.Env, "SERVER_NOTLS")
486+
if !skipTLS {
487+
// Send to FLP service using TLS
488488
tlsCfg := flowslatest.ClientTLS{
489489
Enable: true,
490490
CACert: flowslatest.CertificateReference{
@@ -496,13 +496,16 @@ func (c *AgentController) envConfig(ctx context.Context, coll *flowslatest.FlowC
496496
caPath := c.volumes.AddCACertificate(&tlsCfg, "svc-certs")
497497
config = append(config, corev1.EnvVar{Name: envTargetTLSCACertPath, Value: caPath})
498498
}
499-
config = append(config, corev1.EnvVar{
500-
Name: envFlowsTargetHost,
501-
Value: fmt.Sprintf("%s.%s.svc", constants.FLPName, c.Namespace),
502-
}, corev1.EnvVar{
503-
Name: envFlowsTargetPort,
504-
Value: strconv.Itoa(int(*advancedConfig.Port)),
505-
})
499+
config = append(config,
500+
corev1.EnvVar{
501+
Name: envFlowsTargetHost,
502+
Value: fmt.Sprintf("%s.%s.svc", constants.FLPName, c.Namespace),
503+
},
504+
corev1.EnvVar{
505+
Name: envFlowsTargetPort,
506+
Value: strconv.Itoa(int(*advancedConfig.Port)),
507+
},
508+
)
506509
}
507510
}
508511

internal/controller/ebpf/agent_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ func TestBpfmanConfig(t *testing.T) {
214214
assert.NotNil(t, ds)
215215

216216
assert.Equal(t, corev1.EnvVar{Name: "EBPF_PROGRAM_MANAGER_MODE", Value: "true"}, ds.Spec.Template.Spec.Containers[0].Env[0])
217-
assert.Equal(t, "bpfman-maps", ds.Spec.Template.Spec.Volumes[0].Name)
217+
assert.Equal(t, "bpfman-maps", ds.Spec.Template.Spec.Volumes[1].Name)
218218
assert.Equal(t, map[string]string{
219219
"csi.bpfman.io/maps": "direct_flows,aggregated_flows,additional_flow_metrics,packet_record,dns_flows,global_counters,filter_map,peer_filter_map,ipsec_ingress_map,ipsec_egress_map",
220220
"csi.bpfman.io/program": "netobserv",
221-
}, ds.Spec.Template.Spec.Volumes[0].CSI.VolumeAttributes)
221+
}, ds.Spec.Template.Spec.Volumes[1].CSI.VolumeAttributes)
222222
}

0 commit comments

Comments
 (0)