-
Notifications
You must be signed in to change notification settings - Fork 430
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 support to use different subnets in different node pools #1411
Add support to use different subnets in different node pools #1411
Conversation
Hi @fiunchinho. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
eeaaabf
to
f2b6595
Compare
be95c69
to
24246df
Compare
24246df
to
eb1eb0b
Compare
673484f
to
c0ca96f
Compare
api/v1alpha4/azurecluster_default.go
Outdated
var nodeSubnetFound bool | ||
var nodeSubnetCounter int | ||
for i := range c.Spec.NetworkSpec.Subnets { | ||
if c.Spec.NetworkSpec.Subnets[i].Role == SubnetNode { |
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.
To keep the same spirit as before, we only require users to specify subnet name and role when specifying subnets. The rest of the fields will be defaulted. That's why we need DefaultNodeSubnetCIDRPattern
, so we can generate different cidrs for different subnets.
|
||
// SubnetName selects the Subnet where the VM will be placed | ||
// +optional | ||
SubnetName string `json:"subnetName,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.
This field is optional so that the code keeps working with existing manifests. In the future we may think about changing it to 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.
should we add validation to make it required when there is more than one subnet specified? otherwise it could be ambiguous
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.
Just to clarify: is your concern addressed by this? https://github.com/kubernetes-sigs/cluster-api-provider-azure/pull/1411/files#diff-b6931ac61f37a13f66fc7836e039bf714a0553d5db4f313cc8ef31ca5f5647b9R542-R563
3a9c884
to
130bf20
Compare
/test pull-cluster-api-provider-azure-e2e-windows |
/test pull-cluster-api-provider-azure-e2e |
130bf20
to
c1426fe
Compare
@shysank @CecileRobertMichon I believe I addressed all the comments, please take a look, thank you!! |
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.
Could you please add some docs about this in https://capz.sigs.k8s.io/topics/custom-vnet.html ?
} | ||
} | ||
|
||
// If Nat Gateway is not enabled, then the NIC needs to reference the LB to get outbound traffic. |
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.
Yes, make sense. Thanks for the detailed explanation. Is it possible to abstract the details in machineScope.Subnet()
, and perhaps add a method Subnet.IsNatGatewayEnabled()
so that we can do something like m.Subnet().IsNatGatewayEnabled()
ID: azure.NatGatewayID(s.Scope.SubscriptionID(), s.Scope.ResourceGroup(), natGatewaySpec.Name), | ||
Name: natGatewaySpec.Name, | ||
NatGatewayIP: infrav1.PublicIPSpec{ | ||
Name: *(*natGatewayToCreate.NatGatewayPropertiesFormat.PublicIPAddresses)[0].ID, |
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.
We'll either need to create a new field ID
for public ip spec, or not set it. There was an issue reported for this: #1525
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 changed it so that it uses the name instead of the ID.
azure/scope/machine.go
Outdated
// SetSubnetName defaults the AzureMachine subnet name defined when empty to the name of the subnet with role 'node' where there is only one of them. | ||
// Note: this logic exists only for purposes of ensuring backwards compatibility for old clusters created without the `subnetName` field being set, and should be removed in the future. |
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.
IIUC, this also handles setting subnet name for control plane nodes. Unless, we are planning to implement multiple subnets for cp nodes, this is cannot be removed, I think.
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 plan would be to make the subnetName
field to be mandatory. Once that happens, this logic is not needed anymore. The same applies for both control-plane
and node
subnets.
I will tweak the comment a bit, because it only refers to node
subnets, and as you mentioned, it also applies to the control-plane
subnet.
d54fdd9
to
b0db456
Compare
/test pull-cluster-api-provider-azure-e2e |
b0db456
to
0f4a838
Compare
@fiunchinho: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I added some docs, PTAL. |
/lgtm Awesome work @fiunchinho! Thanks for being patient with the reviews! |
/label tide/merge-method-squash |
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
/approve
thanks for leaving the code cleaner than you found it 🧹
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
It allows to define several different subnets for nodes, not just one. Then we can specify the subnet to use when creating
AzureMachines
orAzureMachinePools
.Which issue(s) this PR fixes:
Fixes #664
Fixes #1362
Special notes for your reviewer:
I kept the role field in the subnets. I think it's still useful to see that a subnet is for control-plane or for the nodes.
I've added a new
SubnetName
field , but if it's empty, capz will try to find the right subnet to use. This makes the code work with some already existing scenarios.Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: