Skip to content

Commit

Permalink
Implementation of flow aggregator
Browse files Browse the repository at this point in the history
- Add the build system, scripts for manifest generation and corresponding
  workflow changes for Flow Aggregator.
- The main logic implementation of the flow aggregator that uses the go-ipfix
  library v0.4.2 with required unit tests.
- Agent side changes in Flow Exporter for integration with Flow Aggregator using
  DNS name resolution.
- Add e2e tests for flow aggregator and remove flow exporter tests.

Co-authored-by: dyongming@vmware.com
Co-authored-by: zyiou@vmware.com
Co-authored-by: stati@vmware.com
  • Loading branch information
srikartati committed Dec 22, 2020
1 parent 7a43f99 commit fc7ef0c
Show file tree
Hide file tree
Showing 52 changed files with 2,398 additions and 615 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,21 @@ jobs:
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
make push
make push-release
build-flow-aggregator:
needs: check-changes
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name == 'push' }}
runs-on: [ubuntu-18.04]
steps:
- uses: actions/checkout@v2
- name: Build flow-aggregator Docker image
run: make flow-aggregator-ubuntu
- name: Push flow-aggregator Docker image to registry
# Will remove the feature/flow-aggregator branch later
if: ${{ github.repository == 'vmware-tanzu/antrea' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push antrea/flow-aggregator:latest
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}"
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
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ windows-bin:
GOOS=windows $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' github.com/vmware-tanzu/antrea/cmd/antrea-cni \
github.com/vmware-tanzu/antrea/cmd/antrea-agent

.PHONY: flow-aggregator
flow-aggregator:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) build -o $(BINDIR) $(GOFLAGS) -ldflags '$(LDFLAGS)' github.com/vmware-tanzu/antrea/cmd/flow-aggregator

.PHONY: test-unit test-integration
ifeq ($(UNAME_S),Linux)
test-unit: .linux-test-unit
Expand Down Expand Up @@ -300,6 +305,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,6 +320,18 @@ octant-antrea-ubuntu:
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/octant-antrea-ubuntu
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION)

.PHONY: flow-aggregator-ubuntu
flow-aggregator-ubuntu:
@echo "===> Building antrea/flow-aggregator Docker image <==="
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
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/flow-aggregator
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/flow-aggregator:$(DOCKER_IMG_VERSION)

.PHONY: verify
verify:
@echo "===> Verifying spellings <==="
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

WORKDIR /antrea

COPY . /antrea

RUN make flow-aggregator

FROM antrea/base-ubuntu:2.14.0

LABEL maintainer="Antrea <projectantrea-dev@googlegroups.com>"
LABEL description="The docker image for the flow aggregator"

USER root

COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator /usr/local/bin/
21 changes: 13 additions & 8 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1240,11 +1240,15 @@ data:
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener.
#enablePrometheusMetrics: true
# Provide flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# IP can be either IPv4 or IPv6. However, IPv6 address should be wrapped with [].
# This also enables the flow exporter that sends IPFIX flow records of conntrack flows on OVS bridge.
# If no L4 transport proto is given, we consider tcp as default.
#flowCollectorAddr: ""
# Provide the IPFIX collector address as a string with format <HOST>:[<PORT>][:<PROTO>].
# HOST can either be the DNS name or the IP of the Flow Collector. For example,
# "flow-aggregator.flow-aggregator.svc" can be provided as DNS name to connect
# to the Antrea Flow Aggregator service. If IP, it can be either IPv4 or IPv6.
# However, IPv6 address should be wrapped with [].
# If PORT is empty, we default to 4739, the standard IPFIX port.
# If no PROTO is given, we consider "tcp" as default. We support "tcp" and "udp"
# L4 transport protocols.
#flowCollectorAddr: "flow-aggregator.flow-aggregator.svc:4739:tcp"
# Provide flow poll interval as a duration string. This determines how often the flow exporter dumps connections from the conntrack module.
# Flow poll interval should be greater than or equal to 1s (one second).
Expand Down Expand Up @@ -1311,7 +1315,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-mdmtkcfh59
name: antrea-config-gm7dcbm584
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -1418,7 +1422,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-mdmtkcfh59
name: antrea-config-gm7dcbm584
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -1640,6 +1644,7 @@ spec:
- mountPath: /var/log/openvswitch
name: host-var-log-antrea
subPath: openvswitch
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
initContainers:
- command:
Expand Down Expand Up @@ -1682,7 +1687,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-mdmtkcfh59
name: antrea-config-gm7dcbm584
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
21 changes: 13 additions & 8 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1240,11 +1240,15 @@ data:
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener.
#enablePrometheusMetrics: true
# Provide flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# IP can be either IPv4 or IPv6. However, IPv6 address should be wrapped with [].
# This also enables the flow exporter that sends IPFIX flow records of conntrack flows on OVS bridge.
# If no L4 transport proto is given, we consider tcp as default.
#flowCollectorAddr: ""
# Provide the IPFIX collector address as a string with format <HOST>:[<PORT>][:<PROTO>].
# HOST can either be the DNS name or the IP of the Flow Collector. For example,
# "flow-aggregator.flow-aggregator.svc" can be provided as DNS name to connect
# to the Antrea Flow Aggregator service. If IP, it can be either IPv4 or IPv6.
# However, IPv6 address should be wrapped with [].
# If PORT is empty, we default to 4739, the standard IPFIX port.
# If no PROTO is given, we consider "tcp" as default. We support "tcp" and "udp"
# L4 transport protocols.
#flowCollectorAddr: "flow-aggregator.flow-aggregator.svc:4739:tcp"
# Provide flow poll interval as a duration string. This determines how often the flow exporter dumps connections from the conntrack module.
# Flow poll interval should be greater than or equal to 1s (one second).
Expand Down Expand Up @@ -1311,7 +1315,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-mdmtkcfh59
name: antrea-config-gm7dcbm584
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -1418,7 +1422,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-mdmtkcfh59
name: antrea-config-gm7dcbm584
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -1642,6 +1646,7 @@ spec:
- mountPath: /var/log/openvswitch
name: host-var-log-antrea
subPath: openvswitch
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
initContainers:
- command:
Expand Down Expand Up @@ -1684,7 +1689,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-mdmtkcfh59
name: antrea-config-gm7dcbm584
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
21 changes: 13 additions & 8 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1240,11 +1240,15 @@ data:
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener.
#enablePrometheusMetrics: true
# Provide flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# IP can be either IPv4 or IPv6. However, IPv6 address should be wrapped with [].
# This also enables the flow exporter that sends IPFIX flow records of conntrack flows on OVS bridge.
# If no L4 transport proto is given, we consider tcp as default.
#flowCollectorAddr: ""
# Provide the IPFIX collector address as a string with format <HOST>:[<PORT>][:<PROTO>].
# HOST can either be the DNS name or the IP of the Flow Collector. For example,
# "flow-aggregator.flow-aggregator.svc" can be provided as DNS name to connect
# to the Antrea Flow Aggregator service. If IP, it can be either IPv4 or IPv6.
# However, IPv6 address should be wrapped with [].
# If PORT is empty, we default to 4739, the standard IPFIX port.
# If no PROTO is given, we consider "tcp" as default. We support "tcp" and "udp"
# L4 transport protocols.
#flowCollectorAddr: "flow-aggregator.flow-aggregator.svc:4739:tcp"
# Provide flow poll interval as a duration string. This determines how often the flow exporter dumps connections from the conntrack module.
# Flow poll interval should be greater than or equal to 1s (one second).
Expand Down Expand Up @@ -1311,7 +1315,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-b5dkk776t2
name: antrea-config-h7t8ffthht
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -1418,7 +1422,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-b5dkk776t2
name: antrea-config-h7t8ffthht
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -1640,6 +1644,7 @@ spec:
- mountPath: /var/log/openvswitch
name: host-var-log-antrea
subPath: openvswitch
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
initContainers:
- command:
Expand Down Expand Up @@ -1682,7 +1687,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-b5dkk776t2
name: antrea-config-h7t8ffthht
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
21 changes: 13 additions & 8 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1245,11 +1245,15 @@ data:
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener.
#enablePrometheusMetrics: true
# Provide flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# IP can be either IPv4 or IPv6. However, IPv6 address should be wrapped with [].
# This also enables the flow exporter that sends IPFIX flow records of conntrack flows on OVS bridge.
# If no L4 transport proto is given, we consider tcp as default.
#flowCollectorAddr: ""
# Provide the IPFIX collector address as a string with format <HOST>:[<PORT>][:<PROTO>].
# HOST can either be the DNS name or the IP of the Flow Collector. For example,
# "flow-aggregator.flow-aggregator.svc" can be provided as DNS name to connect
# to the Antrea Flow Aggregator service. If IP, it can be either IPv4 or IPv6.
# However, IPv6 address should be wrapped with [].
# If PORT is empty, we default to 4739, the standard IPFIX port.
# If no PROTO is given, we consider "tcp" as default. We support "tcp" and "udp"
# L4 transport protocols.
#flowCollectorAddr: "flow-aggregator.flow-aggregator.svc:4739:tcp"
# Provide flow poll interval as a duration string. This determines how often the flow exporter dumps connections from the conntrack module.
# Flow poll interval should be greater than or equal to 1s (one second).
Expand Down Expand Up @@ -1316,7 +1320,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-6kg9kdbg49
name: antrea-config-mh52t2hmmd
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -1432,7 +1436,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-6kg9kdbg49
name: antrea-config-mh52t2hmmd
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -1689,6 +1693,7 @@ spec:
- mountPath: /var/log/strongswan
name: host-var-log-antrea
subPath: strongswan
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
initContainers:
- command:
Expand Down Expand Up @@ -1731,7 +1736,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-6kg9kdbg49
name: antrea-config-mh52t2hmmd
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
21 changes: 13 additions & 8 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1245,11 +1245,15 @@ data:
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener.
#enablePrometheusMetrics: true
# Provide flow collector address as string with format <IP>:<port>[:<proto>], where proto is tcp or udp.
# IP can be either IPv4 or IPv6. However, IPv6 address should be wrapped with [].
# This also enables the flow exporter that sends IPFIX flow records of conntrack flows on OVS bridge.
# If no L4 transport proto is given, we consider tcp as default.
#flowCollectorAddr: ""
# Provide the IPFIX collector address as a string with format <HOST>:[<PORT>][:<PROTO>].
# HOST can either be the DNS name or the IP of the Flow Collector. For example,
# "flow-aggregator.flow-aggregator.svc" can be provided as DNS name to connect
# to the Antrea Flow Aggregator service. If IP, it can be either IPv4 or IPv6.
# However, IPv6 address should be wrapped with [].
# If PORT is empty, we default to 4739, the standard IPFIX port.
# If no PROTO is given, we consider "tcp" as default. We support "tcp" and "udp"
# L4 transport protocols.
#flowCollectorAddr: "flow-aggregator.flow-aggregator.svc:4739:tcp"
# Provide flow poll interval as a duration string. This determines how often the flow exporter dumps connections from the conntrack module.
# Flow poll interval should be greater than or equal to 1s (one second).
Expand Down Expand Up @@ -1316,7 +1320,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-669cb7d7kt
name: antrea-config-mfd9dcdh6d
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -1423,7 +1427,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-669cb7d7kt
name: antrea-config-mfd9dcdh6d
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -1645,6 +1649,7 @@ spec:
- mountPath: /var/log/openvswitch
name: host-var-log-antrea
subPath: openvswitch
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
initContainers:
- command:
Expand Down Expand Up @@ -1687,7 +1692,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-669cb7d7kt
name: antrea-config-mfd9dcdh6d
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
1 change: 1 addition & 0 deletions build/yamls/base/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
component: antrea-agent
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
priorityClassName: system-node-critical
tolerations:
# Mark it as a critical add-on.
Expand Down
Loading

0 comments on commit fc7ef0c

Please sign in to comment.