You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/functions.md
+56-11Lines changed: 56 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -938,6 +938,15 @@ Arguments:
938
938
| ---------- | :------: | ------ | ----------- |
939
939
| instanceID | Yes | string | ID of RDS instance you want to create snapshot of |
940
940
| dbEngine | No | string | Required in case of RDS Aurora instance. Supported DB Engines: `aurora``aurora-mysql`and `aurora-postgresql` |
941
+
| credentialsSource | No | string | Source for aws credentials. Supported sources: `profile`, `secret`, `serviceaccount`. Default value is `profile` |
942
+
| credentialsSecret | No | string | Secret to get credentials from. Only used with `credentialsSource: secret`. Secret with this name should be referenced in the Actionset |
943
+
| region | No | string | AWS region to use. Derived from profile or serviceaccount if not set |
944
+
945
+
::: tip NOTE
946
+
947
+
`credentialsSource: serviceaccount` uses kanister operator service account. IAM role for service
948
+
account should be set up to access the RDS database.
949
+
:::
941
950
942
951
Outputs:
943
952
@@ -994,6 +1003,10 @@ Arguments:
994
1003
| image | No | string | kanister-tools image to be used for running export job |
995
1004
| podAnnotations | No | map[string]string | custom annotations for the temporary pod that gets created |
996
1005
| podLabels | No | map[string]string | custom labels for the temporary pod that gets created |
1006
+
| credentialsSource | No | string | Source for aws credentials. Supported sources: `profile`, `secret`, `serviceaccount`. Default value is `profile` |
1007
+
| credentialsSecret | No | string | Secret to get credentials from. Only used with `credentialsSource: secret`. Secret with this name should be [referenced in the Actionset](templates.html#secrets) |
1008
+
| region | No | string | AWS region to use. Derived from profile or serviceaccount if not set |
1009
+
997
1010
998
1011
::: tip NOTE
999
1012
@@ -1006,6 +1019,19 @@ associated with instance with `instanceID` and will pass the same. - If
1006
1019
set, `default` DB Subnet group will be used.
1007
1020
:::
1008
1021
1022
+
::: tip NOTE
1023
+
1024
+
If `credentialsSource` is configured to `profile` (default behaviour), the profile used has to be
1025
+
an S3 profile configured with the same region as the database snapshot.
1026
+
If it's required to export to another region, `credentialSource: secret` or `credentialSource: serviceaccount` can be used.
1027
+
:::
1028
+
1029
+
::: tip NOTE
1030
+
1031
+
`credentialsSource: serviceaccount` uses kanister operator service account. IAM role for service
1032
+
account should be set up to access the RDS database.
1033
+
:::
1034
+
1009
1035
Outputs:
1010
1036
1011
1037
| Output | Type | Description |
@@ -1069,13 +1095,13 @@ stored in an object storage.
1069
1095
1070
1096
::: tip NOTE
1071
1097
1072
-
\- If [snapshotID] is set, the function will restore RDS
1073
-
instance from the RDS snapshot. Otherwise *backupID* needs
1074
-
to be set to restore the RDS instance from data dump. - While restoring
1075
-
the data from RDS snapshot if RDS instance (where we have to restore the
1076
-
data) doesn\'t exist, the RDS instance will be created. But if the data
1098
+
- If `snapshotID` is set, the function will restore RDS
1099
+
instance from the RDS snapshot. Otherwise `backupID` needs
1100
+
to be set to restore the RDS instance from data dump.
1101
+
- While restoring the data from RDS snapshot if RDS instance (where we have to restore the
1102
+
data) doesn't exist, the RDS instance will be created. But if the data
1077
1103
is being restored from the Object Storage (data dump) and the RDS
1078
-
instance doesn\'t exist new RDS instance will not be created and will
1104
+
instance doesn't exist new RDS instance will not be created and will
1079
1105
result in an error.
1080
1106
:::
1081
1107
@@ -1096,15 +1122,25 @@ Arguments:
1096
1122
| image | No | string | kanister-tools image to be used for running restore, only relevant when restoring from data dump (if `snapshotID` is empty) |
1097
1123
| podAnnotations | No | map[string]string | custom annotations for the temporary pod that gets created |
1098
1124
| podLabels | No | map[string]string | custom labels for the temporary pod that gets created |
1125
+
| credentialsSource | No | string | Source for aws credentials. Supported sources: `profile`, `secret`, `serviceaccount`. Default value is `profile` |
1126
+
| credentialsSecret | No | string | Secret to get credentials from. Only used with `credentialsSource: secret`. Secret with this name should be referenced in the Actionset |
1127
+
| region | No | string | AWS region to use. Derived from profile or serviceaccount if not set |
1128
+
1099
1129
1100
1130
::: tip NOTE
1101
1131
1102
-
\- If `snapshotID` is not set, restore will be done from data dump. In
1103
-
that case `backupID` [arg] is required. - If
1104
-
`securityGroupID`argument is not set, `RestoreRDSSnapshot` will find
1132
+
- If `snapshotID` is not set, restore will be done from data dump. In
1133
+
that case `backupID` arg is required.
1134
+
- If `securityGroupID` argument is not set, `RestoreRDSSnapshot` will find
1105
1135
out Security Group IDs associated with instance with `instanceID` and
1106
-
will pass the same. - If `dbSubnetGroup` argument is not set, `default`
1107
-
DB Subnet group will be used.
1136
+
will pass the same.
1137
+
- If `dbSubnetGroup` argument is not set, `default` DB Subnet group will be used.
1138
+
:::
1139
+
1140
+
::: tip NOTE
1141
+
1142
+
`credentialsSource: serviceaccount` uses kanister operator service account. IAM role for service
1143
+
account should be set up to access the RDS database.
1108
1144
:::
1109
1145
1110
1146
Outputs:
@@ -1153,6 +1189,15 @@ Arguments:
1153
1189
| Argument | Required | Type | Description |
1154
1190
| ---------- | :------: | ------ | ----------- |
1155
1191
| snapshotID | No | string | ID of the RDS snapshot |
1192
+
| credentialsSource | No | string | Source for aws credentials. Supported sources: `profile`, `secret`, `serviceaccount`. Default value is `profile` |
1193
+
| credentialsSecret | No | string | Secret to get credentials from. Only used with `credentialsSource: secret`. Secret with this name should be referenced in the Actionset |
1194
+
| region | No | string | AWS region to use. Derived from profile or serviceaccount if not set |
1195
+
1196
+
::: tip NOTE
1197
+
1198
+
`credentialsSource: serviceaccount` uses kanister operator service account. IAM role for service
1199
+
account should be set up to access the RDS database.
Create a configmap which contains information to connect to the RDS DB instance
47
47
48
-
```
48
+
```yaml
49
49
apiVersion: v1
50
50
kind: ConfigMap
51
51
metadata:
@@ -82,6 +82,32 @@ data operations such as backup should go. This is stored as a `profiles.cr.kanis
82
82
requires a Profile reference to complete the action. This CR (`profiles.cr.kanister.io`)
83
83
can be shared between Kanister-enabled application instances.
84
84
85
+
### Configure a secret to access RDS
86
+
87
+
By default the blueprints in this example are using credentials from the profile to access RDS
88
+
resources.
89
+
90
+
If you want to export your backups to a different region or a different object store (recommended),
91
+
you need to provide alternative credential configuration.
92
+
93
+
Here we use k8s secret with AWS credentials.
94
+
You need to make sure credentials provided in this secret can be used to access RDS operations.
95
+
96
+
```yaml
97
+
---
98
+
apiVersion: v1
99
+
kind: Secret
100
+
metadata:
101
+
name: rds-secret
102
+
namespace: pgtestrds
103
+
type: secrets.kanister.io/aws
104
+
data:
105
+
aws_access_key_id: "<your access key id>"
106
+
aws_secret_access_key: "<you secret>"
107
+
role: ""
108
+
```
109
+
110
+
This secret needs to be referenced in the acitonset.
85
111
86
112
### Create Blueprint
87
113
@@ -97,6 +123,12 @@ So as you can see we will have to create a blueprint depending on how are we goi
97
123
98
124
Use `rds-postgres-snap-blueprint.yaml` or `rds-postgres-blueprint.yaml` Blueprint if you want to take backup using RDS snapshots or you can use `rds-postgres-dump-blueprint.yaml` Blueprint if you want to extract postgres dump from snapshot and push to S3 storage
99
125
126
+
**NOTE:**
127
+
- The `rds-postgres-dump-blueprint.yaml` blueprint demonstrates how to use credentials from the secret.
128
+
- The `rds-postgres-snap-blueprint.yaml` blueprint demonstrates how to use credentials from the profile.
129
+
130
+
To change that you can modify the blueprints using those examples and documentation in https://docs.kanister.io/functions.html#createrdssnapshot
You can now take a snapshot of the PostgreSQL RDS instance data using an ActionSet defining backup for this application. Create an ActionSet in the same namespace as the controller.
108
140
109
-
> If you have deployed your application which uses RDS instance in namespace other than `pgtestrds`, you need to modify the commands used below to use the correct namespace
141
+
Get profile:
110
142
111
143
```bash
112
144
$ kubectl get profile -n pgtestrds
113
145
NAME AGE
114
146
s3-profile-sph7s 2h
147
+
```
115
148
149
+
Create actionset file:
150
+
151
+
> Use correct blueprint name (one of `rds-postgres-dump-bp` or `rds-postgres-snapshot-bp`) you have created earlier
152
+
> If you have deployed your application which uses RDS instance in namespace other than `pgtestrds`, you need to modify the commands used below to use the correct namespace
153
+
> Please make sure `region` option corresponds to the AWS region where your RDS is deployed.
154
+
155
+
```yaml
156
+
apiVersion: cr.kanister.io/v1alpha1
157
+
kind: ActionSet
158
+
metadata:
159
+
name: rds-backup
160
+
namespace: kasten-io
161
+
spec:
162
+
actions:
163
+
- name: backup
164
+
blueprint: <blueprint-name>
165
+
object:
166
+
apiVersion: v1
167
+
name: dbconfig
168
+
namespace: pgtestrds
169
+
resource: configmaps
170
+
profile:
171
+
name: <your profile>
172
+
namespace: pgtestrds
173
+
secrets:
174
+
aws:
175
+
name: rds-secret
176
+
namespace: pgtestrds
177
+
options:
178
+
region: <rds region>
179
+
```
180
+
181
+
Where:
182
+
- dbconfig is a configmap holding RDS infromation
183
+
Please see pgtest/deploy/config.yaml for configmap format
184
+
- rds-secret is an AWS secret with access to RDS resources
116
185
117
-
# Use correct blueprint name (one of `rds-postgres-dump-bp` or `rds-postgres-snapshot-bp`) you have created earlier
118
-
119
-
cat <<EOF | kubectl apply -f -
120
-
> apiVersion: cr.kanister.io/v1alpha1
121
-
> kind: ActionSet
122
-
> metadata:
123
-
> name: rds-backup
124
-
> namespace: kasten-io
125
-
> spec:
126
-
> actions:
127
-
> - name: backup
128
-
> blueprint: <blueprint-name>
129
-
> object:
130
-
> apiVersion: v1
131
-
> name: dbconfig
132
-
> namespace: pgtestrds
133
-
> resource: configmaps
134
-
> profile:
135
-
> name: s3-profile-sph7s
136
-
> namespace: pgtestrds
137
-
> EOF
138
-
actionset.cr.kanister.io/rds-backup created
139
186
140
-
# Where,
141
-
# dbconfig is a configmap holding RDS infromation
142
-
# Please see pgtest/deploy/config.yaml for configmap format
0 commit comments