Skip to content

Commit b318639

Browse files
committed
defined ARN role, by adding new module for preparing aws account and seperating code into into subtask commands
1 parent 1b0517f commit b318639

File tree

3 files changed

+224
-29
lines changed

3 files changed

+224
-29
lines changed

modules/oadp-installing-oadp-rosa-sts.adoc

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@
44

55
:_content-type: PROCEDURE
66
[id="oadp-installing-oadp-rosa-sts_{context}"]
7-
= Installing OADP on {product-title} with AWS STS
7+
= Installing the OADP Operator and providing the IAM role
88

99
AWS Security Token Service (AWS STS) is a global web service that provides short-term credentials for IAM or federated users. {product-title} (ROSA) with STS is the recommended credential mode for ROSA clusters. This document describes how to install OpenShift API for Data Protection (OADP) on (ROSA) with AWS STS.
1010

11+
1112
[IMPORTANT]
1213
====
1314
Restic is not supported in the OADP on ROSA with AWS STS environment. Ensure the Restic service is disabled. Use native snapshots to backup volumes. See _Known Issues_ for more information.
1415
====
1516

1617
.Prerequisites
1718

18-
* A ROSA OpenShift Cluster with the required access and tokens.
19-
* link:https://docs.openshift.com/container-platform/4.14/backup_and_restore/application_backup_and_restore/installing/installing-oadp-aws.html#oadp-creating-default-secret_installing-oadp-aws[A default Secret], if your backup and snapshot locations use the same credentials, or if you do not require a snapshot location.
19+
* A ROSA OpenShift Cluster with the required access and tokens. For instructions, see the procedure in _Preparing AWS credentials_.
20+
2021
2122
.Procedure
2223

23-
. Create an Openshift secret from your AWS token file by entering the following commands:
24+
. Create an Openshift secret from your AWS token file by entering the following commands.
2425

2526
.. Create the credentials file:
2627
+
27-
[source, terminal]
28+
[source,terminal]
2829
----
2930
$ cat <<EOF > ${SCRATCH}/credentials
3031
[default]
@@ -35,7 +36,7 @@ EOF
3536

