Skip to content

Commit 0ef8676

Browse files
author
Carlisia Campos
authored
Merge pull request #38 from skriss/improve-storage-key-docs
improve docs around using static storage account keys
2 parents b28a8b6 + 290227f commit 0ef8676

File tree

3 files changed

+43
-27
lines changed

3 files changed

+43
-27
lines changed

README.md

+32-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ Below is a listing of plugin versions and respective Velero versions that are co
1717
| v1.0.x | v1.3.x |
1818
| v1.0.x | v1.2.0 |
1919

20+
## Kubernetes cluster prerequisites
21+
22+
Ensure that the VMs for your agent pool allow Managed Disks. If I/O performance is critical,
23+
consider using Premium Managed Disks, which are SSD backed.
24+
2025
## Setup
2126

2227
To set up Velero on Azure, you:
@@ -102,12 +107,16 @@ az storage container create -n $BLOB_CONTAINER --public-access off --account-nam
102107

103108
## Set permissions for Velero
104109

105-
### Kubernetes cluster prerequisites
110+
There are two ways Velero can authenticate to Azure: (1) by using a Velero-specific [service principal][17]; or (2) by using a storage account access key.
106111

107-
Ensure that the VMs for your agent pool allow Managed Disks. If I/O performance is critical,
108-
consider using Premium Managed Disks, which are SSD backed.
112+
If you plan to use Velero to take Azure snapshots of your persistent volume managed disks, you **must** use the service principal method.
109113

110-
### Get resource group for persistent volume snapshots
114+
If you don't plan to take Azure disk snapshots, either method is valid.
115+
116+
117+
### Option 1: Create service principal
118+
119+
#### Get resource group containing your VMs/disks
111120

112121
_(Optional) If you decided to backup to a different Subscription, make sure you change back to the Subscription
113122
of your cluster's resources before continuing._
@@ -129,11 +138,7 @@ of your cluster's resources before continuing._
129138

