diff --git a/res/flow-capture.yml b/res/flow-capture.yml index abe07fce..e264507a 100644 --- a/res/flow-capture.yml +++ b/res/flow-capture.yml @@ -158,7 +158,6 @@ spec: - name: var-run-ovs mountPath: /var/run/openvswitch mountPropagation: Bidirectional - volumes: - name: bpf-kernel-debug hostPath: diff --git a/res/packet-capture.yml b/res/packet-capture.yml index 3b63904c..bdd589f7 100644 --- a/res/packet-capture.yml +++ b/res/packet-capture.yml @@ -136,7 +136,6 @@ spec: - name: bpf-kernel-debug mountPath: /sys/kernel/debug mountPropagation: Bidirectional - volumes: - name: bpf-kernel-debug hostPath: diff --git a/scripts/functions.sh b/scripts/functions.sh index 33dd8787..4ed51140 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -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)" @@ -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 } @@ -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" @@ -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