3637
.. Create the OpenShift secret:
3738
+
38-
[source, terminal]
39+
[source,terminal]
3940
----
4041
$ oc -n openshift-adp create secret generic cloud-credentials \
4142
--from-file=${SCRATCH}/credentials
@@ -85,43 +86,35 @@ spec:
8586
key: credentials
8687
name: cloud-credentials
8788
default: true
89+
config:
90+
region: ${REGION}
8891
configuration:
8992
velero:
9093
defaultPlugins:
9194
- openshift
9295
- aws
9396
restic:
9497
enable: false
95-
volumeSnapshots:
98+
snapshotLocations:
9699
- velero:
97100
config:
98-
credentialsFile: /tmp/credentials/openshift-adp/cloud-credentials-credentials
99-
enableSharedConfig: "true"
100-
region: ${REGION}
101+
credentialsFile: /tmp/credentials/openshift-adp/cloud-credentials-credentials <1>
102+
enableSharedConfig: "true" <2>
103+
profile: default <3>
104+
region: ${REGION} <4>
101105
provider: aws
102106
EOF
103107
----
108+
109+
+
110+
<1> The `credentialsFile` is the mounted location of the bucket credential on the pod.
111+
<2> The `enableSharedConfig` allows the `snapshotLocations` to share or reuse the credential defined for the bucket.
112+
<3> Assume your Velero default for your `profile: default`.
113+
<4> Specify `region` as your AWS region. This must be the same as the cluster region.
104114
+
105115
[NOTE]
106116
====
107117
The `enable` parameter of `restic` is set to `false` in this configuration because OADP does not support Restic in ROSA environments.
108118
====
109119
+
110120
You are now ready to backup and restore OpenShift applications, as described in the link:https://docs.openshift.com/container-platform/4.11/backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.html[OADP documentation].
111-
112-
== Known Issues
113-
.Restic is not supported or recommended
114-
115-
* link:https://issues.redhat.com/browse/OADP-1054[CloudStorage: openshift-adp-controller-manager crashloop seg fault with Restic enabled]
116-
* link:https://issues.redhat.com/browse/OADP-1057[Cloudstorage API: CSI Backup of an app with internal images partially fails with plugin panicked error]
117-
* (Affects OADP 1.1.x_ only): link:https://issues.redhat.com/browse/OADP-1055[CloudStorage: bucket is removed on CS CR delete, although it doesn't have "oadp.openshift.io/cloudstorage-delete": "true"]
118-
119-
[role="_additional-resources"]
120-
.Additional resources
121-
122-
* link:https://docs.openshift.com/rosa/rosa_architecture/rosa-understanding.html[Understanding ROSA with STS]
123-
* link:https://docs.openshift.com/rosa/rosa_getting_started/rosa-sts-getting-started-workflow.html[Getting started with ROSA STS]
124-
* link:https://docs.openshift.com/rosa/rosa_install_access_delete_clusters/rosa-sts-creating-a-cluster-quickly.html[Creating a ROSA cluster with STS]
125-
* link:https://docs.openshift.com/container-platform/4.14/backup_and_restore/application_backup_and_restore/installing/about-installing-oadp.html[About installing OADP]
126-
* link:https://docs.openshift.com/container-platform/4.14/storage/container_storage_interface/persistent-storage-csi.html[Configuring CSI volumes]
127-
* link:https://docs.openshift.com/rosa/rosa_architecture/rosa_policy_service_definition/rosa-service-definition.html#rosa-sdpolicy-storage_rosa-service-definition[ROSA storage options]
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * rosa_backing_up_and_restoring_applications/backing-up-applications.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="oadp-preparing-aws-credentials_{context}"]
7+
= Preparing AWS credentials
8+
9+
An AWS account must be ready to accept an OADP installation.
10+
11+
.Procedure
12+
. Create the following environment variables by running the following commands:
13+
+
14+
[NOTE]
15+
====
16+
Change the cluster name to match your ROSA cluster, and ensure you are logged into the cluster as an administrator. Ensure that all fields are outputted correctly before continuing.
17+
====
18+
+
19+
[source,terminal]
20+
----
21+
$ export CLUSTER_NAME=my-cluster <1>
22+
export ROSA_CLUSTER_ID-$(rosa describe cluster -c ${CLUSTER_NAME} --output json | jq -r .id)
23+
export REGION=$(rosa describe cluster -c ${CLUSTER_NAME} --output json | jq -r .region.id)
24+
export OIDC_ENDPOINT=$(oc get authentication.config.openshift.io cluster -o jsonpath='{.spec.serviceAccountIssuer}' | sed 's|^https://||')
25+
export AWS_ACCOUNT_ID='aws sts get-caller-identity --query Account --output text'
26+
export CLUSTER_VERSION='rosa describe cluster -c ${CLUSTER_NAME} -o json | jq -r .version.raw_id | but -f -2 -d '.' '
27+
export ROLE_NAME="${CLUSTER_NAME}-openshift-oadp-aws-cloud-credentials"
28+
export SCRATCH="/tmp/${CLUSTER_NAME}/oadp"
29+
mkdir -p ${SCRATCH}
30+
echo "Cluster ID: ${ROSA_CLUSTER_ID}, Region: ${REGION}, OIDC Endpoint:
31+
${OIDC_ENDPOINT}, AWS Account ID: ${AWS_ACCOUNT_ID}"
32+
----
33+
+
34+
<1> Replace `my-cluster` with your ROSA cluster name.
35+
36+
. On the AWS account, create an IAM policy to allow access to S3.
37+
38+
.. Check to see if the policy exists by running the following command:
39+
+
40+
[source,terminal]
41+
----
42+
$ POLICY_ARN=$(aws iam list-policies --query "Policies[?PolicyName=='RosaOadpVer1'].{ARN:Arn}" -- output text) <1>
43+
----
44+
+
45+
<1> Replace `RosaOadp` with your policy name.
46+
47+
.. Use the following command to create the policy JSON file and then create the policy in ROSA.
48+
+
49+
[NOTE]
50+
====
51+
If the policy ARN is not found, the command will create the policy. If the policy ARN already exists, the `if` statement will intentionally skip the policy creation.
52+
====
53+
+
54+
[source,terminal]
55+
----
56+
$ if [[ -z "${POLICY_ARN}" ]]; then
57+
cat << EOF > ${SCRATCH}/policy.json <1>
58+
{
59+
"Version": "2012-10-17",
60+
"Statement": [
61+
{
62+
"Effect": "Allow",
63+
"Action": [
64+
"s3:CreateBucket",$ echo ${POLICY_ARN}
65+
"s3:DeleteBucket",cd openshift-docs
66+
"s3:PutBucketTegging",
67+
"s3:GetBucketTegging",
68+
"s3:PutEncryptionConfiguration",
69+
"s3:GetEncryptionConfiguration",
70+
"s3:PutLifecycleConfiguration",
71+
"s3:GetLifecycleConfiguration",
72+
"s3:GetBucketLocation",
73+
"s3:ListBucket",
74+
"s3:GetObject",
75+
"s3:PutObject",
76+
"s3:DeleteOgject",
77+
"s3:ListBucketMultipartUpLoads",
78+
"s3:AbortMultipartUpLoads",
79+
"s3:ListMultipartUpLoadParts",
80+
"s3:DescribeSnapshots",
81+
"ec2:DescribeVolumes",
82+
"ec2:DescribeVolumeAttribute",
83+
"ec2:DescribeVolumesModifications",
84+
"ec2:DescribeVolumeStatus",
85+
"ec2:CreateTags",
86+
"ec2:CreateVolume",
87+
"ec2:CreateSnapshot",
88+
"ec2:DeleteSnapshot",
89+
]
90+
"Resource": "*"
91+
}
92+
]}
93+
EOF
94+
POLICY_ARN=$(aws iam create-policy --policy-mane "RosaOadpVer1" \
95+
--policy-document file:///${SCRATCH}/policy.json --query Policy.Arn \
96+
--tags Key=rosa_openshift_version,Value=${CLUSTER_VERSION} Key-rosa_role_prefix,Value=ManagedOpenShift Key=operator_namespace,Value=openshift-oadp Key=operator_name,Value=openshift-oadp \
97+
--output text)
98+
fi
99+
----
100+
+
101+
<1> `SCRATCH` is a name for a temporary directory created for the environment variables.
102+
103+
.. View the policy ARN by running the following command:
104+
+
105+
[source,terminal]
106+
----
107+
$ echo ${POLICY_ARN}
108+
----
109+
110+
111+
. Create an IAM role trust policy for the cluster:
112+
113+
.. Create the trust policy file by running the following command:
114+
+
115+
[source,terminal]
116+
----
117+
$ cat <<EOF > ${SCRATCH}/trust-policy.json
118+
{
119+
"Version": :2012-10-17",
120+
"Statement": [{
121+
"Effect": "Allow",
122+
"Principal": {
123+
"Federated": "arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/${OIDC_ENDPOINT}"
124+
},
125+
"Action": "sts:AssumeRoleWithWebIdentity",
126+
"Condition": {
127+
"StringEquals": {
128+
"${OIDC_ENDPOINT}:sub": [
129+
"system:serviceaccount:openshift-adp:openshift-adp-controller-manager",
130+
"system:serviceaccount:openshift-adp:velero:]
131+
}
132+
}
133+
}]
134+
}
135+
EOF
136+
----
137+
138+
.. Create the role by running the following command:
139+
+
140+
[source,terminal]
141+
----
142+
$ ROLE_ARN=$(aws iam create-role --role-name \
143+
"${ROLE_NAME}" \
144+
--assume-role-policy-document file://${SCRATCH}/trust-policy.json \
145+
--tags Key+rosa_cluster_id,Value=${ROSA_CLUSTER_ID}
146+
Key=rosa_openshift_verson,Value=${CLUSTER_VERSION}
147+
Key=rosa_role_prefix,Value=ManagedOpenShift
148+
Key=operator_namespace,Value=openshift-adp
149+
Key=operator_name,Value-openshift-oadp \
150+
--query Role.Arn --output text)
151+
----
152+
153+
.. View the role ARN by running the following command:
154+
+
155+
[source,terminal]
156+
----
157+
$ echo ${ROLE_ARN}
158+
----
159+
160+
. Attach the IAM policy to the IAM role by running the following command:
161+
+
162+
[source,terminal]
163+
----
164+
$ aws iam attach-role-policy --role-name "${ROLE_NAME}" \
165+
--policy-arn ${POLICY_ARN}
166+
----
167+
168+
.Next steps
169+
170+
* Continue to _Installing the OADP Operator and providing the IAM role_.

rosa_backing_up_and_restoring_applications/backing-up-applications.adoc

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
You can employ OpenShift API for Data Protection (OADP) with Red Hat OpenShift Service on AWS (ROSA) clusters to backup and restore application data. A ROSA deployment of OpenShift is configured specifically for AWS services.
9+
You can employ OpenShift API for Data Protection (OADP) with Red Hat OpenShift Service on AWS (ROSA) clusters to backup and restore application data. Before installing OADP, you must set up role and policy credentials for OADP so that it can use the AWS API.
1010

11-
include::modules/oadp-installing-oadp-rosa-sts.adoc[leveloffset=+1]
11+
This is a two stage process:
12+
13+
. Prepare AWS credentials.
14+
. Install the OADP Operator and provide it with the IAM role.
15+
16+
include::modules/oadp-preparing-aws-credentials.adoc[leveloffset=+1]
17+
18+
include::modules/oadp-installing-oadp-rosa-sts.adoc[leveloffset=+1]
19+
20+
[role="_additional-resources"]
21+
[id="oadp-addtl-resources_{context}"]
22+
.Additional resources
23+
24+
* xref:../rosa_backing_up_and_restoring_applications/backing-up-applications.adoc#oadp-preparing-aws-credentials_rosa-backing-up-applications[Preparing AWS credentials]
25+
26+
[id="rosa-backing-up-applications-known-issues"]
27+
== Known issues
28+
.Restic is not supported or recommended
29+
30+
* link:https://issues.redhat.com/browse/OADP-1054[CloudStorage: openshift-adp-controller-manager crashloop seg fault with Restic enabled]
31+
* link:https://issues.redhat.com/browse/OADP-1057[Cloudstorage API: CSI Backup of an app with internal images partially fails with plugin panicked error]
32+
* (Affects OADP 1.1.x_ only): link:https://issues.redhat.com/browse/OADP-1055[CloudStorage: bucket is removed on CS CR delete, although it doesn't have "oadp.openshift.io/cloudstorage-delete": "true"]
33+
34+
[role="_additional-resources"]
35+
[id="additional-resources_rosa-backing-up-applications"]
36+
== Additional resources
37+
38+
* link:https://docs.openshift.com/rosa/rosa_architecture/rosa-understanding.html[Understanding ROSA with STS]
39+
* link:https://docs.openshift.com/rosa/rosa_getting_started/rosa-sts-getting-started-workflow.html[Getting started with ROSA STS]
40+
* link:https://docs.openshift.com/rosa/rosa_install_access_delete_clusters/rosa-sts-creating-a-cluster-quickly.html[Creating a ROSA cluster with STS]
41+
* link:https://docs.openshift.com/container-platform/4.13/backup_and_restore/application_backup_and_restore/installing/about-installing-oadp.html[About installing OADP]
42+
* link:https://docs.openshift.com/container-platform/4.13/storage/container_storage_interface/persistent-storage-csi.html[Configuring CSI volumes]
43+
* link:https://docs.openshift.com/rosa/rosa_architecture/rosa_policy_service_definition/rosa-service-definition.html#rosa-sdpolicy-storage_rosa-service-definition[ROSA storage options]

0 commit comments

Comments
 (0)