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

NETOBSERV-1906 add nodeSelector #101

Merged
merged 2 commits into from
Dec 12, 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
1 change: 0 additions & 1 deletion res/flow-capture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ spec:
- name: var-run-ovs
mountPath: /var/run/openvswitch
mountPropagation: Bidirectional

volumes:
- name: bpf-kernel-debug
hostPath:
Expand Down
1 change: 0 additions & 1 deletion res/packet-capture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ spec:
- name: bpf-kernel-debug
mountPath: /sys/kernel/debug
mountPropagation: Bidirectional

volumes:
- name: bpf-kernel-debug
hostPath:
Expand Down
27 changes: 19 additions & 8 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function common_usage {
echo " --max-bytes: maximum capture bytes (default: 50000000 = 50MB)"
echo " --copy: copy the output files locally (default: prompt)"
# filters
echo " --node-selector: capture on specific nodes (default: n/a)"
echo " --direction: filter direction (default: n/a)"
echo " --cidr: filter CIDR (default: 0.0.0.0/0)"
echo " --protocol: filter protocol (default: n/a)"
Expand Down Expand Up @@ -279,14 +280,19 @@ function edit_manifest() {
yq e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"FILTER_ACTION\").value|=\"$2\"" "$3"
;;
"filter_tcp_flags")
yq e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"FILTER_TCP_FLAGS\").value|=\"$2\"" "$3"
;;
"filter_pkt_drops")
yq e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"FILTER_DROPS\").value|=\"$2\"" "$3"
;;
yq e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"FILTER_TCP_FLAGS\").value|=\"$2\"" "$3"
;;
"filter_pkt_drops")
yq e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"FILTER_DROPS\").value|=\"$2\"" "$3"
;;
"log_level")
yq e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"LOG_LEVEL\").value|=\"$2\"" "$3"
;;
"node_selector")
key=${2%:*}
val=${2#*:}
yq e --inplace ".spec.template.spec.nodeSelector.\"$key\" |= \"$val\"" "$3"
;;
esac
}

Expand All @@ -302,7 +308,6 @@ function check_args_and_apply() {
case "$key" in
--copy) # Copy or skip without prompt
if [[ "$value" == "true" || "$value" == "false" || "$value" == "prompt" ]]; then
echo "param: $key, param_value: $value"
copy="$value"
else
echo "invalid value for --copy"
Expand Down Expand Up @@ -455,15 +460,21 @@ function check_args_and_apply() {
fi
;;
--max-time) # Max time
echo "param: $key, param_value: $value"
maxTime=$value
filter=${filter/$key=$maxTime/}
;;
--max-bytes) # Max bytes
echo "param: $key, param_value: $value"
maxBytes=$value
filter=${filter/$key=$maxBytes/}
;;
--node-selector) # Node selector
if [[ $value == *":"* ]]; then
edit_manifest "node_selector" "$value" "$2"
else
echo "invalid value for --node-selector. Use --node-selector=key:val instead."
exit 1
fi
;;
*) # Invalid option
echo "Invalid option: $key" >&2
exit 1
Expand Down
Loading