-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BGPPolicy API #6009
Add BGPPolicy API #6009
Conversation
dae2835
to
6c5b0d7
Compare
6c5b0d7
to
5f60191
Compare
5f60191
to
9041f5a
Compare
81b15cb
to
b75d4e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments on other parts of the API
pkg/apis/crd/v1alpha2/types.go
Outdated
ASN int32 `json:"asn"` | ||
|
||
// AuthSecretRef is a reference to a Secret storing the authentication password of the external BGP peer. | ||
AuthSecretRef *string `json:"authSecretRef,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it work exactly? In which Namespace are the secrets defined? I assume they need to be created in the same Namespace as Antrea. Does that mean Antrea will need permissions to read all secrets in the kube-system Namespace (I don't think this is the case today).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a thoughtful question. I found the corresponding implementation in other CNIs:
- Users assign a Secret reference in a CR, then create the corresponding Serect to store the password. To read the password, the CRD controller needs the
get
permission to read the corresponding Secret in the kube-system Namespace. - Uses set the base64 coded password in an annotation.
I think we could let users set the based64 coded password in a BGPPolicy CR directly. Though it is not a good practice, it is easy for users to use.
If users want to secure their BGP passwords, they could add a password for a BGP peer to the Serect named antrea-bgp-passwords
in the kube-system Namespace (assuming that Antrea is installed in the Namespace).
The secret might be like this:
apiVersion: v1
kind: Secret
metadata:
name: antrea-bgp-passwords
namespace: kube-system
type: Opaque
data:
192.168.1.1-65512: dmVyeS1zZWNyZXQ=
192.168.1.2-65513: dmVyeS1zZWNyZXQ=
Antrea needs the permission get
, maybe watch
(to watch the update of the secret)
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- watch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just support the Secret-based method.
The idea of having a single Secret, with a well-known name, mapping BGP peer IDs to passwords, is fine by me. We can also provide a configuration parameter for users to change the Secret name if they want to.
b75d4e4
to
c279227
Compare
c279227
to
64ad4e6
Compare
dbe84c8
to
89dbe7e
Compare
@@ -88,6 +88,9 @@ featureGates: | |||
# Enable L7FlowExporter on Pods and Namespaces to export the application layer flows such as HTTP flows. | |||
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "L7FlowExporter" "default" false) }} | |||
|
|||
# Allow users to advertise Service IPs, Pod IPs, and Egress IPs to external BGP peers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with Pod IPs you meant Pod CIDR here, better to change it to pod CIDR instead
89dbe7e
to
30290bc
Compare
db865f7
to
f90e052
Compare
BGPPeers []BGPPeer `json:"bgpPeers,omitempty"` | ||
} | ||
|
||
type Advertisements struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated Advertisements
pkg/apis/crd/v1alpha1/types.go
Outdated
NodeSelector *metav1.LabelSelector `json:"nodeSelector"` | ||
|
||
// LocalASN is the AS number used by the BGP process. | ||
LocalASN *int32 `json:"localASN,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it have a default value? If not, it shouldn't be a pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it should be a pointer as long as it is optional, regardless of whether or not there is a non-zero default value. It's easier to stick to that rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed it's not optional, there should always be a ASN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point now.
Yes, there should always be an ASN, but the question is does it make sense to default the ASN to 64512
or should we require users to provide a value every time? @hongliangl if 2 K8s clusters are peering to the same local router, I assume it may create a conflict ? And would there be some conflict if 2 different BGPPolicies in the same cluster (applied to a different subset of Nodes) use the same localASN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this some more, I feel like logically it is perfectly valid to use the same ASN across different BGPPolicies and even different K8s clusters, while peering to the same router. I'll let @hongliangl comment but I think the current API version works well.
Edit: if one wants to use eBGP to provide Pod-to-Pod connectivity between 2 K8s cluster connected to the same BGP router, then maybe using different localASNs will be required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if 2 K8s clusters are peering to the same local router, I assume it may create a conflict ?
As long as the Node IPs of these 2 k8s clusters are not the same, it's okay for the local router regardless of the value of the ASN. Ideally, each k8s cluster should be treated as an AS, given its fully meshed network implemented by CNI, and the cluster should be assigned a unique ASN. If two k8s clusters use the same ASN, but the network between them is not fully reachable, for the local router, there might be potential BGP issues (I'm not sure what it might be)
And would there be some conflict if 2 different BGPPolicies in the same cluster (applied to a different subset of Nodes) use the same localASN?
In a k8s cluster, all BGPPolicies should use the same ASN as the description above, but it's okay that every Node has its unique ASN.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: if one wants to use eBGP to provide Pod-to-Pod connectivity between 2 K8s cluster connected to the same BGP router, then maybe using different localASNs will be required?
It should work using the same localASN, but it is a little weird. Normally, the traffic within an AS (the source and destination are in the same AS) should only be forwarded in this AS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the Node IPs of these 2 k8s clusters are not the same
Is this a valid case anyway? I guess it is with different VRFs
We are getting into advanced use cases. I do agree that the recommendation should be that 2 clusters connected to the same BGP router should use different localASNs, and we can include that in the documentation.
But to go back to @tnqn's original point, maybe we should err on the side of caution and require users to explicitly provide a private ASN? Then we would ensure that users are well-aware of this parameter and configure it appropriately for their use case. It seems like a very small inconvenience, especially considering the fact that users may need to also configure the uplink router to authorize peering for this ASN (I guess that depends on the uplink router's configuration).
How do you feel about making this a required parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But to go back to @tnqn's original point, maybe we should err on the side of caution and require users to explicitly provide a private ASN? Then we would ensure that users are well-aware of this parameter and configure it appropriately for their use case. It seems like a very small inconvenience, especially considering the fact that users may need to also configure the uplink router to authorize peering for this ASN (I guess that depends on the uplink router's configuration).
That makes sense to me. Anyway, when users configure the uplink router, they need to set the BGP peers by specifying peer IPs and ASNs. Maybe it's better for users to set the localASN
since it is also needed by the configuration of the uplink router.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the Node IPs of these 2 k8s clusters are not the same
Is this a valid case anyway? I guess it is with different VRFs
If I understand correctly, for different VRFs in multiple k8s clusters, and the Nodes in these clusters connect to the same uplink router, the IPs of the Node should not overlap, and then each Node can establish a BGP session with the uplink router. Did I miss some background information on your question?
format: int32 | ||
minimum: 64512 | ||
maximum: 65535 | ||
default: 64512 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with this, just want to confirm if it's typical to assign a default local ASN and the default number works in most cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a K8s cluster, the network is fully reachable and implemented by CNI, and the cluster could be treated as an AS (for traditional network, the network is implemented by IGP protocols like OSPF, EIGRP, etc.).
For multiple K8s clusters, at least the network of each cluster is fully reachable. Ideally, every cluster should be treated as an AS, but it's okay for these clusters to use the same ASN when peering to the same router as long as they don't have overlapped Node IPs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a K8s cluster, it is also okay that different Nodes use different ASNs to peer to the same router.
ccc4e92
to
46462cd
Compare
pkg/apis/crd/v1alpha1/types.go
Outdated
ClusterIPs *bool `json:"clusterIPs,omitempty"` | ||
|
||
// Advertise ExternalIPs of the selected Services (currently all Services without Service selector) if this is set to | ||
// true. Otherwise, no ExternalIPs will be advertised. | ||
ExternalIPs *bool `json:"externalIPs,omitempty"` | ||
|
||
// Advertise LoadBalancerIPs of the selected Services (currently all Services without Service selector) if this is set to | ||
// true. Otherwise, no LoadBalancerIPs will be advertised. | ||
LoadBalancerIPs *bool `json:"loadBalancerIPs,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why these booleans are pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #6009 (comment)
fac6a0c
to
6c9d01e
Compare
} | ||
|
||
// BGPPolicySpec defines the specification for a BGPPolicy. | ||
type BGPPolicySpec struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated some comments of the spec. I would appreciate it if you could help review them for appropriateness and ease of understanding. @antoninbas @tnqn @luolanzone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
required: | ||
- nodeSelector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think localASN
should be added to the required properties after the recent changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot adding this. Will add it. Thanks for pointing out it.
Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
6c9d01e
to
2cb6c19
Compare
/skip-all |
@hongliangl please remember to update docs/api.md in a future PR |
Done with #6457 |
No description provided.