Skip to content

Commit

Permalink
[ExternalNode] Handle ExternalNode from Antrea agent side (antrea-io#…
Browse files Browse the repository at this point in the history
…3799)

1. Provide an example RBAC yaml file for Antrea agent running
on VM with definitions of ClusterRole, ServiceAccount and
ClusterRoleBinding.

2. Add ExternalNodeController to monitor ExternalNode CRUD,
invoke interfaces to operate OVS and update interface store
with ExternalEntityInterface.

3. Implement OVS interactions related to ExternalNode CRUD.

4. Add a channel for receiving ExternalEntity updates from
ExternalNodeController and notifying NetworkPolicyController
to reconcile rules related to the updated ExternalEntities.
This is to handle the case when NetworkPolicyController reconciles
rules before ExternalEntityInterface is realized in the
interface store.

5. Support configuring policy bypass rules to skip ANP check.

Signed-off-by: Mengdie Song <[email protected]>
Co-authored-by: Wenying Dong <[email protected]>
  • Loading branch information
mengdie-song and wenyingd committed Aug 3, 2022
1 parent 1d75060 commit 53d11d0
Show file tree
Hide file tree
Showing 36 changed files with 1,287 additions and 88 deletions.
3 changes: 0 additions & 3 deletions build/charts/antrea/conf/antrea-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ featureGates:
# Enable certificated-based authentication for IPsec.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "IPsecCertAuth" "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
7 changes: 2 additions & 5 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2686,9 +2686,6 @@ data:
# Enable certificated-based authentication for IPsec.
# IPsecCertAuth: 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 @@ -3787,7 +3784,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: beca655f34bfd122082c7efa73505680278a8aa97e74099ca6040bcc4311622f
checksum/config: affad240c8b2b8575f7a93c12a08b7cf72aca2d978bda83d73d0120f45212877
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -4028,7 +4025,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: beca655f34bfd122082c7efa73505680278a8aa97e74099ca6040bcc4311622f
checksum/config: affad240c8b2b8575f7a93c12a08b7cf72aca2d978bda83d73d0120f45212877
labels:
app: antrea
component: antrea-controller
Expand Down
7 changes: 2 additions & 5 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2686,9 +2686,6 @@ data:
# Enable certificated-based authentication for IPsec.
# IPsecCertAuth: 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 @@ -3787,7 +3784,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: beca655f34bfd122082c7efa73505680278a8aa97e74099ca6040bcc4311622f
checksum/config: affad240c8b2b8575f7a93c12a08b7cf72aca2d978bda83d73d0120f45212877
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -4030,7 +4027,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: beca655f34bfd122082c7efa73505680278a8aa97e74099ca6040bcc4311622f
checksum/config: affad240c8b2b8575f7a93c12a08b7cf72aca2d978bda83d73d0120f45212877
labels:
app: antrea
component: antrea-controller
Expand Down
7 changes: 2 additions & 5 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2686,9 +2686,6 @@ data:
# Enable certificated-based authentication for IPsec.
# IPsecCertAuth: 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 @@ -3787,7 +3784,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: 741b313c6ab0ed98e7d994985861722f503a93529f90a5141b8a6e0c124d8904
checksum/config: 3677c7d305f558cd78b34ee0a71f786b0c53a3f19ad9eaa5eabf09aa2590164e
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -4027,7 +4024,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: 741b313c6ab0ed98e7d994985861722f503a93529f90a5141b8a6e0c124d8904
checksum/config: 3677c7d305f558cd78b34ee0a71f786b0c53a3f19ad9eaa5eabf09aa2590164e
labels:
app: antrea
component: antrea-controller
Expand Down
7 changes: 2 additions & 5 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2699,9 +2699,6 @@ data:
# Enable certificated-based authentication for IPsec.
# IPsecCertAuth: 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 @@ -3800,7 +3797,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: c74f29ceba3905db50cef22ee46f73e1c101c108a70e70918b17413c174081e8
checksum/config: 5e82c60c904bef6feb9d344aa5f283e3bb516250ffc1239aa1f46b99b07d5221
checksum/ipsec-secret: d0eb9c52d0cd4311b6d252a951126bf9bea27ec05590bed8a394f0f792dcb2a4
labels:
app: antrea
Expand Down Expand Up @@ -4086,7 +4083,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: c74f29ceba3905db50cef22ee46f73e1c101c108a70e70918b17413c174081e8
checksum/config: 5e82c60c904bef6feb9d344aa5f283e3bb516250ffc1239aa1f46b99b07d5221
labels:
app: antrea
component: antrea-controller
Expand Down
7 changes: 2 additions & 5 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2686,9 +2686,6 @@ data:
# Enable certificated-based authentication for IPsec.
# IPsecCertAuth: 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 @@ -3787,7 +3784,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: 056a828ba2400e94aa9c43e6e74a4b007027bf6b95a68e1e15f34cd6ffeb2baa
checksum/config: f72e5c9f6a652693755b716796b9aa0d4b6e2f0c7b64fd2333197af96862c8b5
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -4027,7 +4024,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: 056a828ba2400e94aa9c43e6e74a4b007027bf6b95a68e1e15f34cd6ffeb2baa
checksum/config: f72e5c9f6a652693755b716796b9aa0d4b6e2f0c7b64fd2333197af96862c8b5
labels:
app: antrea
component: antrea-controller
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/externalnode/conf/antrea-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ featureGates:
# Defaults to "k8sNode". Valid values include "k8sNode", and "externalNode".
nodeType: externalNode

