Skip to content

Commit 48544c2

Browse files
authored
Merge pull request #96739 from shdeshpa07/OADP-Authentication-OADP-with-Azure
OADP Authentication with Azure
2 parents 5935ff1 + 598cf04 commit 48544c2

6 files changed

Lines changed: 372 additions & 14 deletions

File tree

backup_and_restore/application_backup_and_restore/installing/installing-oadp-azure.adoc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,23 @@ You configure Azure for Velero, create a default `Secret`, and then install the
1818

1919
To install the OADP Operator in a restricted network environment, you must first disable the default OperatorHub sources and mirror the Operator catalog. See xref:../../../disconnected/using-olm.adoc#olm-restricted-networks[Using Operator Lifecycle Manager in disconnected environments] for details.
2020

21-
// include::modules/oadp-installing-operator.adoc[leveloffset=+1]
21+
2222
include::modules/migration-configuring-azure.adoc[leveloffset=+1]
2323
include::modules/oadp-about-backup-snapshot-locations-secrets.adoc[leveloffset=+1]
24-
include::modules/oadp-creating-default-secret.adoc[leveloffset=+2]
25-
include::modules/oadp-secrets-for-different-credentials.adoc[leveloffset=+2]
26-
27-
[id="configuring-dpa-azure"]
28-
== Configuring the Data Protection Application
24+
include::modules/oadp-auth-azure-methods.adoc[leveloffset=+1]
25+
include::modules/oadp-auth-azure-secret-based.adoc[leveloffset=+1]
26+
include::modules/oadp-auth-azure-sts.adoc[leveloffset=+1]
2927

3028
You can configure the Data Protection Application by setting Velero resource allocations or enabling self-signed CA certificates.
3129

32-
include::modules/oadp-setting-resource-limits-and-requests.adoc[leveloffset=+2]
30+
include::modules/oadp-setting-resource-limits-and-requests.adoc[leveloffset=+1]
3331

3432
include::snippets/oadp-nodeselector-snippet.adoc[]
3533

3634
For more details, see xref:../../../backup_and_restore/application_backup_and_restore/installing/installing-oadp-azure.adoc#oadp-configuring-node-agents_installing-oadp-azure[Configuring node agents and node labels].
3735

38-
include::modules/oadp-self-signed-certificate.adoc[leveloffset=+2]
39-
include::modules/oadp-using-ca-certificates-with-velero-command.adoc[leveloffset=+2]
36+
include::modules/oadp-self-signed-certificate.adoc[leveloffset=+1]
37+
include::modules/oadp-using-ca-certificates-with-velero-command.adoc[leveloffset=+1]
4038

