Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into antrea-cluster-checks
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/kind.yml
#	pkg/antctl/raw/check/installation/command.go
  • Loading branch information
kanha-gupta committed May 7, 2024
2 parents 93afe40 + 9125f28 commit a2c4158
Show file tree
Hide file tree
Showing 22 changed files with 504 additions and 199 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ on:
branches: [ "main" ]

jobs:
check-changes:
name: Check whether tests need to be run based on diff
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- uses: antrea-io/has-changes@v2
id: check_diff
with:
paths-ignore: docs/* ci/jenkins/* *.md hack/.notableofcontents
outputs:
has_changes: ${{ steps.check_diff.outputs.has_changes }}

analyze-on-linux:
needs: check-changes
if: ${{ needs.check-changes.outputs.has_changes == 'yes' }}
name: Analyze on Linux
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -50,6 +67,8 @@ jobs:
category: "/language:${{matrix.language}}"

analyze-on-windows:
needs: check-changes
if: ${{ needs.check-changes.outputs.has_changes == 'yes' }}
name: Analyze on Windows
runs-on: windows-latest
permissions:
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ jobs:
path: log.tar.gz
retention-days: 30

run-installation-checks:
run-post-installation-checks:
name: Test connectivity using 'antctl check' command
needs: [ build-antrea-coverage-image ]
runs-on: [ ubuntu-latest ]
Expand Down Expand Up @@ -771,18 +771,14 @@ jobs:
sudo mv kind /usr/local/bin
- name: Create Kind Cluster
run: |
kind create cluster --config ci/kind/config-3nodes.yml
./ci/kind/kind-setup.sh create kind --ip-family dual
- name: Deploy Antrea
run: |
kubectl apply -f build/yamls/antrea.yml
- name: Build antctl binary
run: |
make antctl-linux
- name: Run Pre checks
run: |
./bin/antctl-linux check cluster
- name: Load Docker images and deploy Antrea
run: |
kind load docker-image antrea/antrea-controller-ubuntu-coverage:latest antrea/antrea-agent-ubuntu-coverage:latest
kubectl apply -f build/yamls/antrea.yml
- name: Run Post checks
- name: Run antctl command
run: |
./bin/antctl-linux check installation
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,23 @@ Here are the trigger phrases for individual checks:
* `/test-rancher-e2e`: Linux IPv4 e2e tests on Rancher clusters.
* `/test-rancher-conformance`: Linux IPv4 conformance tests on Rancher clusters.
* `/test-rancher-networkpolicy`: Linux IPv4 networkpolicy tests on Rancher clusters.
* `/test-kind-ipv6-e2e`: Linux dual stack e2e tests on Kind cluster.
* `/test-kind-ipv6-only-e2e`: Linux IPv6 only e2e tests on Kind cluster.
* `/test-kind-conformance`: Linux IPv4 conformance tests on Kind cluster.
* `/test-kind-ipv6-only-conformance`: Linux IPv6 only conformance tests on Kind cluster.
* `/test-kind-ipv6-conformance`: Linux dual stack conformance tests on Kind cluster.
* `/test-kind-networkpolicy`: Linux IPv4 networkpolicy tests on Kind cluster.
* `/test-kind-ipv6-only-networkpolicy`: Linux IPv6 only networkpolicy tests on Kind cluster.
* `/test-kind-ipv6-networkpolicy`: Linux dual stack networkpolicy tests on Kind cluster.
Here are the trigger phrases for groups of checks:
* `/test-all`: Linux IPv4 tests
* `/test-windows-all`: Windows IPv4 tests, including e2e tests with proxyAll enabled. It also includes all containerd runtime based Windows tests since 1.10.0.
* `/test-ipv6-all`: Linux dual stack tests
* `/test-ipv6-only-all`: Linux IPv6 only tests
* `/test-kind-ipv6-only-all`: Linux IPv6 only tests on Kind cluster.
* `/test-kind-ipv6-all`: Linux dual stack tests on Kind cluster.
Besides, you can skip a check with `/skip-*`, e.g. `/skip-e2e`: skip Linux IPv4
e2e tests.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0.0-dev
v2.1.0-dev
2 changes: 1 addition & 1 deletion build/charts/antrea/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# antrea

![Version: 2.0.0-dev](https://img.shields.io/badge/Version-2.0.0--dev-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 2.1.0-dev](https://img.shields.io/badge/Version-2.1.0--dev-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

Kubernetes networking based on Open vSwitch

Expand Down
2 changes: 1 addition & 1 deletion build/charts/flow-aggregator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flow-aggregator

![Version: 2.0.0-dev](https://img.shields.io/badge/Version-2.0.0--dev-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 2.1.0-dev](https://img.shields.io/badge/Version-2.1.0--dev-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

Antrea Flow Aggregator

Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/test-mc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function clean_tmp() {
function clean_images() {
docker images --format "{{.Repository}}:{{.Tag}}" | grep -E 'mc-controller|antrea-ubuntu' | xargs -r docker rmi -f || true
# Clean up dangling images generated in previous builds.
docker image prune -f --filter "until=24h" || true > /dev/null
docker image prune -af --filter "until=24h" || true > /dev/null
check_and_cleanup_docker_build_cache
}

Expand Down
2 changes: 1 addition & 1 deletion ci/test-conformance-aks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function deliver_antrea_to_aks() {
fi
# Clean up dangling images generated in previous builds. Recent ones must be excluded
# because they might be being used in other builds running simultaneously.
docker image prune -f --filter "until=2h" > /dev/null
docker image prune -af --filter "until=2h" > /dev/null
docker system df -v
check_and_cleanup_docker_build_cache

Expand Down
2 changes: 1 addition & 1 deletion ci/test-conformance-eks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function deliver_antrea_to_eks() {
fi
# Clean up dangling images generated in previous builds. Recent ones must be excluded
# because they might be being used in other builds running simultaneously.
docker image prune -f --filter "until=2h" > /dev/null
docker image prune -af --filter "until=2h" > /dev/null
docker system df -v
check_and_cleanup_docker_build_cache
set -e
Expand Down
2 changes: 1 addition & 1 deletion ci/test-conformance-gke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function deliver_antrea_to_gke() {
fi
# Clean up dangling images generated in previous builds. Recent ones must be excluded
# because they might be being used in other builds running simultaneously.
docker image prune -f --filter "until=2h" > /dev/null
docker image prune -af --filter "until=2h" > /dev/null
docker system df -v
check_and_cleanup_docker_build_cache
set -e
Expand Down
94 changes: 93 additions & 1 deletion docs/antrea-network-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [K8s clusters with version 1.21 and above](#k8s-clusters-with-version-121-and-above)
- [K8s clusters with version 1.20 and below](#k8s-clusters-with-version-120-and-below)
- [Selecting Pods in the same Namespace with Self](#selecting-pods-in-the-same-namespace-with-self)
- [Selecting Namespaces with the same label values using SameLabels](#selecting-namespaces-with-the-same-label-values-using-samelabels)
- [FQDN based filtering](#fqdn-based-filtering)
- [Node Selector](#node-selector)
- [toServices egress rules](#toservices-egress-rules)
Expand Down Expand Up @@ -1301,7 +1302,7 @@ spec:
```

The policy above ensures that x/a, x/b and x/c can communicate with each other, but nothing else
(unless there are higher precedenced policies which say otherwise). Same for Namespaces y and z.
(unless there are higher precedence policies that say otherwise). Same for Namespaces y and z.

```yaml
apiVersion: crd.antrea.io/v1beta1
Expand Down Expand Up @@ -1334,6 +1335,97 @@ These two policies shown above are for demonstration purposes only. For more rea
`namespaces` field, refer to this [sample](#acnp-for-strict-namespace-isolation) YAML in the previous
section.

### Selecting Namespaces with the same label values using SameLabels

Starting from Antrea v2.0, Antrea ClusterNetworkPolicy supports creating policy rules between groups
of Namespaces that share common label values. The most prominent use case of this feature is to provide
isolation between Namespaces that have different values for some pre-defined labels, e.g. "org", by
applying a single ACNP in the cluster.

Consider a minimalistic cluster with the following Namespaces:

```text
NAME LABELS
kube-system kubernetes.io/metadata.name=kube-system
accounting1 kubernetes.io/metadata.name=accounting1, org=accounting, region=us-west
accounting2 kubernetes.io/metadata.name=accounting2, org=accounting, region=us-east
sales1 kubernetes.io/metadata.name=sales1, org=sales, region=us-west
sales2 kubernetes.io/metadata.name=sales2, org=sales, region=us-east
```

An administrator of such cluster typically would want to enforce some boundaries between the "tenants"
in the cluster (the accounting team and the sales team in this case, who each own two Namespaces).
This can be easily achieved by the following ACNP:

```yaml
apiVersion: crd.antrea.io/v1beta1
kind: ClusterNetworkPolicy
metadata:
name: isolation-based-on-org
spec:
priority: 1
tier: securityops
appliedTo:
- namespaceSelector:
matchExpressions:
- { key: org, operator: Exists }
ingress:
- action: Allow
from:
- namespaces:
sameLabels: [org]
- action: Deny
egress:
- action: Allow
to:
- namespaces:
sameLabels: [org]
- action: Deny
```

The above policy will also automatically adapt to the changes in the cluster, i.e., any new Namespace
created in the cluster with a different "org" label value will be automatically isolated from both the
accounting and the sales Namespaces. In addition, the Namespace grouping criteria can be easily extended
to match more than one label keys, and Namespaces will be grouped together ONLY IF ALL the values of the
label keys listed in the `sameLabels` field have the same value. For example, if we change the `sameLabels`
list to `[org, region]` in the example above, then this ACNP will create four Namespace groups instead of
two, which are all isolated from each other. The reason is that individual Namespaces for the accounting
or sales organizations have different values for the "region" label, even though they share the same value
for the "org" label.

Another important note is that such policy is a no-op on Namespaces that do not have all the labels listed
in the `sameLabels` field, even if such Namespaces are selected in `appliedTo`. In other words, we can
rewrite the `appliedTo` in the policy above to `- namespaceSelector: {}` and it will work exactly the same.
There will be no effective rules created for the `kube-system` Namespace since it does not have the "org"
label. On the other hand, if the following policy (alone) is applied in this cluster:

```yaml
apiVersion: crd.antrea.io/v1beta1
kind: ClusterNetworkPolicy
metadata:
name: isolation-based-on-org-and-env
spec:
priority: 1
tier: securityops
appliedTo:
- namespaceSelector: {}
ingress:
- action: Allow
from:
- namespaces:
sameLabels: [org, env]
- action: Deny
from:
- namespaceSelector: {}
```

it will have no effect whatsoever because no Namespace has both the "org" and "env" label keys.
To take the example further, if we now add another Namespace `dev` with labels "org=dev, env=test" the end
result is that only the `dev` Namespace will be selected by the `isolation-based-on-org-and-env` ACNP, which
denies ingress from all other Namespaces in the cluster since they don't have the same values for labels
"org" and "env" compared to `dev` (in fact, there is no other Namespace with the "env" label key). All the
other Namespaces, on the other hand, will not have effective ingress rules created by this policy.

### FQDN based filtering

Antrea-native policy features a `fqdn` field in egress rules to select Fully Qualified Domain Names
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/containernetworking/plugins v1.1.1
github.com/coreos/go-iptables v0.7.0
github.com/davecgh/go-spew v1.1.1
github.com/fatih/color v1.16.0
github.com/fsnotify/fsnotify v1.7.0
github.com/gammazero/deque v0.1.2
github.com/go-logr/logr v1.4.1
Expand All @@ -39,8 +40,8 @@ require (
github.com/mdlayher/packet v1.1.2
github.com/miekg/dns v1.1.59
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.33.0
github.com/onsi/ginkgo/v2 v2.17.2
github.com/onsi/gomega v1.33.1
github.com/pkg/sftp v1.13.6
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/common v0.47.0
Expand All @@ -53,16 +54,16 @@ require (
github.com/vishvananda/netlink v1.2.1-beta.2
github.com/vmware/go-ipfix v0.9.0
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.23.0
golang.org/x/mod v0.17.0
golang.org/x/net v0.24.0
golang.org/x/net v0.25.0
golang.org/x/sync v0.7.0
golang.org/x/sys v0.19.0
golang.org/x/sys v0.20.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.20.0
golang.org/x/tools v0.21.0
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210506160403-92e472f520a5
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.34.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -126,7 +127,6 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
Expand All @@ -136,14 +136,14 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.17.7 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
Expand All @@ -166,7 +166,7 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mdlayher/genetlink v1.0.0 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
Expand Down Expand Up @@ -219,8 +219,8 @@ require (
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.zx2c4.com/wireguard v0.0.0-20210427022245-097af6e1351b // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
Loading

0 comments on commit a2c4158

Please sign in to comment.