Skip to content

Commit

Permalink
Update generate-manifest-flow-aggregator.sh with new config
Browse files Browse the repository at this point in the history
In this commit, we updated the hack/generate-manifest-flow-aggregator.sh
with new configuration of Flow Aggregator to support both FlowCollector
and Clickhouse sink.

Signed-off-by: Yongming Ding <dyongming@vmware.com>
  • Loading branch information
Yongming Ding committed Mar 25, 2022
1 parent c2a664b commit e98d440
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ci/test-flow-visibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ config_antrea() {

setup_flow_aggregator() {
echo "=== Config Antrea Flow Aggregator ==="
perl -i -p0e 's/ # Enable is the switch to enable exporting flow records to ClickHouse.\n #enable: false/ # Enable is the switch to enable exporting flow records to ClickHouse.\n enable: true/' ./build/yamls/flow-aggregator.yml
$GIT_CHECKOUT_DIR/hack/generate-manifest.sh -ch > ${GIT_CHECKOUT_DIR}/build/yamls/flow-aggregator.yml
echo "=== Start Antrea Flow Aggregator ==="
kubectl apply -f ${GIT_CHECKOUT_DIR}/build/yamls/flow-aggregator.yml
echo "=== Waiting for Antrea Flow Aggregator to be ready ==="
Expand Down
31 changes: 21 additions & 10 deletions hack/generate-manifest-flow-aggregator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ function echoerr {
>&2 echo "$@"
}

_usage="Usage: $0 [--mode (dev|release)] [-fc|--flow-collector] [--keep] [--help|-h]
_usage="Usage: $0 [--mode (dev|release)] [-fc|--flow-collector <addr>] [-ch|--clickhouse] [--keep] [--help|-h]
Generate a YAML manifest for the Flow Aggregator, using Kustomize, and print it to stdout.
--mode (dev|release) Choose the configuration variant that you need (default is 'dev')
--flow-collector Flow collector is the externalFlowCollectorAddr configMap parameter
It should be given in format IP:port:proto. Example: 192.168.1.100:4739:udp
--keep Debug flag which will preserve the generated kustomization.yml
--coverage Generate a manifest which supports measuring code coverage of the Flow Aggregator binaries.
--verbose-log Generate a manifest with increased log-level (level 4) for the Flow Aggregator.
This option will work only with 'dev' mode.
--help, -h Print this message and exit
--mode (dev|release) Choose the configuration variant that you need (default is 'dev')
--flow-collector, -fc <addr> Flow collector is the flowCollector address configMap parameter
It should be given in format IP:port:proto. Example: 192.168.1.100:4739:udp
--clickhouse, -ch Enable exporting flow records to default ClickHouse service address.
--keep Debug flag which will preserve the generated kustomization.yml
--coverage Generate a manifest which supports measuring code coverage of the Flow Aggregator binaries.
--verbose-log Generate a manifest with increased log-level (level 4) for the Flow Aggregator.
This option will work only with 'dev' mode.
--help, -h Print this message and exit
In 'release' mode, environment variables IMG_NAME and IMG_TAG must be set.
Expand All @@ -49,6 +50,7 @@ function print_help {
MODE="dev"
KEEP=false
FLOW_COLLECTOR=""
CLICKHOUSE=false
COVERAGE=false
VERBOSE_LOG=false

Expand All @@ -65,6 +67,10 @@ case $key in
FLOW_COLLECTOR="$2"
shift 2
;;
-ch|--clickhouse)
CLICKHOUSE=true
shift
;;
--keep)
KEEP=true
shift
Expand Down Expand Up @@ -138,7 +144,12 @@ mkdir configMap && cd configMap
# but instead to the generated YAML manifest, so our regexs need not be too robust.
cp $KUSTOMIZATION_DIR/base/conf/flow-aggregator.conf flow-aggregator.conf
if [[ $FLOW_COLLECTOR != "" ]]; then
sed -i.bak -E "s/^[[:space:]]*#[[:space:]]*externalFlowCollectorAddr[[:space:]]*:[[:space:]]\"\"+[[:space:]]*$/externalFlowCollectorAddr: \"$FLOW_COLLECTOR\"/" flow-aggregator.conf
perl -i -p0e 's/ # Enable is the switch to enable exporting flow records to external flow collector.\n #enable: false/ # Enable is the switch to enable exporting flow records to external flow collector.\n enable: true/' flow-aggregator.conf
sed -i.bak -E "s/^[[:space:]]*#[[:space:]]*address[[:space:]]*:[[:space:]]\"\"+[[:space:]]*$/ address: \"$FLOW_COLLECTOR\"/" flow-aggregator.conf
fi

if $CLICKHOUSE; then
perl -i -p0e 's/ # Enable is the switch to enable exporting flow records to ClickHouse.\n #enable: false/ # Enable is the switch to enable exporting flow records to ClickHouse.\n enable: true/' flow-aggregator.conf
fi

# unfortunately 'kustomize edit add configmap' does not support specifying 'merge' as the behavior,
Expand Down

0 comments on commit e98d440

Please sign in to comment.