Skip to content

Commit

Permalink
Refactor the Azure plugin
Browse files Browse the repository at this point in the history
Both Kopia repository and Azure plugin need to interact with Azure storage. In order to keep in sync with the new features for both these two places and remove duplicated code, PR vmware-tanzu/velero#6686 makes the common code as util functions in Velero repository.

This commit refactors the Azure plugin based on these util functions.

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
  • Loading branch information
ywk253100 committed Sep 20, 2023
1 parent 5ac1aab commit b7732e8
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 518 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,10 @@ There are two ways to specify the role: use the built-in role or create a custom
AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET}
AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
AZURE_CLOUD_NAME=AzurePublicCloud
AZURE_ENVIRONMENT=AzurePublicCloud
EOF
```
> Available values for `AZURE_CLOUD_NAME` and `AZURE_ENVIRONMENT`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`. `AZURE_ENVIRONMENT` is NOT required for `AzurePublicCloud`
> Available values for `AZURE_CLOUD_NAME`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`
### Option 2: Use Azure AD Workload Identity
Expand Down Expand Up @@ -395,11 +394,10 @@ Before proceeding, ensure that you have installed [workload identity mutating ad
AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID}
AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
AZURE_CLOUD_NAME=AzurePublicCloud
AZURE_ENVIRONMENT=AzurePublicCloud
EOF
```
> Available values for `AZURE_CLOUD_NAME` and `AZURE_ENVIRONMENT`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`. `AZURE_ENVIRONMENT` is NOT required for `AzurePublicCloud`
> Available values for `AZURE_CLOUD_NAME`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`
### Option 3: Use storage account access key
Expand All @@ -418,11 +416,10 @@ _Note: this option is **not valid** if you are planning to take Azure snapshots
cat << EOF > ./credentials-velero
AZURE_STORAGE_ACCOUNT_ACCESS_KEY=${AZURE_STORAGE_ACCOUNT_ACCESS_KEY}
AZURE_CLOUD_NAME=AzurePublicCloud
AZURE_ENVIRONMENT=AzurePublicCloud
EOF
```
> Available values for `AZURE_CLOUD_NAME` and `AZURE_ENVIRONMENT`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`. `AZURE_ENVIRONMENT` is NOT required for `AzurePublicCloud`
> Available values for `AZURE_CLOUD_NAME`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`
## Install and start Velero
Expand Down Expand Up @@ -491,7 +488,7 @@ After that update your velero BackupStorageLocation with the useAAD flag as show
velero backup-location set default --provider azure --bucket $BLOB_CONTAINER --config useAAD="true",resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,storageAccount=$AZURE_STORAGE_ACCOUNT_ID[,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID]
```
Limitation: Listing storage account access key is still needed for Restic/Kopia to work as expected on Azure. Tracking Issue: [#5984](https://github.com/vmware-tanzu/velero/issues/5984). The useAAD route won't accrue to them and users using kopia/restic should not remove the ListKeys permission from the velero identity.
Limitation: Listing storage account access key is still needed for Restic to work as expected on Azure. The useAAD route won't accrue to it and users using Restic should not remove the ListKeys permission from the velero identity.
### If using storage account access key and no Azure snapshots:
Expand Down
47 changes: 25 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,45 @@ module github.com/vmware-tanzu/velero-plugin-for-microsoft-azure
go 1.18

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0
github.com/gofrs/uuid v4.3.1+incompatible
github.com/joho/godotenv v1.4.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.2
github.com/vmware-tanzu/velero v0.0.0-20230727074327-a6d79fc272a2
github.com/stretchr/testify v1.8.4
github.com/vmware-tanzu/velero v1.10.0-rc.1.0.20230920021852-d3e5bb745144
k8s.io/api v0.26.0
k8s.io/apimachinery v0.26.0
sigs.k8s.io/azuredisk-csi-driver v1.26.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.3.0 // indirect
github.com/joho/godotenv v1.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/hashicorp/go-hclog v1.4.0 // indirect
github.com/hashicorp/go-plugin v1.4.8 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand All @@ -47,7 +51,7 @@ require (
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -58,17 +62,16 @@ require (
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit b7732e8

Please sign in to comment.