Skip to content
Snippets Groups Projects
Unverified Commit 3a12ba2e authored by Joel Takvorian's avatar Joel Takvorian Committed by GitHub
Browse files

Change HOST/PORT env to TARGET_HOST / TARGET_PORT (#303)

As discussed here: https://github.com/netobserv/netobserv-ebpf-agent/pull/291#discussion_r1520076865
HOST and PORT are very generic and don't provide the meaning about what
they are for; An uninformed user would probably think this would be for
a server, of for the agent host itself, rather than a target of
flow/packet collectors.
parent b63f4832
Branches
Tags
No related merge requests found
...@@ -45,9 +45,9 @@ configured by our [Network Observability Operator](https://github.com/netobserv/ ...@@ -45,9 +45,9 @@ configured by our [Network Observability Operator](https://github.com/netobserv/
Anyway you can run it directly as an executable from your command line: Anyway you can run it directly as an executable from your command line:
``` ```bash
export HOST=... export TARGET_HOST=...
export PORT=... export TARGET_PORT=...
sudo -E bin/netobserv-ebpf-agent sudo -E bin/netobserv-ebpf-agent
``` ```
......
...@@ -32,11 +32,11 @@ spec: ...@@ -32,11 +32,11 @@ spec:
- SYS_RESOURCE - SYS_RESOURCE
runAsUser: 0 runAsUser: 0
env: env:
- name: HOST - name: TARGET_HOST
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.hostIP fieldPath: status.hostIP
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
......
...@@ -27,11 +27,11 @@ spec: ...@@ -27,11 +27,11 @@ spec:
privileged: true privileged: true
runAsUser: 0 runAsUser: 0
env: env:
- name: HOST - name: TARGET_HOST
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.hostIP fieldPath: status.hostIP
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
......
...@@ -27,9 +27,9 @@ spec: ...@@ -27,9 +27,9 @@ spec:
privileged: true privileged: true
runAsUser: 0 runAsUser: 0
env: env:
- name: HOST - name: TARGET_HOST
value: "flp" value: "flp"
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
--- ---
apiVersion: v1 apiVersion: v1
......
...@@ -5,8 +5,8 @@ _Please also refer to the file [config.go](../pkg/agent/config.go) which is the ...@@ -5,8 +5,8 @@ _Please also refer to the file [config.go](../pkg/agent/config.go) which is the
The following environment variables are available to configure the NetObserv eBFP Agent: The following environment variables are available to configure the NetObserv eBFP Agent:
* `EXPORT` (default: `grpc`). Flows' exporter protocol. Accepted values are: `grpc`, `kafka`, `ipfix+udp`, `ipfix+tcp` or `direct-flp`. In `direct-flp` mode, [flowlogs-pipeline](https://github.com/netobserv/flowlogs-pipeline) is run internally from the agent, allowing more filtering, transformations and exporting options. * `EXPORT` (default: `grpc`). Flows' exporter protocol. Accepted values are: `grpc`, `kafka`, `ipfix+udp`, `ipfix+tcp` or `direct-flp`. In `direct-flp` mode, [flowlogs-pipeline](https://github.com/netobserv/flowlogs-pipeline) is run internally from the agent, allowing more filtering, transformations and exporting options.
* `HOST` (required if `EXPORT` is `grpc` or `ipfix+[tcp/udp]`). Host name or IP of the Flow collector. * `TARGET_HOST` (required if `EXPORT` is `grpc` or `ipfix+[tcp/udp]`). Host name or IP of the target flow or packet collector.
* `PORT` (required if `EXPORT` is `grpc` or `ipfix+[tcp/udp]`). Port of the flow collector. * `TARGET_PORT` (required if `EXPORT` is `grpc` or `ipfix+[tcp/udp]`). Port of the target flow or packet collector.
* `GRPC_MESSAGE_MAX_FLOWS` (default: `10000`). Specifies the limit, in number of flows, of each GRPC * `GRPC_MESSAGE_MAX_FLOWS` (default: `10000`). Specifies the limit, in number of flows, of each GRPC
message. Messages larger than that number will be split and submitted sequentially. message. Messages larger than that number will be split and submitted sequentially.
* `AGENT_IP` (optional). Allows overriding the reported Agent IP address on each flow. * `AGENT_IP` (optional). Allows overriding the reported Agent IP address on each flow.
......
...@@ -26,11 +26,11 @@ spec: ...@@ -26,11 +26,11 @@ spec:
value: 200ms value: 200ms
- name: LOG_LEVEL - name: LOG_LEVEL
value: debug value: debug
- name: HOST - name: TARGET_HOST
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.hostIP fieldPath: status.hostIP
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
volumeMounts: volumeMounts:
- name: bpf-kernel-debug - name: bpf-kernel-debug
......
...@@ -28,11 +28,11 @@ spec: ...@@ -28,11 +28,11 @@ spec:
value: 200ms value: 200ms
- name: LOG_LEVEL - name: LOG_LEVEL
value: debug value: debug
- name: HOST - name: TARGET_HOST
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.hostIP fieldPath: status.hostIP
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
volumeMounts: volumeMounts:
- name: bpf-kernel-debug - name: bpf-kernel-debug
......
...@@ -14,7 +14,7 @@ go build -mod vendor -o bin/flowlogs-dump-collector examples/flowlogs-dump/serve ...@@ -14,7 +14,7 @@ go build -mod vendor -o bin/flowlogs-dump-collector examples/flowlogs-dump/serve
``` ```
Start the agent using: Start the agent using:
```bash ```bash
sudo HOST=127.0.0.1 PORT=9999 ./bin/netobserv-ebpf-agent sudo TARGET_HOST=127.0.0.1 TARGET_PORT=9999 ./bin/netobserv-ebpf-agent
``` ```
Start the flowlogs-dump-collector using: (in a secondary shell) Start the flowlogs-dump-collector using: (in a secondary shell)
......
...@@ -19,7 +19,7 @@ Start the packetcapture-client using: (in a secondary shell) ...@@ -19,7 +19,7 @@ Start the packetcapture-client using: (in a secondary shell)
Start the agent using: Start the agent using:
```bash ```bash
sudo HOST=localhost PORT=9990 ENABLE_PCA=true PCA_FILTER=tcp,22 ./bin/netobserv-ebpf-agent sudo TARGET_HOST=localhost TARGET_PORT=9990 ENABLE_PCA=true PCA_FILTER=tcp,22 ./bin/netobserv-ebpf-agent
``` ```
You should see output such as: You should see output such as:
......
...@@ -67,9 +67,9 @@ spec: ...@@ -67,9 +67,9 @@ spec:
value: call_error,cares_resolver,dns_resolver value: call_error,cares_resolver,dns_resolver
- name: GRPC_DNS_RESOLVER - name: GRPC_DNS_RESOLVER
value: "ares" value: "ares"
- name: HOST - name: TARGET_HOST
value: "packet-counter" value: "packet-counter"
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
# resources: # resources:
# limits: # limits:
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
# /etc/default/netobserv-ebpf-agent # /etc/default/netobserv-ebpf-agent
DIRECTION=both DIRECTION=both
HOST=127.0.0.1 TARGET_HOST=127.0.0.1
PORT=9999 TARGET_PORT=9999
...@@ -294,11 +294,11 @@ func buildFlowExporter(cfg *Config, m *metrics.Metrics) (node.TerminalFunc[[]*fl ...@@ -294,11 +294,11 @@ func buildFlowExporter(cfg *Config, m *metrics.Metrics) (node.TerminalFunc[[]*fl
} }
func buildGRPCExporter(cfg *Config, m *metrics.Metrics) (node.TerminalFunc[[]*flow.Record], error) { func buildGRPCExporter(cfg *Config, m *metrics.Metrics) (node.TerminalFunc[[]*flow.Record], error) {
if cfg.Host == "" || cfg.Port == 0 { if cfg.TargetHost == "" || cfg.TargetPort == 0 {
return nil, fmt.Errorf("missing target host or port: %s:%d", return nil, fmt.Errorf("missing target host or port: %s:%d",
cfg.Host, cfg.Port) cfg.TargetHost, cfg.TargetPort)
} }
grpcExporter, err := exporter.StartGRPCProto(cfg.Host, cfg.Port, cfg.GRPCMessageMaxFlows, m) grpcExporter, err := exporter.StartGRPCProto(cfg.TargetHost, cfg.TargetPort, cfg.GRPCMessageMaxFlows, m)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -364,11 +364,11 @@ func buildKafkaExporter(cfg *Config, m *metrics.Metrics) (node.TerminalFunc[[]*f ...@@ -364,11 +364,11 @@ func buildKafkaExporter(cfg *Config, m *metrics.Metrics) (node.TerminalFunc[[]*f
} }
func buildIPFIXExporter(cfg *Config, proto string) (node.TerminalFunc[[]*flow.Record], error) { func buildIPFIXExporter(cfg *Config, proto string) (node.TerminalFunc[[]*flow.Record], error) {
if cfg.Host == "" || cfg.Port == 0 { if cfg.TargetHost == "" || cfg.TargetPort == 0 {
return nil, fmt.Errorf("missing target host or port: %s:%d", return nil, fmt.Errorf("missing target host or port: %s:%d",
cfg.Host, cfg.Port) cfg.TargetHost, cfg.TargetPort)
} }
ipfix, err := exporter.StartIPFIXExporter(cfg.Host, cfg.Port, proto) ipfix, err := exporter.StartIPFIXExporter(cfg.TargetHost, cfg.TargetPort, proto)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -29,10 +29,10 @@ func TestFlowsAgent_InvalidConfigs(t *testing.T) { ...@@ -29,10 +29,10 @@ func TestFlowsAgent_InvalidConfigs(t *testing.T) {
c: Config{Export: "foo"}, c: Config{Export: "foo"},
}, { }, {
d: "GRPC: missing host", d: "GRPC: missing host",
c: Config{Export: "grpc", Port: 3333}, c: Config{Export: "grpc", TargetPort: 3333},
}, { }, {
d: "GRPC: missing port", d: "GRPC: missing port",
c: Config{Export: "grpc", Host: "flp"}, c: Config{Export: "grpc", TargetHost: "flp"},
}, { }, {
d: "Kafka: missing brokers", d: "Kafka: missing brokers",
c: Config{Export: "kafka"}, c: Config{Export: "kafka"},
......
...@@ -42,11 +42,11 @@ type Config struct { ...@@ -42,11 +42,11 @@ type Config struct {
// Accepted values for Flows are: grpc (default), kafka, ipfix+udp, ipfix+tcp or direct-flp. // Accepted values for Flows are: grpc (default), kafka, ipfix+udp, ipfix+tcp or direct-flp.
// Accepted values for Packets are: grpc (default) or tcp // Accepted values for Packets are: grpc (default) or tcp
Export string `env:"EXPORT" envDefault:"grpc"` Export string `env:"EXPORT" envDefault:"grpc"`
// Host is the host name or IP of the Flow collector, when the EXPORT variable is // Host is the host name or IP of the flow or packet collector, when the EXPORT variable is
// set to "grpc" // set to "grpc"
Host string `env:"HOST"` TargetHost string `env:"TARGET_HOST"`
// Port is the port the Flow collector, when the EXPORT variable is set to "grpc" // Port is the port the flow or packet collector, when the EXPORT variable is set to "grpc"
Port int `env:"PORT"` TargetPort int `env:"TARGET_PORT"`
// GRPCMessageMaxFlows specifies the limit, in number of flows, of each GRPC message. Messages // GRPCMessageMaxFlows specifies the limit, in number of flows, of each GRPC message. Messages
// larger than that number will be split and submitted sequentially. // larger than that number will be split and submitted sequentially.
GRPCMessageMaxFlows int `env:"GRPC_MESSAGE_MAX_FLOWS" envDefault:"10000"` GRPCMessageMaxFlows int `env:"GRPC_MESSAGE_MAX_FLOWS" envDefault:"10000"`
...@@ -193,14 +193,14 @@ type Config struct { ...@@ -193,14 +193,14 @@ type Config struct {
func manageDeprecatedConfigs(cfg *Config) { func manageDeprecatedConfigs(cfg *Config) {
if len(cfg.FlowsTargetHost) != 0 { if len(cfg.FlowsTargetHost) != 0 {
clog.Infof("Using deprecated FlowsTargetHost %s", cfg.FlowsTargetHost) clog.Infof("Using deprecated FlowsTargetHost %s", cfg.FlowsTargetHost)
cfg.Host = cfg.FlowsTargetHost cfg.TargetHost = cfg.FlowsTargetHost
} }
if cfg.FlowsTargetPort != 0 { if cfg.FlowsTargetPort != 0 {
clog.Infof("Using deprecated FlowsTargetPort %d", cfg.FlowsTargetPort) clog.Infof("Using deprecated FlowsTargetPort %d", cfg.FlowsTargetPort)
cfg.Port = cfg.FlowsTargetPort cfg.TargetPort = cfg.FlowsTargetPort
} else if cfg.PCAServerPort != 0 { } else if cfg.PCAServerPort != 0 {
clog.Infof("Using deprecated PCAServerPort %d", cfg.PCAServerPort) clog.Infof("Using deprecated PCAServerPort %d", cfg.PCAServerPort)
cfg.Port = cfg.PCAServerPort cfg.TargetPort = cfg.PCAServerPort
} }
} }
...@@ -135,12 +135,12 @@ func packetsAgent(cfg *Config, ...@@ -135,12 +135,12 @@ func packetsAgent(cfg *Config,
} }
func buildGRPCPacketExporter(cfg *Config) (node.TerminalFunc[[]*flow.PacketRecord], error) { func buildGRPCPacketExporter(cfg *Config) (node.TerminalFunc[[]*flow.PacketRecord], error) {
if cfg.Host == "" || cfg.Port == 0 { if cfg.TargetHost == "" || cfg.TargetPort == 0 {
return nil, fmt.Errorf("missing target host or port for PCA: %s:%d", return nil, fmt.Errorf("missing target host or port for PCA: %s:%d",
cfg.Host, cfg.Port) cfg.TargetHost, cfg.TargetPort)
} }
plog.Info("starting gRPC Packet send") plog.Info("starting gRPC Packet send")
pcapStreamer, err := exporter.StartGRPCPacketSend(cfg.Host, cfg.Port) pcapStreamer, err := exporter.StartGRPCPacketSend(cfg.TargetHost, cfg.TargetPort)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -34,11 +34,11 @@ spec: ...@@ -34,11 +34,11 @@ spec:
value: 200ms value: 200ms
- name: LOG_LEVEL - name: LOG_LEVEL
value: debug value: debug
- name: HOST - name: TARGET_HOST
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.hostIP fieldPath: status.hostIP
- name: PORT - name: TARGET_PORT
value: "9999" value: "9999"
- name: ENABLE_RTT - name: ENABLE_RTT
value: "true" value: "true"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment