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: add Azure China/German support #1836

Closed

Conversation

andyzhangx
Copy link

@andyzhangx andyzhangx commented Sep 4, 2019

What type of PR is this?
/kind feature

What this PR does / why we need it:

This PR adds a new env var(AZURE_CLOUD_NAME) in azure environment config, available values could be: AzurePublicCloud, AzureUSGovernmentCloud, AzureChinaCloud, AzureGermanCloud

If env var(AZURE_CLOUD_NAME) is not set, AzurePublicCloud would be the default, so it's compatible.

Which issue(s) this PR fixes:

Fixes #287

Special notes for your reviewer:

Release note:

add azure china support

@andyzhangx
Copy link
Author

cc @skriss for code review

@andyzhangx andyzhangx changed the title feat: add azure china support [WIP]feat: add azure china support Sep 4, 2019
@nrb nrb requested review from skriss and nrb September 4, 2019 15:59
@andyzhangx andyzhangx changed the title [WIP]feat: add azure china support feat: add azure china support Sep 5, 2019
@andyzhangx
Copy link
Author

Test pass on Azure China cloud, someone could take a code reivew? Thanks.
cc @carlisia @ncdc

Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Handful of comments @andyzhangx. The main question to resolve is whether we want to specify this as an env var (i.e. in the secret), or as a config item in the BackupStorageLocation and VolumeSnapshotLocation. Interested in others' thoughts on this.

pkg/cloudprovider/azure/common.go Show resolved Hide resolved
}

func getRequiredValues(getValue func(string) string, keys ...string) (map[string]string, error) {
missing := []string{}
results := map[string]string{}

for _, key := range keys {
if val := getValue(key); val == "" {
if val := getValue(key); val == "" && key != cloudNameEnvVar {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this special case, since the cloud name is not a required value. see next comment.

// 1. we need AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID
envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar)
// 1. we need AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_CLOUD_NAME
envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar, cloudNameEnvVar)
Copy link
Contributor

Choose a reason for hiding this comment

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

Regardless of whether we go with the env var or the config key, I would have separate code to try to get its value since it's not a required item. See previous comment as well.

pkg/cloudprovider/azure/object_store.go Show resolved Hide resolved
// 1. we need AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP
envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar, resourceGroupEnvVar)
// 1. we need AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_CLOUD_NAME
envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar, resourceGroupEnvVar, cloudNameEnvVar)
Copy link
Contributor

Choose a reason for hiding this comment

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

similar to for object store, I would fetch the cloud name outside of the getRequiredValues call, since it's not a required value.

@andyzhangx
Copy link
Author

thanks guys for the review.
In the future, I would like to be a reviewer of this azure cloud provider code since I have been working on k8s on Azure for more than 2 years, mainly focus on azure storage part.

@skriss
Copy link
Contributor

skriss commented Sep 9, 2019

In the future, I would like to be a reviewer of this azure cloud provider code since I have been working on k8s on Azure for more than 2 years, mainly focus on azure storage part.

@andyzhangx that'd be great! For now, we can tag you on any PRs that come in for the Azure code. We're also working on separating the in-tree cloud provider plugins out into their own repos, so once we have a velero-plugin-azure repo it'll be easier for you to track any Azure-specific changes.

Here's our current backlog of Azure-related items: https://github.com/heptio/velero/issues?q=is%3Aopen+is%3Aissue+label%3ACloud%2FAzure

@andyzhangx
Copy link
Author

In the future, I would like to be a reviewer of this azure cloud provider code since I have been working on k8s on Azure for more than 2 years, mainly focus on azure storage part.

@andyzhangx that'd be great! For now, we can tag you on any PRs that come in for the Azure code. We're also working on separating the in-tree cloud provider plugins out into their own repos, so once we have a velero-plugin-azure repo it'll be easier for you to track any Azure-specific changes.

Here's our current backlog of Azure-related items: https://github.com/heptio/velero/issues?q=is%3Aopen+is%3Aissue+label%3ACloud%2FAzure

Sure, I could take the code review for any Azure related PR.
So is it ok to merge this PR? @skriss Do I need to fix anything more on this PR? Thanks.

@andyzhangx andyzhangx changed the title feat: add azure china support feat: add Azure China/German support Sep 10, 2019
@skriss
Copy link
Contributor

skriss commented Sep 10, 2019

@andyzhangx I'd stil like to move the code to get the AZURE_CLOUD_NAME value out of the "required values" code path since it's not a required value - see three comments from original review.

@skriss
Copy link
Contributor

skriss commented Sep 19, 2019

@andyzhangx just checking in to see if you needed any more input on the requested code changes?

@skriss
Copy link
Contributor

skriss commented Sep 25, 2019

@andyzhangx checking in again to see if you'd be able to make the requested revisions; if not I can take this over and give you credit for commits made.

@andyzhangx
Copy link
Author

@andyzhangx checking in again to see if you'd be able to make the requested revisions; if not I can take this over and give you credit for commits made.

hi @skriss I am a little busy these two weeks, it's great if you could take over, thanks.

@skriss
Copy link
Contributor

skriss commented Oct 4, 2019

I've updated this in #1938, closing this one out.

@skriss skriss closed this Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for storage in Azure Germany
4 participants