-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 externallyManagedReplicaCount field to MachinePool #5685
✨ Add externallyManagedReplicaCount field to MachinePool #5685
Conversation
0dd1e56
to
4481e9b
Compare
// Whether the Replicas value is externally managed. This is useful when | ||
// the infrastructure is a managed machine pool, or if the cluster-autoscaler is scaling | ||
// the underlying cloud infrastructure directly outside of cluster-api. Set this to true | ||
// if you wish the replica count to be managed outside of cluster-api. Defaults to false. | ||
// +optional | ||
ExternallyManagedReplicaCount *bool `json:"externallyManagedReplicaCount,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.
Is this field used anywhere?
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.
It will be used to signal to the infrastructure provider that it is responsible for managing the spec.replicas
and relevant status fields on the MachinePool. So there is no implementation code in the MachinePool itself yet. That may change a little as the MachinePool Machines implementation begins though.
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 this is intended to be a stop gap until more mature support in Cluster Autoscaler, did you consider something a little more temporary, like an annotation?
@devigned It is intended for more than a temporary stop gap, though stop gap is one use case. Some other example use cases are listed above. This field is intended to provide flexibility and permit cluster operator choice of scaler software. Without this field, cluster operators that wish to use external scaling tools are blocked from using cluster-api to manage node pools. That seems unnecessarily restrictive. If we place this in an annotation instead, it seems likely to me this will be a very long lived annotation, especially considering developers of other scaling solutions may never target scaling via cluster API. It assumes at some point in the future we intend to make cluster API incompatible with underlying managed cloud features or external software that manipulate the pools outside of cluster API. MachinePools were originally conceived to support this exact use case and it is a key differentiator from MachineDeployments. One that we use heavily today and others also wish to do. |
I can rebase this tonight to resolve merge conflicts but is there anything preventing this from being merged? I'd like to start on the AWSMachinePool implementation soon. |
I don't think this is something that the MachinePool Machines proposal requires, so no objections there. It does seem odd to add a field that isn't used by any logic in CAPI, just in infra providers. But I understand your use case and see how it could be useful in certain cluster-autoscaler configurations like AKS, so 👍🏻 . |
4481e9b
to
076597a
Compare
Hey guys is there an update here? |
@xvzf My apologies, I fell behind on this. I'll rebase this PR today. Most of the maintainers are out for holidays but I expect this should get merged quickly once folks return. |
076597a
to
f393a8d
Compare
f393a8d
to
b5889a6
Compare
This seems to me a natural case to differentiate nil from zero. The semantic could be included into the existing machinePool.Replicas field. machinePool.Replicas=nil then machinePool.status.replicasExternallyManaged=true. Then each implementation reacts appropriately. |
@enxebre @fabriziopandini @vincepri @CecileRobertMichon
Based on first hand experience using this at scale, using a I think regarding the concern that there is no logic in this controller currently that uses this field, I do think that will change as we implement MachinePool Machines. This field could be used to signal to the machinepool controller whether it is responsible for creating Machines or whether the infrastructure provider will be doing it. |
What would be the expected behavior if using an |
Correct, that is how it behaves in our fork today. The infrastructure provider keeps the spec.replicas field on the machinepools object up to date with the actual replicas value it observes in the cloud provider. This provided a nice feedback loop and fixed the UX issues for our cluster operators. |
// the infrastructure is a managed machine pool, or if the cluster-autoscaler is scaling | ||
// the underlying cloud infrastructure directly outside of cluster-api. Set this to true | ||
// if you wish the replica count to be managed outside of cluster-api. Defaults to false. | ||
// +optional |
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 document this property and the (expected) behavior of infra providers in the book (https://cluster-api.sigs.k8s.io/developer/architecture/controllers/machine-pool.html#infrastructure-provider)?
I assume this logic in the core MachinePool controller won't change when ExternallyManagedReplicaCount is set?
After the machine pool controller sets the OwnerReferences on the associated objects, it waits for the bootstrap and infrastructure objects referenced by the machine to have the Status.Ready field set to true. Then the infrastructure object is ready, the machine pool controller will attempt to read its spec.ProviderIDList and copy it into MachinePool.Spec.ProviderIDList.
The machine pool controller uses the kubeconfig for the new workload cluster to watch new nodes coming up. When a node appears with a Node.Spec.ProviderID in MachinePool.Spec.ProviderIDList, the machine pool controller increments the number of ready replicas. When all replicas are ready and the infrastructure ref is also Ready, the machine pool controller marks the machine pool as Running.
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, I will definitely update the book. And also yes, the logic you mention does not change.
Hey @dthorsen great to hear we are coming here with real use feedback already. Some thoughts:
I see what you mean. In any case let's make sure we document exhaustively so
I see these problems as cosmetic consequences to be approached individually rather than as a driving force to come up with the best design for user input experience.
This sounds pretty reasonable to me although peculiar because you are effectively treating spec.replicas as status to satisfy existing core controller assumptions with your particular implementation. This use case seems to me more like a provider specific field for awsmachinepool. I think externallyManagedReplicaCount naming is confusing since any external out of band controller adding smart scaling e.g capi provider autoscaling would modify spec.replicas naturally without enabling externallyManagedReplicaCount, right? Based on this reasoning I'm curious have you considered this use case (aws provider scaling instead of capi) to be supported by |
@dthorsen: PR needs rebase. 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. |
@dthorsen @fabriziopandini hey gents! have you came into any conclusion for the case? |
FWIW, I use an own version of this fix which requires no changes in CAPI (uses an annotation instead) in my fork: https://github.com/kubernetes-sigs/cluster-api-provider-aws/compare/main...helio:externally-managed?expand=1 I haven't yet tested it well enough to be in any way contributable, but in case anyone is looking for a way to implement this, have a look :) |
Getting back to this after the 20th Apr office hour discussion. I don't want to block this PR and I'm happy to adapt to whatever the community agrees on given that it can unblock so many use cases and help people to un-fork. Personally, for sake of consistency with what we already have in the project, I like the idea of using
I also agree with @enxebre that Instead, using annotation named on capabilities like e.g |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Anything we can do to help move this forward? We'd still very much like to see this functionality implemented. |
+1 to using an annotation to surface information to the user that replicas are being ignored / managed by an autoscaler or other external process In kubernetes-sigs/cluster-api-provider-azure#2444 we've been going back and forth on this for AzureManagedClusters specifically and it looks like we're going to land on the following:
|
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
/reopen |
@Skarlso: Reopened this PR. In response to this:
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@dthorsen: The following tests 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. |
@dthorsen I know this has been quite some time, and frankly, I don't understand why we aren't just moving forward with this after years of discussions. Having something is still better than nothing or things that just don't work. We can always fix it later if there is a bug, or we can adjust things. Just have SOMETHING. I'm asking if someone might still review this, please, as it would be a great help. I don't care about the annotations-based approach, to be honest. I don't see the value, but others might. However, that could easily be a followup to this added as a separate ticket. WDYT? |
@Skarlso There has been progress on the annotation-based approach, and that will fulfill the use-case here. Given the current traction of the annotation approach I propose we close this issue and pursue completion of the annotation-based solution. |
Okay, that's a fair point. |
/close |
@Skarlso: Closed this PR. In response to this:
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. |
What this PR does / why we need it:
User Story
As a cluster operator, I would like to have the option to utilize external scaling applications for autoscaling infrastructure managed under a MachinePool so that we can take advantage of the capabilities of existing infrastructure scaling tools if we chose.
Detailed Description
There are many potential scaler implementations that support things like AWS ASG and Azure VMSS. With a small change, cluster-api can be made to optionally allow external software to manage the scaling of the node pools without needing to have support for cluster-api. Some examples of scalers that would benefit from this solution are:
Kubernetes cluster-autoscaler using the existing cloud-provider implementations. This provides a stopgap while cluster-autoscaler's support for CAPI MachinePools to mature and reach feature parity with the existing cloud provider implementations. Incidentally, this would also allow the CAPZ provider add AKS' native managed node pool autoscaling support, which provides an fully-managed installation of cluster-autoscaler on the AKS control plane itself completely managed by the cloud provider, Azure.
Atlassian escalator
Spotinst (an infrastructure provider for spotinst does not yet exist but interest has been expressed by the community for one to exist)
Fixes #5658