4139
// include::modules/oadp-installing-dpa-1-2-and-earlier.adoc[leveloffset=+1]
4240
include::modules/oadp-installing-dpa-1-3.adoc[leveloffset=+1]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Module included in the following assemblies:
2+
3+
// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-azure.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="oadp-auth-azure-methods_{context}"]
7+
= About authenticating OADP with Azure
8+
9+
You can authenticate {oadp-short} with Azure by using the following methods:
10+
11+
* A Velero-specific service principal with secret-based authentication.
12+
* A Velero-specific storage account access key with secret-based authentication.
13+
* Azure Security Token Service.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Module included in the following assemblies:
2+
3+
// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-azure.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="oadp-auth-azure-secret-based_{context}"]
7+
= Using a service principal or a storage account access key
8+
9+
[role="_abstract"]
10+
You create a default `Secret` object and reference it in the backup storage location custom resource. The credentials file for the `Secret` object can contain information about the Azure service principal or a storage account access key.
11+
12+
The default name of the `Secret` is `{credentials}`.
13+
14+
[NOTE]
15+
====
16+
The `DataProtectionApplication` custom resource (CR) requires a default `Secret`. Otherwise, the installation will fail. If the name of the backup location `Secret` is not specified, the default name is used.
17+
18+
If you do not want to use the backup location credentials during the installation, you can create a `Secret` with the default name by using an empty `credentials-velero` file.
19+
====
20+
21+
22+
.Prerequisites
23+
24+
* You have access to the OpenShift cluster as a user with `cluster-admin` privileges.
25+
* You have an Azure subscription with appropriate permissions.
26+
* You have installed {oadp-short}.
27+
* You have configured an object storage for storing the backups.
28+
29+
.Procedure
30+
31+
. Create a `credentials-velero` file for the backup storage location in the appropriate format for your cloud provider.
32+
+
33+
You can use one of the following two methods to authenticate {oadp-short} with Azure.
34+
35+
* Use the service principal with secret-based authentication. See the following example:
36+
+
37+
[source,terminal]
38+
----
39+
AZURE_SUBSCRIPTION_ID=<azure_subscription_id>
40+
AZURE_TENANT_ID=<azure_tenant_id>
41+
AZURE_CLIENT_ID=<azure_client_id>
42+
AZURE_CLIENT_SECRET=<azure_client_secret>
43+
AZURE_RESOURCE_GROUP=<azure_resource_group>
44+
AZURE_CLOUD_NAME=<azure_cloud_name>
45+
----
46+
47+
* Use a storage account access key. See the following example:
48+
+
49+
[source,terminal]
50+
----
51+
AZURE_STORAGE_ACCOUNT_ACCESS_KEY=<azure_storage_account_access_key>
52+
AZURE_SUBSCRIPTION_ID=<azure_subscription_id>
53+
AZURE_RESOURCE_GROUP=<azure_resource_group>
54+
AZURE_CLOUD_NAME=<azure_cloud_name>
55+
----
56+
57+
. Create a `Secret` custom resource (CR) with the default name:
58+
+
59+
[source,terminal,subs="attributes+"]
60+
----
61+
$ oc create secret generic {credentials} -n openshift-adp --from-file cloud=credentials-velero
62+
----
63+
64+
. Reference the `Secret` in the `spec.backupLocations.velero.credential` block of the `DataProtectionApplication` CR when you install the Data Protection Application as shown in the following example:
65+
+
66+
[source,yaml,subs="attributes+"]
67+
----
68+
apiVersion: oadp.openshift.io/v1alpha1
69+
kind: DataProtectionApplication
70+
metadata:
71+
name: <dpa_sample>
72+
namespace: openshift-adp
73+
spec:
74+
...
75+
backupLocations:
76+
- velero:
77+
config:
78+
resourceGroup: <azure_resource_group>
79+
storageAccount: <azure_storage_account_id>
80+
subscriptionId: <azure_subscription_id>
81+
credential:
82+
key: cloud
83+
name: <custom_secret> # <1>
84+
provider: azure
85+
default: true
86+
objectStorage:
87+
bucket: <bucket_name>
88+
prefix: <prefix>
89+
snapshotLocations:
90+
- velero:
91+
config:
92+
resourceGroup: <azure_resource_group>
93+
subscriptionId: <azure_subscription_id>
94+
incremental: "true"
95+
provider: {provider}
96+
----
97+
<1> Backup location `Secret` with custom name.

modules/oadp-auth-azure-sts.adoc

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-azure.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="oadp-auth-azure-STS_{context}"]
7+
= Using OADP with Azure Security Token Service authentication
8+
9+
[role="_abstract"]
10+
You can use Microsoft Entra Workload ID to access Azure storage for {oadp-short} backup and restore operations. This approach uses the signed Kubernetes service account tokens of the OpenShift cluster. These token are automatically rotated every hour and exchanged with the Azure Active Directory (AD) access tokens, eliminating the need for long-term client secrets.
11+
12+
To use the Azure Security Token Service (STS) configuration, you need the `credentialsMode` field set to `Manual` during cluster installation. This approach uses the Cloud Credential Operator (`ccoctl`) to set up the workload identity infrastructure, including the OpenID Connect (OIDC) provider, issuer configuration, and user-assigned managed identities.
13+
14+
15+
.Prerequisites
16+
17+
* You have an OpenShift cluster installed on Microsoft Azure with Microsoft Entra Workload ID configured. For more details see, link:https://docs.redhat.com/en/documentation/openshift_container_platform/{product-version}/html/installing_on_azure/installer-provisioned-infrastructure#installing-azure-with-short-term-creds_installing-azure-customizations[Configuring an Azure cluster to use short-term credentials].
18+
* You have the Azure CLI (`az`) installed and configured.
19+
* You have access to the OpenShift cluster as a user with `cluster-admin` privileges.
20+
* You have an Azure subscription with appropriate permissions.
21+
22+
[NOTE]
23+
====
24+
If your OpenShift cluster was not originally installed with Microsoft Entra Workload ID, you can enable short-term credentials after installation. This post-installation configuration is supported specifically for Azure clusters.
25+
====
26+
27+
28+
.Procedure
29+
30+
. If your cluster was installed with long-term credentials, you can switch to Microsoft Entra Workload ID authentication after installation. For more details, see link:https://docs.redhat.com/en/documentation/openshift_container_platform/{product-version}/html/postinstallation_configuration/changing-cloud-credentials-configuration#enabling-entra-workload-id-existing-cluster_changing-cloud-credentials-configuration[Enabling Microsoft Entra Workload ID on an existing cluster].
31+
+
32+
[IMPORTANT]
33+
====
34+
After enabling Microsoft Entra Workload ID on an existing Azure cluster, you must update all cluster components that use cloud credentials, including {oadp-short}, to use the new authentication method.
35+
====
36+
37+
. Set the environment variables for your Azure STS configuration as shown in the following example:
38+
+
39+
[source,terminal]
40+
----
41+
export API_URL=$(oc whoami --show-server) # Get cluster information
42+
export CLUSTER_NAME=$(echo "$API_URL" | sed 's|https://api\.||' | sed 's|\..*||')
43+
export CLUSTER_RESOURCE_GROUP="${CLUSTER_NAME}-rg"
44+
45+
# Get Azure information
46+
export AZURE_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
47+
export AZURE_TENANT_ID=$(az account show --query tenantId -o tsv)
48+
49+
# Set names for resources
50+
export IDENTITY_NAME="velero"
51+
export APP_NAME="velero-${CLUSTER_NAME}"
52+
export STORAGE_ACCOUNT_NAME=$(echo "velero${CLUSTER_NAME}" | tr -d '-' | tr '[:upper:]' '[:lower:]' | cut -c1-24)
53+
export CONTAINER_NAME="velero"
54+
----
55+
56+
. Create an Azure Managed Identity for {oadp-short} as shown in the following example:
57+
+
58+
[source,terminal]
59+
----
60+
az identity create \ # Create managed identity
61+
--subscription "$AZURE_SUBSCRIPTION_ID" \
62+
--resource-group "$CLUSTER_RESOURCE_GROUP" \
63+
--name "$IDENTITY_NAME"
64+
65+
# Get identity details
66+
export IDENTITY_CLIENT_ID=$(az identity show -g "$CLUSTER_RESOURCE_GROUP" -n "$IDENTITY_NAME" --query clientId -o tsv)
67+
export IDENTITY_PRINCIPAL_ID=$(az identity show -g "$CLUSTER_RESOURCE_GROUP" -n "$IDENTITY_NAME" --query principalId -o tsv)
68+
----
69+
70+
. Grant the required Azure roles to the managed identity as shown in the following example:
71+
+
72+
[source,terminal]
73+
----
74+
export SUBSCRIPTION_ID=$(az account show --query id -o tsv) # Get subscription ID for role assignments
75+
76+
# Required roles for OADP operations
77+
REQUIRED_ROLES=(
78+
"Contributor"
79+
"Storage Blob Data Contributor"
80+
"Disk Snapshot Contributor"
81+
)
82+
83+
for role in "${REQUIRED_ROLES[@]}"; do
84+
echo "Assigning role: $role"
85+
az role assignment create \
86+
--assignee "$IDENTITY_PRINCIPAL_ID" \
87+
--role "$role" \
88+
--scope "/subscriptions/$SUBSCRIPTION_ID"
89+
done
90+
----
91+
92+
. Create an Azure storage account and a container as shown in the following example:
93+
+
94+
[source,terminal]
95+
----
96+
az storage account create \ # Create storage account
97+
--name "$STORAGE_ACCOUNT_NAME" \
98+
--resource-group "$CLUSTER_RESOURCE_GROUP" \
99+
--location "$(az group show -n $CLUSTER_RESOURCE_GROUP --query location -o tsv)" \
100+
--sku Standard_LRS \
101+
--kind StorageV2
102+
----
103+
104+
. Get the OIDC issuer URL from your OpenShift cluster as shown in the following example:
105+
+
106+
[source, terminal]
107+
----
108+
export SERVICE_ACCOUNT_ISSUER=$(oc get authentication.config.openshift.io cluster -o json | jq -r .spec.serviceAccountIssuer)
109+
echo "OIDC Issuer: $SERVICE_ACCOUNT_ISSUER"
110+
----
111+
112+
. Configure Microsoft Entra Workload ID Federation as shown in the following example:
113+
+
114+
[source, terminal]
115+
----
116+
az identity federated-credential create \ # Create federated identity credential for Velero service account
117+
--name "velero-federated-credential" \
118+
--identity-name "$IDENTITY_NAME" \
119+
--resource-group "$CLUSTER_RESOURCE_GROUP" \
120+
--issuer "$SERVICE_ACCOUNT_ISSUER" \
121+
--subject "system:serviceaccount:openshift-adp:velero" \
122+
--audiences "openshift"
123+
124+
# Create federated identity credential for OADP controller manager
125+
az identity federated-credential create \
126+
--name "oadp-controller-federated-credential" \
127+
--identity-name "$IDENTITY_NAME" \
128+
--resource-group "$CLUSTER_RESOURCE_GROUP" \
129+
--issuer "$SERVICE_ACCOUNT_ISSUER" \
130+
--subject "system:serviceaccount:openshift-adp:openshift-adp-controller-manager" \
131+
--audiences "openshift"
132+
----
133+
134+
. Create the OADP namespace if it does not already exist by running the following command:
135+
+
136+
[source, terminal]
137+
----
138+
oc create namespace openshift-adp
139+
----
140+
141+
. To use the `CloudStorage` CR to create an Azure cloud storage resource, run the following command:
142+
+
143+
[source, terminal]
144+
----
145+
cat <<EOF | oc apply -f -
146+
apiVersion: oadp.openshift.io/v1alpha1
147+
kind: CloudStorage
148+
metadata:
149+
name: azure-backup-storage
150+
namespace: openshift-adp
151+
spec:
152+
name: ${CONTAINER_NAME}
153+
provider: azure
154+
creationSecret:
155+
name: cloud-credentials-azure
156+
key: azurekey
157+
config:
158+
storageAccount: ${STORAGE_ACCOUNT_NAME}
159+
EOF
160+
----
161+
162+
. Create the `DataProtectionApplication` (DPA) custom resource (CR) and configure the Azure STS details as shown in the following example:
163+
+
164+
[source, terminal]
165+
----
166+
cat <<EOF | oc apply -f -
167+
apiVersion: oadp.openshift.io/v1alpha1
168+
kind: DataProtectionApplication
169+
metadata:
170+
name: dpa-azure-workload-id-cloudstorage
171+
namespace: openshift-adp
172+
spec:
173+
backupLocations:
174+
- bucket:
175+
cloudStorageRef:
176+
name: <cloud_storage_cr> # <1>
177+
config:
178+
storageAccount: <storage_account_name> # <2>
179+
useAAD: "true"
180+
credential:
181+
key: azurekey
182+
name: cloud-credentials-azure
183+
default: true
184+
prefix: velero
185+
name: default
186+
configuration:
187+
velero:
188+
defaultPlugins:
189+
- azure
190+
- openshift
191+
- csi
192+
disableFsBackup: false
193+
logFormat: text
194+
snapshotLocations:
195+
- name: default
196+
velero:
197+
config:
198+
resourceGroup: <resource_group> # <3>
199+
subscriptionId: <subscription_ID> # <4>
200+
credential:
201+
key: azurekey
202+
name: cloud-credentials-azure
203+
provider: azure
204+
EOF
205+
----
206+
<1> Specify the `CloudStorage` CR name.
207+
<2> Specify the Azure storage account name.
208+
<3> Specify the resource group.
209+
<4> Specify the subscription ID.
210+
211+
.Verification
212+
213+
. Verify that the OADP operator pods are running:
214+
+
215+
[source, terminal]
216+
----
217+
$ oc get pods -n openshift-adp
218+
----
219+
220+
. Verify the Azure role assignments:
221+
+
222+
[source, terminal]
223+
----
224+
az role assignment list --assignee ${IDENTITY_PRINCIPAL_ID} --all --query "[].roleDefinitionName" -o tsv
225+
----
226+
227+
. Verify Microsoft Entra Workload ID authentication:
228+
+
229+
[source, terminal]
230+
----
231+
$ VELERO_POD=$(oc get pods -n openshift-adp -l app.kubernetes.io/name=velero -o jsonpath='{.items[0].metadata.name}') # Check Velero pod environment variables
232+
233+
# Check AZURE_CLIENT_ID environment variable
234+
$ oc get pod ${VELERO_POD} -n openshift-adp -o jsonpath='{.spec.containers[0].env[?(@.name=="AZURE_CLIENT_ID")]}'
235+
236+
# Check AZURE_FEDERATED_TOKEN_FILE environment variable
237+
$ oc get pod ${VELERO_POD} -n openshift-adp -o jsonpath='{.spec.containers[0].env[?(@.name=="AZURE_FEDERATED_TOKEN_FILE")]}'
238+
----
239+
240+
. Create a backup of an application and verify the backup is stored successfully in Azure storage.

0 commit comments

Comments
 (0)