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

[Feat] Multi region support (Topology Aware Provisioning) #280

Merged
merged 23 commits into from
Oct 11, 2024

Conversation

komer3
Copy link
Contributor

@komer3 komer3 commented Oct 4, 2024

Overview

This PR enhances the CSI driver's controller server to provision volumes in regions outside of its deployment region. The improvement allows for more flexible and efficient volume management across different geographical locations.

Key Concepts

  • Remote Region: A region where worker nodes are deployed, separate from the control plane region.
    Example: Control plane in us-ord, worker node in us-central.

Current Deployment Setup

  • Controller server: Deployed on worker nodes
  • Node servers: Deployed as a DaemonSet on all nodes

Changes Implemented

1. Dynamic Region Detection

  • Previously: Used metadata service in the controller service class to determine the region.
  • Now: Utilizes topology-based dynamic provisioning.

2. Volume Provisioning Process

  • External-provisioner makes an API call to the api-server to retrieve the Linode region.
  • This region information is included in the CreateVolumeRequest object during the CreateVolume gRPC call.
  • Enables volume provisioning in the region where the pod is scheduled.

3. Volume Binding Mode

  • Changed from 'Immediate' to 'WaitForFirstConsumer'.
  • Allows the provisioner time to gather necessary region data before volume creation.

Benefits

  • Improved flexibility in volume provisioning across different regions.
  • Better alignment of volume location with pod scheduling.

General:

  • Have you removed all sensitive information, including but not limited to access keys and passwords?
  • Have you checked to ensure there aren't other open or closed Pull Requests for the same bug/feature/question?

Pull Request Guidelines:

  1. Does your submission pass tests?
  2. Have you added tests?
  3. Are you addressing a single feature in this PR?
  4. Are your commits atomic, addressing one change per commit?
  5. Are you following the conventions of the language?
  6. Have you saved your large formatting changes for a different PR, so we can focus on your work?
  7. Have you explained your rationale for why this feature is needed?
  8. Have you linked your PR to an open issue

Khaja Omer added 6 commits October 3, 2024 19:05
- Updated CreateVolume method to include accessibility requirements.
- Modified attemptCreateLinodeVolume and createLinodeVolume methods to accept and utilize accessibility requirements for region selection.
- Adjusted createAndWaitForVolume to pass accessibility requirements to attemptCreateLinodeVolume.
- Ensured volume context includes the region derived from accessibility requirements.
Copy link

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.

Project coverage is 76.33%. Comparing base (1748a1b) to head (47706e2).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/driver/controllerserver_helper.go 85.71% 3 Missing and 2 partials ⚠️
internal/driver/controllerserver.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #280      +/-   ##
==========================================
+ Coverage   76.32%   76.33%   +0.01%     
==========================================
  Files          21       21              
  Lines        1622     1644      +22     
==========================================
+ Hits         1238     1255      +17     
- Misses        286      289       +3     
- Partials       98      100       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@komer3 komer3 changed the title [Feat] Multi region support - Volume creation (WIP) [Feat] Multi region support (WIP) Oct 8, 2024
@komer3 komer3 changed the title [Feat] Multi region support (WIP) [Feat] Multi region support Oct 9, 2024
@komer3 komer3 marked this pull request as ready for review October 9, 2024 22:53
@komer3 komer3 requested review from a team as code owners October 9, 2024 22:53

#### Provisioning Process

1. CO determines required topology based on application needs and cluster layout.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain what CO is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the doc. Hope its more clear now! Let me know if there is anything else that is unclear :)

return nil, errRegionMismatch(volumeData.Region, cs.metadata.Region)
}

// If a topology is specified, the source volume must be in the same region as the specified topology
if accessibilityRequirements != nil {
if volumeData.Region != accessibilityRequirements.GetPreferred()[0].GetSegments()[VolumeTopologyRegion] {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this guaranteed to be an array of len > 0 && is the key guaranteed to exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its pretty much guaranteed to exist and the first key is going to be the region we want to use.

for more info check this link out! https://kubernetes-csi.github.io/docs/topology.html?highlight=VOLUME_ACCESSIBILITY_CONSTRAINTS#implementing-topology-in-your-csi-driver

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 curious because getRegionFromTopology operates on the same accessibilityRequirements but includes all those checks, Thanks for the link - will check it out!

Copy link
Contributor

Choose a reason for hiding this comment

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

could also use that here - to validate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only time that is not passed (accessibilityRequirements) is when you have a broken multi region cluster (I had this issue while trying to make konnectivity work). In that senario, I'm falling back to using the region from the metadata (region where controller server is running)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Let me include those checks here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it!

```

This example demonstrates how to set up topology-aware provisioning using the Linode Block Storage CSI Driver. The StorageClass defines the provisioner and reclaim policy, while the PersistentVolumeClaim requests storage from this class. The Pod specification shows how to use the PVC and includes a node selector for region-specific deployment.

Copy link
Contributor

Choose a reason for hiding this comment

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

should we also mention that the cluster itself must be started with --feature-gates=CSINodeInfo=true ? https://kubernetes-csi.github.io/docs/topology.html?highlight=VOLUME_ACCESSIBILITY_CONSTRAINTS#kubernetes-cluster-setup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point. Let me add that as well.

Also, that feature flag is going to be turn on by default now with future csi releases

@komer3 komer3 changed the title [Feat] Multi region support [Feat] Multi region support (Topology Aware Provisioning) Oct 10, 2024
@komer3 komer3 merged commit 0c9e508 into main Oct 11, 2024
9 checks passed
@komer3 komer3 deleted the multi-region-support branch October 11, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants