Skip to content

Commit

Permalink
[ExternalNode]Add ExternalNodeController for processing ExternalNode …
Browse files Browse the repository at this point in the history
…changes (#3687)

1. Antrea Controller watches ExternalNode CRUD and converts it to
the corresponding ExternalEntity.

2. The conversion includes the following changes:
a.These ExternalEntity name is generated by this format:
  If NetworkInterface name is empty, uses ExternalNode name
  If NetworkInterface name is not empty, uses [ExternalNode name]-[Interface name].
b.The ExternalNode's labels are added on the ExternalEntity(ies).
c.The ExternalNode name is used to set "ExternalNode" field in the ExternalEntity.
d.ExternalNode NetworkInterface is used to set "Endpoint" field in the ExternalEntity.

3. Handle ExternalNode reconciliation and cleanup stale ExternalEntities.

Signed-off-by: Mengdie Song <[email protected]>
  • Loading branch information
mengdie-song authored and wenyingd committed May 27, 2022
1 parent 0dc1c92 commit 9c7554a
Show file tree
Hide file tree
Showing 12 changed files with 512 additions and 11 deletions.
3 changes: 3 additions & 0 deletions build/charts/antrea/conf/antrea-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ featureGates:
# Enable mirroring or redirecting the traffic Pods send or receive.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "TrafficControl" "default" false) }}

# Enable running agent on an unmanaged VM/BM.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "ExternalNode" "default" false) }}

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: {{ .Values.ovs.bridgeName | quote }}
Expand Down
3 changes: 3 additions & 0 deletions build/charts/antrea/conf/antrea-controller.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ featureGates:
# Enable managing external IPs of Services of LoadBalancer type.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "ServiceExternalIP" "default" false) }}

# Enable managing ExternalNode for unmanaged VM/BM.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "ExternalNode" "default" false) }}

# The port for the antrea-controller APIServer to serve on.
# Note that if it's set to another value, the `containerPort` of the `api` port of the
# `antrea-controller` container must be set to the same value.
Expand Down
8 changes: 8 additions & 0 deletions build/charts/antrea/templates/controller/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ rules:
- ippools/status
verbs:
- update
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ webhooks:
scope: "Cluster"
admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None
timeoutSeconds: 5
timeoutSeconds: 5
18 changes: 16 additions & 2 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ data:
# Enable mirroring or redirecting the traffic Pods send or receive.
# TrafficControl: false
# Enable running agent on an unmanaged VM/BM.
# ExternalNode: false
# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -358,6 +361,9 @@ data:
# Enable managing external IPs of Services of LoadBalancer type.
# ServiceExternalIP: false
# Enable managing ExternalNode for unmanaged VM/BM.
# ExternalNode: false
# The port for the antrea-controller APIServer to serve on.
# Note that if it's set to another value, the `containerPort` of the `api` port of the
# `antrea-controller` container must be set to the same value.
Expand Down Expand Up @@ -3372,6 +3378,14 @@ rules:
- ippools/status
verbs:
- update
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -3557,7 +3571,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 0cc20edc3fc882f0ea9bd3450fbab504858feeff47e1d3f09d8f6ebacd741dbe
checksum/config: fd3db69eb5db9d8492480b297952e3577e1063d608dd3e9d904a84c9c7466af7
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -3797,7 +3811,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 0cc20edc3fc882f0ea9bd3450fbab504858feeff47e1d3f09d8f6ebacd741dbe
checksum/config: fd3db69eb5db9d8492480b297952e3577e1063d608dd3e9d904a84c9c7466af7
labels:
app: antrea
component: antrea-controller
Expand Down
18 changes: 16 additions & 2 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ data:
# Enable mirroring or redirecting the traffic Pods send or receive.
# TrafficControl: false
# Enable running agent on an unmanaged VM/BM.
# ExternalNode: false
# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -358,6 +361,9 @@ data:
# Enable managing external IPs of Services of LoadBalancer type.
# ServiceExternalIP: false
# Enable managing ExternalNode for unmanaged VM/BM.
# ExternalNode: false
# The port for the antrea-controller APIServer to serve on.
# Note that if it's set to another value, the `containerPort` of the `api` port of the
# `antrea-controller` container must be set to the same value.
Expand Down Expand Up @@ -3372,6 +3378,14 @@ rules:
- ippools/status
verbs:
- update
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -3557,7 +3571,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 0cc20edc3fc882f0ea9bd3450fbab504858feeff47e1d3f09d8f6ebacd741dbe
checksum/config: fd3db69eb5db9d8492480b297952e3577e1063d608dd3e9d904a84c9c7466af7
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -3799,7 +3813,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 0cc20edc3fc882f0ea9bd3450fbab504858feeff47e1d3f09d8f6ebacd741dbe
checksum/config: fd3db69eb5db9d8492480b297952e3577e1063d608dd3e9d904a84c9c7466af7
labels:
app: antrea
component: antrea-controller
Expand Down
18 changes: 16 additions & 2 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ data:
# Enable mirroring or redirecting the traffic Pods send or receive.
# TrafficControl: false
# Enable running agent on an unmanaged VM/BM.
# ExternalNode: false
# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -358,6 +361,9 @@ data:
# Enable managing external IPs of Services of LoadBalancer type.
# ServiceExternalIP: false
# Enable managing ExternalNode for unmanaged VM/BM.
# ExternalNode: false
# The port for the antrea-controller APIServer to serve on.
# Note that if it's set to another value, the `containerPort` of the `api` port of the
# `antrea-controller` container must be set to the same value.
Expand Down Expand Up @@ -3372,6 +3378,14 @@ rules:
- ippools/status
verbs:
- update
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -3557,7 +3571,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 6b6be76fd37d8fdac7783fcd026b6f34e993630c12c339b1dafa99ba5b36cf00
checksum/config: 44e834426bd7efecb883d82527b964b6ac50a347db2ef007bfb577cbee6da121
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -3797,7 +3811,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 6b6be76fd37d8fdac7783fcd026b6f34e993630c12c339b1dafa99ba5b36cf00
checksum/config: 44e834426bd7efecb883d82527b964b6ac50a347db2ef007bfb577cbee6da121
labels:
app: antrea
component: antrea-controller
Expand Down
18 changes: 16 additions & 2 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ data:
# Enable mirroring or redirecting the traffic Pods send or receive.
# TrafficControl: false
# Enable running agent on an unmanaged VM/BM.
# ExternalNode: false
# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -371,6 +374,9 @@ data:
# Enable managing external IPs of Services of LoadBalancer type.
# ServiceExternalIP: false
# Enable managing ExternalNode for unmanaged VM/BM.
# ExternalNode: false
# The port for the antrea-controller APIServer to serve on.
# Note that if it's set to another value, the `containerPort` of the `api` port of the
# `antrea-controller` container must be set to the same value.
Expand Down Expand Up @@ -3385,6 +3391,14 @@ rules:
- ippools/status
verbs:
- update
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -3570,7 +3584,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: d289c621cfdc7aee9e8320c0398e76f302591b0adc12156d470320ee9839c073
checksum/config: effea4fa7935691aaea3fa102062366856076965a51577c751c11b8653230a77
checksum/ipsec-secret: d0eb9c52d0cd4311b6d252a951126bf9bea27ec05590bed8a394f0f792dcb2a4
labels:
app: antrea
Expand Down Expand Up @@ -3846,7 +3860,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: d289c621cfdc7aee9e8320c0398e76f302591b0adc12156d470320ee9839c073
checksum/config: effea4fa7935691aaea3fa102062366856076965a51577c751c11b8653230a77
labels:
app: antrea
component: antrea-controller
Expand Down
18 changes: 16 additions & 2 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ data:
# Enable mirroring or redirecting the traffic Pods send or receive.
# TrafficControl: false
# Enable running agent on an unmanaged VM/BM.
# ExternalNode: false
# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -358,6 +361,9 @@ data:
# Enable managing external IPs of Services of LoadBalancer type.
# ServiceExternalIP: false
# Enable managing ExternalNode for unmanaged VM/BM.
# ExternalNode: false
# The port for the antrea-controller APIServer to serve on.
# Note that if it's set to another value, the `containerPort` of the `api` port of the
# `antrea-controller` container must be set to the same value.
Expand Down Expand Up @@ -3372,6 +3378,14 @@ rules:
- ippools/status
verbs:
- update
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -3557,7 +3571,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 976e8c918d8c411df17238dd333a51f9adfdfafe2d6d480d7652f16be02fff3c
checksum/config: 854c66e484311ec7df5096b24c238923750a7713d83b3aa4332cd24297e22936
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -3797,7 +3811,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 976e8c918d8c411df17238dd333a51f9adfdfafe2d6d480d7652f16be02fff3c
checksum/config: 854c66e484311ec7df5096b24c238923750a7713d83b3aa4332cd24297e22936
labels:
app: antrea
component: antrea-controller
Expand Down
11 changes: 11 additions & 0 deletions cmd/antrea-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"antrea.io/antrea/pkg/controller/egress"
egressstore "antrea.io/antrea/pkg/controller/egress/store"
"antrea.io/antrea/pkg/controller/externalippool"
"antrea.io/antrea/pkg/controller/externalnode"
"antrea.io/antrea/pkg/controller/grouping"
antreaipam "antrea.io/antrea/pkg/controller/ipam"
"antrea.io/antrea/pkg/controller/metrics"
Expand Down Expand Up @@ -124,6 +125,7 @@ func run(o *Options) error {
cgInformer := crdInformerFactory.Crd().V1alpha3().ClusterGroups()
egressInformer := crdInformerFactory.Crd().V1alpha2().Egresses()
externalIPPoolInformer := crdInformerFactory.Crd().V1alpha2().ExternalIPPools()
externalNodeInformer := crdInformerFactory.Crd().V1alpha1().ExternalNodes()

clusterIdentityAllocator := clusteridentity.NewClusterIdentityAllocator(
env.GetAntreaNamespace(),
Expand Down Expand Up @@ -156,6 +158,11 @@ func run(o *Options) error {
networkPolicyStore,
groupStore)

var externalNodeController *externalnode.ExternalNodeController
if features.DefaultFeatureGate.Enabled(features.ExternalNode) {
externalNodeController = externalnode.NewExternalNodeController(crdClient, externalNodeInformer, eeInformer)
}

var networkPolicyStatusController *networkpolicy.StatusController
if features.DefaultFeatureGate.Enabled(features.AntreaPolicy) {
networkPolicyStatusController = networkpolicy.NewStatusController(crdClient, networkPolicyStore, cnpInformer, anpInformer)
Expand Down Expand Up @@ -315,6 +322,10 @@ func run(o *Options) error {
go externalIPController.Run(stopCh)
}

if features.DefaultFeatureGate.Enabled(features.ExternalNode) {
go externalNodeController.Run(stopCh)
}

if antreaIPAMController != nil {
go antreaIPAMController.Run(stopCh)
}
Expand Down
Loading

0 comments on commit 9c7554a

Please sign in to comment.