externalNode:
# The expected Namespace in which the ExternalNode is created.
# Defaults to "default".
#externalNodeNamespace: default

# The policyBypassRules describes the traffic that is expected to bypass NetworkPolicy rules.
# Each rule contains the following four attributes:
# direction (ingress|egress), protocol(tcp/udp/icmp/ip), remote CIDR, dst port (ICMP doesn't require).
# Here is an example:
# - direction: ingress
# protocol: tcp
# cidr: 1.1.1.1/32
# port: 22
# It is used only when NodeType is externalNode.
#policyBypassRules: []

# The path to access the kubeconfig file used in the connection to K8s APIServer. The file contains the K8s
# APIServer endpoint and the token of ServiceAccount required in the connection.
clientConnection:
Expand Down
112 changes: 112 additions & 0 deletions build/yamls/externalnode/vm-agent-rbac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vm-agent
namespace: vm-ns # Change the Namespace to where vm-agent is expected to run.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vm-agent
rules:
# antrea-controller distributes the CA certificate as a ConfigMap named `antrea-ca` in the Antrea deployment Namespace.
# vm-agent needs to access `antrea-ca` to connect with antrea-controller.
- apiGroups:
- ""
resources:
- configmaps
resourceNames:
- antrea-ca
verbs:
- get
- watch
- list
# This is the content of built-in role kube-system/extension-apiserver-authentication-reader.
# But it doesn't have list/watch permission before K8s v1.17.0 so the extension apiserver (vm-agent) will
# have permission issue after bumping up apiserver library to a version that supports dynamic authentication.
# See https://github.com/kubernetes/kubernetes/pull/85375
# To support K8s clusters older than v1.17.0, we grant the required permissions directly instead of relying on
# the extension-apiserver-authentication role.
- apiGroups:
- ""
resourceNames:
- extension-apiserver-authentication
resources:
- configmaps
verbs:
- get
- list
- watch
- apiGroups:
- crd.antrea.io
resources:
- antreaagentinfos
verbs:
- get
- update
- apiGroups:
- controlplane.antrea.io
resources:
- networkpolicies
- appliedtogroups
- addressgroups
verbs:
- get
- watch
- list
- apiGroups:
- controlplane.antrea.io
resources:
- nodestatssummaries
verbs:
- create
- apiGroups:
- controlplane.antrea.io
resources:
- networkpolicies/status
verbs:
- create
- get
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vm-agent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: vm-agent
subjects:
- kind: ServiceAccount
name: vm-agent
namespace: vm-ns # Change the Namespace to where vm-agent is expected to run.
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vm-agent
namespace: vm-ns # Change the Namespace to where vm-agent is expected to run.
rules:
- apiGroups:
- crd.antrea.io
resources:
- externalnodes
verbs:
- get
- watch
- list
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vm-agent
namespace: vm-ns # Change the Namespace to where vm-agent is expected to run.
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: vm-agent
subjects:
- kind: ServiceAccount
name: vm-agent
namespace: vm-ns # Change the Namespace to where vm-agent is expected to run.
Loading

0 comments on commit 53d11d0

Please sign in to comment.