Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change HOST/PORT env to TARGET_HOST / TARGET_PORT #303

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
export HOST=...
export PORT=...
```bash
export TARGET_HOST=...
export TARGET_PORT=...
sudo -E bin/netobserv-ebpf-agent
```

Expand Down
4 changes: 2 additions & 2 deletions deployments/flp-daemonset-cap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
- SYS_RESOURCE
runAsUser: 0
env:
- name: HOST
- name: TARGET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: PORT
- name: TARGET_PORT
value: "9999"
---
apiVersion: apps/v1
Expand Down
4 changes: 2 additions & 2 deletions deployments/flp-daemonset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ spec:
privileged: true
runAsUser: 0
env:
- name: HOST
- name: TARGET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: PORT
- name: TARGET_PORT
value: "9999"
---
apiVersion: apps/v1
Expand Down
4 changes: 2 additions & 2 deletions deployments/flp-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ spec:
privileged: true
runAsUser: 0
env:
- name: HOST
- name: TARGET_HOST
value: "flp"
- name: PORT
- name: TARGET_PORT
value: "9999"
---
apiVersion: v1
Expand Down
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

* `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.
* `PORT` (required if `EXPORT` is `grpc` or `ipfix+[tcp/udp]`). Port 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.
* `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
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.
Expand Down
4 changes: 2 additions & 2 deletions e2e/cluster/base/04-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ spec:
value: 200ms
- name: LOG_LEVEL
value: debug
- name: HOST
- name: TARGET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: PORT
- name: TARGET_PORT
value: "9999"
volumeMounts:
- name: bpf-kernel-debug
Expand Down
4 changes: 2 additions & 2 deletions e2e/ipfix/manifests/30-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ spec:
value: 200ms
- name: LOG_LEVEL
value: debug
- name: HOST
- name: TARGET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: PORT
- name: TARGET_PORT
value: "9999"
volumeMounts:
- name: bpf-kernel-debug
Expand Down
2 changes: 1 addition & 1 deletion examples/flowlogs-dump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go build -mod vendor -o bin/flowlogs-dump-collector examples/flowlogs-dump/serve
```
Start the agent using:
```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)
Expand Down
2 changes: 1 addition & 1 deletion examples/packetcapture-dump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Start the packetcapture-client using: (in a secondary shell)

Start the agent using:
```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:
Expand Down
4 changes: 2 additions & 2 deletions examples/performance/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ spec:
value: call_error,cares_resolver,dns_resolver
- name: GRPC_DNS_RESOLVER
value: "ares"
- name: HOST
- name: TARGET_HOST
value: "packet-counter"
- name: PORT
- name: TARGET_PORT
value: "9999"
# resources:
# limits:
Expand Down
4 changes: 2 additions & 2 deletions examples/systemd/netobserv-ebpf-agent
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# /etc/default/netobserv-ebpf-agent

DIRECTION=both
HOST=127.0.0.1
PORT=9999
TARGET_HOST=127.0.0.1
TARGET_PORT=9999
12 changes: 6 additions & 6 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if cfg.Host == "" || cfg.Port == 0 {
if cfg.TargetHost == "" || cfg.TargetPort == 0 {
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 {
return nil, err
}
Expand Down Expand Up @@ -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) {
if cfg.Host == "" || cfg.Port == 0 {
if cfg.TargetHost == "" || cfg.TargetPort == 0 {
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 {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ func TestFlowsAgent_InvalidConfigs(t *testing.T) {
c: Config{Export: "foo"},
}, {
d: "GRPC: missing host",
c: Config{Export: "grpc", Port: 3333},
c: Config{Export: "grpc", TargetPort: 3333},
}, {
d: "GRPC: missing port",
c: Config{Export: "grpc", Host: "flp"},
c: Config{Export: "grpc", TargetHost: "flp"},
}, {
d: "Kafka: missing brokers",
c: Config{Export: "kafka"},
Expand Down
14 changes: 7 additions & 7 deletions pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 Packets are: grpc (default) or tcp
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"
Host string `env:"HOST"`
// Port is the port the Flow collector, when the EXPORT variable is set to "grpc"
Port int `env:"PORT"`
TargetHost string `env:"TARGET_HOST"`
// Port is the port the flow or packet collector, when the EXPORT variable is set to "grpc"
TargetPort int `env:"TARGET_PORT"`
// GRPCMessageMaxFlows specifies the limit, in number of flows, of each GRPC message. Messages
// larger than that number will be split and submitted sequentially.
GRPCMessageMaxFlows int `env:"GRPC_MESSAGE_MAX_FLOWS" envDefault:"10000"`
Expand Down Expand Up @@ -193,14 +193,14 @@ type Config struct {
func manageDeprecatedConfigs(cfg *Config) {
if len(cfg.FlowsTargetHost) != 0 {
clog.Infof("Using deprecated FlowsTargetHost %s", cfg.FlowsTargetHost)
cfg.Host = cfg.FlowsTargetHost
cfg.TargetHost = cfg.FlowsTargetHost
}

if cfg.FlowsTargetPort != 0 {
clog.Infof("Using deprecated FlowsTargetPort %d", cfg.FlowsTargetPort)
cfg.Port = cfg.FlowsTargetPort
cfg.TargetPort = cfg.FlowsTargetPort
} else if cfg.PCAServerPort != 0 {
clog.Infof("Using deprecated PCAServerPort %d", cfg.PCAServerPort)
cfg.Port = cfg.PCAServerPort
cfg.TargetPort = cfg.PCAServerPort
}
}
6 changes: 3 additions & 3 deletions pkg/agent/packets_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ func packetsAgent(cfg *Config,
}

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",
cfg.Host, cfg.Port)
cfg.TargetHost, cfg.TargetPort)
}
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 {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ spec:
value: 200ms
- name: LOG_LEVEL
value: debug
- name: HOST
- name: TARGET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: PORT
- name: TARGET_PORT
value: "9999"
- name: ENABLE_RTT
value: "true"
Expand Down
Loading