Skip to content
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

Allow API server LB frontend port to be configured #1207

Closed

Conversation

tuommaki
Copy link

@tuommaki tuommaki commented Mar 4, 2021

/kind feature

Description:
This change allows API server LB frontend port to be configured separately from the API server listen port. The code uses Cluster CR's Spec.ControlPlaneEndpoint.Port as LB frontend port, given it is defined. Otherwise the API server listen port is used as the implementation was before.

This change implements following proposal: #1240

Common use case for this would be:
API LB is listening in default HTTPS port (443) while workload cluster control plane node uses default (6443) for API server listen port.

Special notes for your reviewer:
Depending on situation, this might require user action on existing clusters if control plane endpoint port is configured but earlier LB defaulting has been used.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Use `Cluster` CR's `Spec.ControlPlaneEndpoint.Port` as LB frontend port if it's defined. User action is needed if the said port is defined but differs from `Spec.ClusterNetwork.APIServerPort`.

This change allows API server LB frontend port to be configured
separately from the API server listen port. The code uses Cluster CR's
ControlPlaneEndpoint.Port as LB frontend port if it is defined.
Otherwise the API server listen port is used as the implementation was
before.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Mar 4, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign fabriziopandini after the PR has been reviewed.
You can assign the PR to them by writing /assign @fabriziopandini in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/provider/azure Issues or PRs related to azure provider sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. labels Mar 4, 2021
@k8s-ci-robot k8s-ci-robot requested a review from alexeldeib March 4, 2021 08:37
@k8s-ci-robot
Copy link
Contributor

Welcome @tuommaki!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-azure 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-azure has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @tuommaki. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 4, 2021
@k8s-ci-robot k8s-ci-robot requested a review from juan-lee March 4, 2021 08:37
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 4, 2021
@CecileRobertMichon
Copy link
Contributor

CecileRobertMichon commented Mar 4, 2021

Thanks for the PR @tuommaki! Could you please document how to set both ports in https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/master/docs/book/src/topics/api-server-endpoint.md ?

Also, does this change impact the guidance on allowing inbound ports in vnet security groups https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/master/docs/book/src/topics/custom-vnet.md ? And does it impact the default ingress rules we generate https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/master/azure/scope/cluster.go#L507

@tuommaki
Copy link
Author

tuommaki commented Mar 5, 2021

Hi Cecile and thanks for the initial feedback!

Could you please document how to set both ports

Sure, I will.

does this change impact the guidance on allowing inbound ports in vnet security groups

Based on my understanding no, because this change won't affect the CP node listen port.

does it impact the default ingress rules we generate

This one I'm not sure and I'll perform further tests to find out. 👍

@CecileRobertMichon
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 5, 2021
@shysank
Copy link
Contributor

shysank commented Mar 10, 2021

@tuommaki Thanks for the PR! Can you create an issue for this and link it in the pr description for tracking?

@tuommaki
Copy link
Author

does it impact the default ingress rules we generate

Ok. I did additional testing to verify this and I cannot observe any impacts. The default ingress rule linked earlier matches for apiserver listen port, but this PR doesn't change any behavior related to that.

This only affects the LB public facing configuration which affects LB rules but those work both with defaults and with configuration e.g. from 443 -> 6443.

I also created the issue and linked it in proposal.

@tuommaki
Copy link
Author

I'll write the missing documentation next.

@@ -457,6 +458,15 @@ func (s *ClusterScope) AdditionalTags() infrav1.Tags {
return tags
}

// APIServerLBFrontendPort returns the frontend listen port to use when creating the load balancer.
func (s *ClusterScope) APIServerLBFrontendPort() int32 {
if s.Cluster.Spec.ControlPlaneEndpoint.Port > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is still not 100% clear to me is the relationship between Cluster.Spec.ControlPlaneEndpoint and AzureCluster.Spec.ControlPlaneEndpoint

We set AzureCluster.Spec.ControlPlaneEndpoint in the AzureCluster controller here (to follow the CAPI provider contract): https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/master/controllers/azurecluster_controller.go#L256-L260

I had opened a discussion in CAPI a while back about moving it to Status since it's basically being used as status right now (and any user value will be overridden) kubernetes-sigs/cluster-api#3715

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the CAPI cluster_controller, Cluster.Spec.ControlPlaneEndpoint is set to the value of AzureCluster.Spec.ControlPlaneEndpoint https://github.com/kubernetes-sigs/cluster-api/blob/master/controllers/cluster_controller_phases.go#L184

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I didn't realize to think from this perspective.

My original use case for this change was to provide migration compatibility when converting existing Kubernetes cluster (Giant Swarm flavor in this case) into one managed by CAPZ. The cluster is already reconciled by v1alpha3 CAPI + CAPZ CRs and there's DNS zone managed for the workload cluster.

I was also viewing the Cluster CR as main spec for provider independent workload cluster configuration since it also has several important network configuration fields (e.g. Service and POD CIDRs as well as API server listen port).

Now I see that my understanding / interpretation on that is slightly off from the present implementation and interoperability between different controllers.

Do you think this change would still make sense in CAPZ?

As far as I was able to reason & test, this change should be fully compatible with present state, but I do understand that there's the corner case that one might not be able to configure just port because the host must be set as well and something needs to manage that. I'm not sure if that can be fixed in any way right now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also viewing the Cluster CR as main spec for provider independent workload cluster configuration since it also has several important network configuration fields (e.g. Service and POD CIDRs as well as API server listen port).

Right, that's why it's confusing. I think it's a bug that providers don't honor that field, that's why I opened kubernetes-sigs/cluster-api#3715.

I think as long as it has no effect on current behaviors for those who don't set the port & for existing clusters that have the default port, it should be ok to make this change to unblock your use case. However in that case we should remove the user facing documentation since it's not really a configuration option, but more of a workaround. Also let's make sure there are solid comments in the code so we know exactly why this was done and what the expected bahavior is when we look at this code again 6 months from now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for long delays, we have been recently working on different areas so this was not high priority. Because of this controversial nature of this feature and the fact that we don't urgently need this right now, I'll take more time to consider this. I'll get back to this later. Thanks for your patience 🙂

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 8, 2021
@k8s-ci-robot
Copy link
Contributor

@tuommaki: 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.

@CecileRobertMichon
Copy link
Contributor

Sorry for long delays, we have been recently working on different areas so this was not high priority. Because of this controversial nature of this feature and the fact that we don't urgently need this right now, I'll take more time to consider this. I'll get back to this later. Thanks for your patience 🙂

Going to close the PR for now, feel free to reopen when it's ready for review again

/close

@k8s-ci-robot
Copy link
Contributor

@CecileRobertMichon: Closed this PR.

In response to this:

Sorry for long delays, we have been recently working on different areas so this was not high priority. Because of this controversial nature of this feature and the fact that we don't urgently need this right now, I'll take more time to consider this. I'll get back to this later. Thanks for your patience 🙂

Going to close the PR for now, feel free to reopen when it's ready for review again

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants