Skip to content

Commit

Permalink
Merge PR #1 updates into PR #2 for flow aggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongming Ding committed Dec 1, 2020
2 parents 40601f0 + 43dc23a commit fb0741e
Show file tree
Hide file tree
Showing 18 changed files with 363 additions and 26 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ jobs:
VERSION="${TAG:10}" make octant-antrea-ubuntu
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push antrea/octant-antrea-ubuntu:"${TAG:10}"
build-flow-aggregator:
runs-on: [ubuntu-18.04]
steps:
- uses: actions/checkout@v2
- name: Build flow-aggregator Docker image and push to registry
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
TAG: ${{ github.ref }}
run: |
VERSION="${TAG:10}" make flow-aggregator-ubuntu
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push antrea/flow-aggregator:"${TAG:10}"
2 changes: 2 additions & 0 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
- master
- release-*
- ipv6
- feature/flow-aggregator
push:
branches:
- master
- release-*
- ipv6
- feature/flow-aggregator

env:
KIND_VERSION: v0.9.0
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/upload_release_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ jobs:
asset_path: ./assets/antrea-windows.yml
asset_name: antrea-windows.yml
asset_content_type: application/octet-stream
- name: Upload flow-aggregator.yml
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/flow-aggregator.yml
asset_name: flow-aggregator.yml
asset_content_type: application/octet-stream
- name: Upload antrea-agent-windows-x86_64.exe
uses: actions/upload-release-asset@v1
env:
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ manifest:
$(CURDIR)/hack/generate-manifest.sh --mode dev --cloud AKS --encap-mode networkPolicyOnly > build/yamls/antrea-aks.yml
$(CURDIR)/hack/generate-manifest-octant.sh --mode dev > build/yamls/antrea-octant.yml
$(CURDIR)/hack/generate-manifest-windows.sh --mode dev > build/yamls/antrea-windows.yml
$(CURDIR)/hack/generate-manifest-flow-aggregator.sh --mode dev > build/yamls/flow-aggregator.yml

.PHONY: manifest-coverage
manifest-coverage:
Expand All @@ -314,7 +315,11 @@ octant-antrea-ubuntu:
.PHONY: flow-aggregator-ubuntu
flow-aggregator-ubuntu:
@echo "===> Building antrea/flow-aggregator Docker image <==="
docker build --pull -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flowaggregator/Dockerfile .
ifneq ($(DOCKER_REGISTRY),"")
docker build -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile .
else
docker build --pull -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile .
endif
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) antrea/flow-aggregator

.PHONY: verify
Expand Down
16 changes: 16 additions & 0 deletions build/images/flow-aggregator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.15 as flow-aggregator-build

LABEL maintainer="Antrea <[email protected]>"
LABEL description="The docker image for flow aggregator"

WORKDIR /antrea

COPY . /antrea

RUN make flow-aggregator

FROM antrea/base-ubuntu:2.14.0

USER root

COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator /usr/local/bin/
13 changes: 0 additions & 13 deletions build/images/flowaggregator/Dockerfile

This file was deleted.

80 changes: 80 additions & 0 deletions build/yamls/flow-aggregator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: v1
data:
flow-aggregator.conf: |-
# Provide the flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# If no L4 transport proto is given, we consider tcp as default.
# Defaults to "".
flowCollectorAddr: ""
# Provide flow export interval as a duration string. This determines how often the flow aggregator exports flow
# records to the flow collector.
# Flow export interval should be greater than or equal to 1s (one second).
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# Defaults to "60s".
flowExportInterval: 60s
kind: ConfigMap
metadata:
labels:
app: flow-aggregator
name: flow-aggregator-configmap-ht56gf55k8
namespace: flow-aggregator
---
apiVersion: v1
kind: Service
metadata:
labels:
app: flow-aggregator
name: flow-aggregator
namespace: flow-aggregator
spec:
ports:
- port: 4739
protocol: UDP
targetPort: 4739
selector:
app: flow-aggregator
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: flow-aggregator
name: flow-aggregator
namespace: flow-aggregator
spec:
replicas: 1
selector:
matchLabels:
app: flow-aggregator
template:
metadata:
labels:
app: flow-aggregator
spec:
containers:
- args:
- --config
- /etc/flow-aggregator/flow-aggregator.conf
- --logtostderr=false
- --log_dir=/var/log/flowaggregator
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- flow-aggregator
image: antrea/flow-aggregator
imagePullPolicy: IfNotPresent
name: flow-aggregator
ports:
- containerPort: 4739
volumeMounts:
- mountPath: /etc/flow-aggregator/flow-aggregator.conf
name: flow-aggregator-config
readOnly: true
subPath: flow-aggregator.conf
volumes:
- configMap:
name: flow-aggregator-configmap-ht56gf55k8
name: flow-aggregator-config
11 changes: 11 additions & 0 deletions build/yamls/flow-aggregator/base/conf/flow-aggregator.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Provide the flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# If no L4 transport proto is given, we consider tcp as default.
# Defaults to "".
flowCollectorAddr: ""

