Skip to content

Commit bf24d89

Browse files
committed
Update docs about STORAGES setting
1 parent 486851e commit bf24d89

File tree

3 files changed

+197
-10
lines changed

3 files changed

+197
-10
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Configure Storage Backend
2+
3+
Pulp uses [django-storages](https://django-storages.readthedocs.io) to support multiple storage backends.
4+
See the reference for the [`STORAGES` settings](site:pulpcore/docs/admin/reference/settings.md).
5+
6+
## Local Filesystem
7+
8+
This is the default storage backend Pulp will use if another is not specified.
9+
10+
### Configure
11+
12+
Configure the `BACKEND` and `OPTIONS` for the default django storage.
13+
14+
Example configuration:
15+
16+
```python
17+
STORAGES = {
18+
"default": {
19+
"BACKEND": "storages.backends.s3.S3Storage",
20+
"OPTIONS": {
21+
"file_permissions_mode": 0o600,
22+
"directory_permissions_mode": 0o600,
23+
},
24+
},
25+
}
26+
```
27+
28+
Compreheensive options for Local Filesystem can be found in
29+
[Django docs](https://docs.djangoproject.com/en/4.2/ref/files/storage/#django.core.files.storage.FileSystemStorage).
30+
31+
### Further notes
32+
33+
- Read about how Pulp's modifies `MEDIA_ROOT` defaults [here]().
34+
- Other relevant settings (module-scope settings) that are left as Django default's:
35+
* `MEDIA_URL`
36+
* `FILE_UPLOAD_PERMISSIONS`
37+
* `FILE_UPLOAD_DIRECTORY_PERMISSIONS`
38+
39+
## Amazon S3
40+
41+
### Amazon Setup
42+
43+
Before you can configure Amazon S3 storage to use with Pulp, ensure that you complete the following steps.
44+
To complete these steps, consult the official Amazon S3 documentation.
45+
46+
1. Set up an AWS account.
47+
2. Create an S3 bucket for Pulp to use.
48+
3. In AWS Identity and Access Management (IAM), create a user that Pulp can use to access your S3 bucket.
49+
4. Save the access key id and secret access key.
50+
51+
### Pulp Setup
52+
53+
**TODO: learn how that works for oci-images and operator and provide links**
54+
55+
To have Pulp use S3, complete the following steps.
56+
This assumes a simple install. For oci-images:
57+
* ...
58+
* ...
59+
60+
#### Install Python Dependencies
61+
62+
Ensure you have `django-storages` and `boto3` in your environement.
63+
64+
For example:
65+
66+
```bash
67+
pip install django-storages[boto3]
68+
```
69+
70+
#### Configure
71+
72+
Configure the `BACKEND` and `OPTIONS` for the default django storage.
73+
74+
Here is an example configuration that will use a bucket called `pulp3` that is hosted in
75+
region `eu-central-1`:
76+
77+
```python
78+
MEDIA_ROOT = ""
79+
STORAGES = {
80+
"default": {
81+
"BACKEND": "storages.backends.s3.S3Storage",
82+
"OPTIONS": {
83+
"access_key": 'AKIAIT2Z5TDYPX3ARJBA',
84+
"secret_key": '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',
85+
"bucket_name": 'pulp3',
86+
"signature_version": "s3v4",
87+
"addressing_style": "path",
88+
"region_name": "eu-central-1",
89+
},
90+
},
91+
}
92+
```
93+
94+
Compreheensive options for Amazon S3 can be found in
95+
[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#configuration-settings).
96+
97+
#### Further notes
98+
99+
- You can omit `access_key` and `secret_key` if the following are true:
100+
* The system that hosts Pulp is running in AWS
101+
* The [`instance_profile`](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) provides access to the S3 bucket
102+
103+
## Azure Blob storage
104+
105+
### Azure Setup
106+
107+
Before you can configure Azure Blob storage to use with Pulp, ensure that you complete the following steps.
108+
To complete these steps, consult the official Azure Blob documentation.
109+
110+
1. Set up an Azure account and create a storage account.
111+
2. In your storage account, create a container under `Blob` service.
112+
3. Obtain the access credentials so that you can later configure Pulp to access your Azure Blob storage. You can find the access credentials
113+
at the storage account level, at Access keys (these are automatically generated).
114+
115+
### Pulp Setup
116+
117+
#### Install Python Dependencies
118+
119+
Ensure you have `django-storages[azure]` in your environement:
120+
121+
```bash
122+
pip install django-storages[azure]
123+
```
124+
125+
#### Configure
126+
127+
```python
128+
MEDIA_ROOT = ""
129+
STORAGES = {
130+
"default": {
131+
"BACKEND": "storages.backends.azure_storage.AzureStorage",
132+
"OPTIONS": {
133+
"account_name": '<storage account name>',
134+
"azure_container": '<container name>', # As created within the blob service of your storage account
135+
"account_key": '<Key1 or Key2>', # From the access keys of your storage account
136+
"expiration_secs": 60,
137+
"overwrite_files": 'True',
138+
"location": '<path>' # The folder within the container where your pulp objects will be stored
139+
},
140+
},
141+
}
142+
```
143+
144+
Compreheensive options for Azure Blob can be found in
145+
[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/azure.html#configuration-settings).
146+

docs/admin/reference/settings.md

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,58 @@ For a zero downtime key rotation you can follow the slightly more complex recipe
7171
By default Pulp uses PostgreSQL on localhost. PostgreSQL is the only supported database. For
7272
instructions on how to configure the database, refer to `database installation <database-install>`.
7373

74-
### DEFAULT_FILE_STORAGE
74+
### DEFULT_FILE_STORAGE
75+
76+
!!! warning "Removed in `3.70`"
77+
The `DEFAULT_FILE_STORAGE` setting was deprecated in
78+
[django `4.2`](https://docs.djangoproject.com/en/4.2/ref/settings/#default-file-storage).
79+
Use [`STORAGES`](#STORAGES) instead.
80+
81+
### STORAGES
82+
83+
!!! note "Added in `3.70`"
84+
Replaces [`DEFAULT_DJANGO_STORAGES`](#DEFULT_FILE_STORAGE).
85+
86+
Pulp uses [django-storages](https://django-storages.readthedocs.io/en/latest/index.html) to support multiple storage backends.
87+
If no backend is configured, Pulp will by default use the local filesystem (`pulpcore.app.models.storage.FileSystem`).
88+
89+
To use another backend storage, you'll need to:
90+
91+
- 1. Setup your storage and gather required credentials and specific configs.
92+
- 1. Ensure the `django-storage[ s3 | google | azure ]` python package is installed. This depends on the installation method. On
93+
- 1. Configure the default `BACKEND` storage class.
94+
- 1. Configure available `OPTIONS` for that backend.
95+
96+
An Amazon S3 might look like this:
97+
98+
```python
99+
STORAGES = {
100+
"default": {
101+
"BACKEND": "storages.backends.s3.S3Storage",
102+
"OPTIONS": {
103+
"access_key": 'AKIAIT2Z5TDYPX3ARJBA',
104+
"secret_key": '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',
105+
"bucket_name": 'pulp3',
106+
"signature_version": "s3v4",
107+
"addressing_style": "path",
108+
"region_name": "eu-central-1",
109+
},
110+
},
111+
}
112+
```
113+
114+
Overview of the integration with Pulp:
75115

76-
By default, Pulp uses the local filesystem to store files. The default option which
77-
uses the local filesystem is `pulpcore.app.models.storage.FileSystem`.
116+
- **Supported**: We support (test) Amazon S3 and Azure. You can find more detailed information about it in
117+
[Configure Storages](site:pulpcore/docs/admin/guides/configure-pulp/configure-storages.md) guide.
118+
- **Untested**: Other backends provided by `django-storages` should work as well, but we provide no guarantee.
119+
- **Known caveat**: Using SFTP Storage is not recommended in Pulp's current state, and doing so can lead to file corruption. This is because Pulp currently uses coroutines that seem to be incompatible with Django's SFTPStorage implementation.
78120

79-
For more information about different Pulp storage options, see the
80-
`storage documentation `.
81121

82122
### REDIRECT_TO_OBJECT_STORAGE
83123

84124
When set to `True` access to artifacts is redirected to the corresponding Cloud storage
85-
configured in `DEFAULT_FILE_STORAGE` using pre-authenticated URLs. When set to `False`
125+
configured in `STORAGES['default']['BACKEND']` using pre-authenticated URLs. When set to `False`
86126
artifacts are always served by the content app instead.
87127

88128
Defaults to `True`; ignored for local file storage.
@@ -91,9 +131,10 @@ Defaults to `True`; ignored for local file storage.
91131

92132
The location where Pulp will store files. By default this is `/var/lib/pulp/media`.
93133

94-
This only affects storage location when `DEFAULT_FILE_STORAGE` is set to
95-
`pulpcore.app.models.storage.FileSystem`. See the `storage documentation ` for
96-
more info.
134+
This only affects storage location when `STORAGES['default']['BACKEND']` is set to
135+
`pulpcore.app.models.storage.FileSystem`.
136+
137+
See the [storage documentation](site:pulpcore/docs/admin/guides/configure-pulp/configure-storages.md) for more info.
97138

98139
It should have permissions of:
99140

@@ -188,7 +229,7 @@ It should have permissions of:
188229
### CHUNKED_UPLOAD_DIR
189230

190231
A relative path inside the DEPLOY_ROOT directory used exclusively for uploaded chunks. The
191-
uploaded chunks are stored in the default storage specified by `DEFAULT_FILE_STORAGE`. This
232+
uploaded chunks are stored in the default storage specified by `STORAGES['default']['BACKEND']`. This
192233
option allows users to customize the actual place where chunked uploads should be stored within
193234
the declared storage. The default, `upload`, is sufficient for most use cases. A change to
194235
this setting only applies to uploads created after the change.

0 commit comments

Comments
 (0)