130139
Get your cluster's Resource Group name from the `ResourceGroup` value in the response, and use it to set `$AZURE_RESOURCE_GROUP`.
131140
132-
### Create service principal
133-
134-
To integrate Velero with Azure, you must create a Velero-specific [service principal][17].
135-
136-
_(Optional) When you do not need to create volume snapshots, you can use [storage account access key][10] instead._
141+
#### Create service principal
137142
138143
1. Obtain your Azure Account Subscription ID and Tenant ID:
139144
@@ -164,7 +169,7 @@ _(Optional) When you do not need to create volume snapshots, you can use [storag
164169
AZURE_CLIENT_ID=`az ad sp list --display-name "velero" --query '[0].appId' -o tsv`
165170
```
166171

167-
1. Now you need to create a file that contains all the environment variables you just set. The command looks like the following:
172+
1. Now you need to create a file that contains all the relevant environment variables. The command looks like the following:
168173

169174
```bash
170175
cat << EOF > ./credentials-velero
@@ -179,17 +184,17 @@ _(Optional) When you do not need to create volume snapshots, you can use [storag
179184
180185
> available `AZURE_CLOUD_NAME` values: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`, `AzureGermanCloud`
181186
182-
### Set storage account access key
187+
### Option 2: Use storage account access key
183188
184-
_(Optional) To integrate Velero with Azure, you can use storage account key instead of service principal._
189+
_Note: this option is **not valid** if you are planning to take Azure snapshots of your managed disks with Velero._
185190
186191
1. Obtain your Azure Storage account access key:
187192
188193
```bash
189194
AZURE_STORAGE_ACCOUNT_ACCESS_KEY=`az storage account keys list --account-name $AZURE_STORAGE_ACCOUNT_ID --query "[?keyName == 'key1'].value" -o tsv`
190195
```
191196
192-
1. Now you need to create a file that contains all the environment variables you just set. The command looks like the following:
197+
1. Now you need to create a file that contains all the relevant environment variables. The command looks like the following:
193198
194199
```bash
195200
cat << EOF > ./credentials-velero
@@ -200,14 +205,14 @@ _(Optional) To integrate Velero with Azure, you can use storage account key inst
200205
201206
> available `AZURE_CLOUD_NAME` values: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`, `AzureGermanCloud`
202207
203-
1. Set name of the variable with access key stored in `credentials-velero` using `--backup-location-config` option see [additional configurable parameters][7].
204-
205208
## Install and start Velero
206209
207210
[Download][4] Velero
208211
209212
Install Velero, including all prerequisites, into the cluster and start the deployment. This will create a namespace called `velero`, and place a deployment named `velero` in it.
210213
214+
**If using service principal:**
215+
211216
```bash
212217
velero install \
213218
--provider azure \
@@ -218,6 +223,18 @@ velero install \
218223
--snapshot-location-config apiTimeout=<YOUR_TIMEOUT>[,resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID]
219224
```
220225
226+
**If using storage account access key and no Azure snapshots:**
227+
228+
```bash
229+
velero install \
230+
--provider azure \
231+
--plugins velero/velero-plugin-for-microsoft-azure:v1.0.1 \
232+
--bucket $BLOB_CONTAINER \
233+
--secret-file ./credentials-velero \
234+
--backup-location-config resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,storageAccount=$AZURE_STORAGE_ACCOUNT_ID,storageAccountKeyEnvVar=AZURE_STORAGE_ACCOUNT_ACCESS_KEY[,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID] \
235+
--use-volume-snapshots=false
236+
```
237+
221238
Additionally, you can specify `--use-restic` to enable restic support, and `--wait` to wait for the deployment to be ready.
222239
223240
(Optional) Specify [additional configurable parameters][7] for the `--backup-location-config` flag.
@@ -235,7 +252,6 @@ For more complex installation needs, use either the Helm chart, or add `--dry-ru
235252
[7]: backupstoragelocation.md
236253
[8]: volumesnapshotlocation.md
237254
[9]: https://velero.io/docs/customize-installation/
238-
[10]: #Set-storage-account-access-key
239255
[11]: https://velero.io/docs/faq/
240256
[17]: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects
241257
[18]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli

backupstoragelocation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ spec:
3838

3939
# Name of the environment variable in $AZURE_CREDENTIALS_FILE that contains storage account key for this backup storage location.
4040
#
41-
# Optional.
42-
storageAccountKeyEnvVar: MY_BACKUP_STORAGE_ACCOUNT_KEY
41+
# Required if using a storage account access key to authenticate rather than a service principal.
42+
storageAccountKeyEnvVar: MY_BACKUP_STORAGE_ACCOUNT_KEY_ENV_VAR
4343

4444
# ID of the subscription for this backup storage location.
4545
#

velero-plugin-for-microsoft-azure/object_store.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import (
3636
)
3737

3838
const (
39-
storageAccountConfigKey = "storageAccount"
40-
storageAccountKeyEnvVarConfigKey = "storageAccountKeyEnvVar"
41-
subscriptionIdConfigKey = "subscriptionId"
42-
blockSizeConfigKey = "blockSizeInBytes"
39+
storageAccountConfigKey = "storageAccount"
40+
storageAccountKeyEnvVarConfigKey = "storageAccountKeyEnvVar"
41+
subscriptionIdConfigKey = "subscriptionId"
42+
blockSizeConfigKey = "blockSizeInBytes"
4343

4444
// blocks must be less than/equal to 100MB in size
4545
// ref. https://docs.microsoft.com/en-us/rest/api/storageservices/put-block#uri-parameters
@@ -161,12 +161,12 @@ func getStorageAccountKey(config map[string]string) (string, *azure.Environment,
161161
return "", nil, errors.Wrap(err, "unable to parse azure cloud name environment variable")
162162
}
163163

164-
// 2. get storage key from secret using key config[storageAccountKeyEnvVarConfigKey]. If the config does not
165-
// exist, continue obtaining it using API
166-
if secretKeyEnvVar := config[storageAccountKeyEnvVarConfigKey]; secretKeyEnvVar != "" {
164+
// 2. get storage account key from env var whose name is in config[storageAccountKeyEnvVarConfigKey].
165+
// If the config does not exist, continue obtaining the storage key using API
166+
if secretKeyEnvVar := config[storageAccountKeyEnvVarConfigKey]; secretKeyEnvVar != "" {
167167
storageKey := os.Getenv(secretKeyEnvVar)
168168
if storageKey == "" {
169-
return "", env, errors.Errorf("no storage key secret with key %s found", secretKeyEnvVar)
169+
return "", env, errors.Errorf("no storage account key found in env var %s", secretKeyEnvVar)
170170
}
171171

172172
return storageKey, env, nil
@@ -208,7 +208,7 @@ func getStorageAccountKey(config map[string]string) (string, *azure.Environment,
208208
return "", env, errors.New("No storage keys found")
209209
}
210210

211-
var storageKey string
211+
var storageKey string
212212
for _, key := range *res.Keys {
213213
// uppercase both strings for comparison because the ListKeys call returns e.g. "FULL" but
214214
// the storagemgmt.Full constant in the SDK is defined as "Full".

0 commit comments

Comments
 (0)