# Provide flow export interval as a duration string. This determines how often the flow aggregator exports flow
# records to the flow collector.
# Flow export interval should be greater than or equal to 1s (one second).
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# Defaults to "60s".
flowExportInterval: 60s
52 changes: 52 additions & 0 deletions build/yamls/flow-aggregator/base/flow-aggregator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: v1
kind: Service
metadata:
name: flow-aggregator
namespace: flow-aggregator
spec:
selector:
app: flow-aggregator
type: NodePort
ports:
- port: 4739
protocol: UDP
targetPort: 4739
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flow-aggregator
namespace: flow-aggregator
spec:
replicas: 1
selector:
matchLabels:
app: flow-aggregator
template:
spec:
containers:
- args:
- --config
- /etc/flow-aggregator/flow-aggregator.conf
- --logtostderr=false
- --log_dir=/var/log/flowaggregator
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- flow-aggregator
name: flow-aggregator
image: antrea/flow-aggregator
ports:
- containerPort: 4739
volumeMounts:
- mountPath: /etc/flow-aggregator/flow-aggregator.conf
name: flow-aggregator-config
readOnly: true
subPath: flow-aggregator.conf
volumes:
- name: flow-aggregator-config
configMap:
name: flow-aggregator-configmap

11 changes: 11 additions & 0 deletions build/yamls/flow-aggregator/base/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resources:
- flow-aggregator.yml
configMapGenerator:
- files:
- conf/flow-aggregator.conf
name: flow-aggregator-configmap
commonLabels:
app: flow-aggregator
namespace: flow-aggregator
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
11 changes: 11 additions & 0 deletions build/yamls/flow-aggregator/patches/dev/imagePullPolicy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: flow-aggregator
namespace: flow-aggregator
spec:
template:
spec:
containers:
- name: flow-aggregator
imagePullPolicy: IfNotPresent
1 change: 1 addition & 0 deletions build/yamls/flow-aggregator/patches/release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# placeholder
9 changes: 5 additions & 4 deletions cmd/flow-aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type FlowAggregatorConfig struct {
// If no L4 transport proto is given, we consider tcp as default.
// Defaults to "".
FlowCollectorAddr string `yaml:"flowCollectorAddr,omitempty"`
// Provide flow export frequency, which is the number of seconds elapsed before flow aggregator exports flow
// Provide flow export interval as a duration string. This determines how often the flow aggregator exports flow
// records to the flow collector.
// Flow export frequency should be greater than or equal to 1s(one second).
// Defaults to "60s". Follow the time units of duration.
FlowExportFrequency string `yaml:"flowExportFrequency,omitempty"`
// Flow export interval should be greater than or equal to 1s (one second).
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
// Defaults to "60s".
FlowExportInterval string `yaml:"flowExportInterval,omitempty"`
}
3 changes: 2 additions & 1 deletion cmd/flow-aggregator/flow-aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package main

import (
"k8s.io/klog"

aggregator "github.com/vmware-tanzu/antrea/pkg/flowaggregator"
"github.com/vmware-tanzu/antrea/pkg/signals"
"k8s.io/klog"
)

func run(o *Options) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/flow-aggregator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/vmware-tanzu/antrea/pkg/log"
"github.com/vmware-tanzu/antrea/pkg/version"
"k8s.io/component-base/logs"
"k8s.io/klog"

"github.com/vmware-tanzu/antrea/pkg/log"
"github.com/vmware-tanzu/antrea/pkg/version"
)

func main() {
Expand Down
10 changes: 5 additions & 5 deletions cmd/flow-aggregator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ func (o *Options) validate(args []string) error {
}
}
}
if o.config.FlowExportFrequency != "" {
if o.config.FlowExportInterval != "" {
var err error
o.exportFrequency, err = time.ParseDuration(o.config.FlowExportFrequency)
o.exportInterval, err = time.ParseDuration(o.config.FlowExportInterval)
if err != nil {
return fmt.Errorf("ExportFrequency is not provided in right format: %v", err)
return fmt.Errorf("ExportInterval is not provided in right format: %v", err)
}
if o.exportFrequency < time.Second {
return fmt.Errorf("ExportFrequency should be greater than or equal to one second")
if o.exportInterval < time.Second {
return fmt.Errorf("ExportInterval should be greater than or equal to one second")
}
}
return nil
Expand Down
Loading

0 comments on commit fb0741e

Please sign in to comment.