|
| 1 | +:_content-type: PROCEDURE |
| 2 | +[id="managing-namespace-auto-pruning-policies"] |
| 3 | += Managing namespace auto-pruning policies using the {productname} UI |
| 4 | + |
| 5 | +Namespace auto-pruning policies are created using the {productname} UI v2. This can be done after you have configured your {productname} `config.yaml` file to enable the auto-pruning feature. |
| 6 | + |
| 7 | +[NOTE] |
| 8 | +==== |
| 9 | +This feature is not available when using the {productname} legacy UI. |
| 10 | +==== |
| 11 | + |
| 12 | +[id="configuring-namespace-auto-prune-feature"] |
| 13 | +== Configuring the {productname} namespace auto-pruning feature |
| 14 | + |
| 15 | +Use the following procedure to configure your {productname} `config.yaml` file to enable the namespace auto-pruning feature. |
| 16 | + |
| 17 | +.Procedure |
| 18 | + |
| 19 | +* In your {productname} `config.yaml` file, add, and set, the `FEATURE_AUTO_PRUNE` environment variable to `True`. For example: |
| 20 | ++ |
| 21 | +[source,yaml] |
| 22 | +---- |
| 23 | +# ... |
| 24 | +FEATURE_AUTO_PRUNE: True |
| 25 | +# ... |
| 26 | +---- |
| 27 | + |
| 28 | +[id="creating-policy-v2-ui"] |
| 29 | +== Creating an auto-prune policy using the {productname} v2 UI |
| 30 | + |
| 31 | +Use the following procedure to create an auto-prune policy using the {productname} UI v2. |
| 32 | + |
| 33 | +.Prerequisites |
| 34 | + |
| 35 | +* You have enabled the `FEATURE_AUTO_PRUNE` feature. |
| 36 | + |
| 37 | +.Procedure |
| 38 | + |
| 39 | +. Tag three sample images, for example, `busybox`, that will be pushed to the repository with auto-pruning enabled. For example: |
| 40 | ++ |
| 41 | +[source,terminal] |
| 42 | +---- |
| 43 | +$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test |
| 44 | +---- |
| 45 | ++ |
| 46 | +[source,terminal] |
| 47 | +---- |
| 48 | +$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test2 |
| 49 | +---- |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test3 |
| 54 | +---- |
| 55 | ++ |
| 56 | +[source,terminal] |
| 57 | +---- |
| 58 | +$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test4 |
| 59 | +---- |
| 60 | + |
| 61 | +. Push the three sample images, for example, `busybox`, to the repository with auto-pruning enabled by entering the following commands: |
| 62 | ++ |
| 63 | +[source,terminal] |
| 64 | +---- |
| 65 | +$ podman push <quay-server.example.com>/quayadmin/busybox:test |
| 66 | +---- |
| 67 | ++ |
| 68 | +[source,terminal] |
| 69 | +---- |
| 70 | +$ podman push <quay-server.example.com>/<quayadmin>/busybox:test2 |
| 71 | +---- |
| 72 | ++ |
| 73 | +[source,terminal] |
| 74 | +---- |
| 75 | +$ podman push <quay-server.example.com>/<quayadmin>/busybox:test3 |
| 76 | +---- |
| 77 | ++ |
| 78 | +[source,terminal] |
| 79 | +---- |
| 80 | +sudo podman push --tls-verify=false <quay-server.example.com>/<quayadmin>/busybox:test4 |
| 81 | +---- |
| 82 | + |
| 83 | +. Check that there are four tags in your repository. |
| 84 | + |
| 85 | +. On the {productname} UI v2, click *Organizations* in the navigation pane. |
| 86 | + |
| 87 | +. Select the name of an organization that you will apply the auto-pruning feature to, for example, `test_organization`. |
| 88 | + |
| 89 | +. Click *Settings*. |
| 90 | + |
| 91 | +. Click *Auto-Prune Policies*. For example: |
| 92 | ++ |
| 93 | +image:auto-prune-policies-page.png[Auto-Prune Policies page] |
| 94 | + |
| 95 | +. Click the drop down menu and select the desired policy, for example, *By number of tags*. |
| 96 | + |
| 97 | +. Select the desired number of tags to keep. By default, this is set at *20* tags. For this example, the number of tags to keep is set at *3*. |
| 98 | + |
| 99 | +Click *Save*. The following alert is received: *Successfully updated auto-prune policy*. |
| 100 | + |
| 101 | +.Verification |
| 102 | + |
| 103 | +* Navigate to the *Tags* page of your repository. After a few minutes, the auto-pruner worker removes tags that no longer fit within the established criteria. In this example, it removes the `busybox:test` tag, and keeps the `busybox:test2`, `busybox:test3`, and `busybox:test4` tag. |
| 104 | ++ |
| 105 | +After tags are automatically pruned, they go into the {productname} time machine, or the amount of time, after a tag is deleted, that the tag is accessible before being garbage collected. The expiration time of an image tag is dependent on your organization's settings. For more information, see link:https://access.redhat.com/documentation/en-us/red_hat_quay/3/html-single/manage_red_hat_quay/index#garbage-collection[{productname} garbage collection]. |
| 106 | + |
| 107 | +[id="creating-policy-api"] |
| 108 | +== Creating an auto-prune policy using the {productname} API |
| 109 | + |
| 110 | +You can use {productname} API endpoints to manage auto-pruning policies for an organization. |
| 111 | + |
| 112 | +.Prerequisites |
| 113 | + |
| 114 | +* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file. |
| 115 | +* You have created an OAuth access token. |
| 116 | +* You have logged into {productname}. |
| 117 | + |
| 118 | +.Procedure |
| 119 | + |
| 120 | +. Enter the following `POST` command create a new policy that limits the number of tags allowed in an organization: |
| 121 | ++ |
| 122 | +[source,terminal] |
| 123 | +---- |
| 124 | +$ curl -X POST -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" -H "Content-Type: application/json" -d '{ |
| 125 | + "method": "number_of_tags", |
| 126 | + "value": 10 |
| 127 | +}' http://<quay-server.example.com>/api/v1/organization/<quayadmin>/autoprunepolicy/ |
| 128 | +---- |
| 129 | ++ |
| 130 | +Alternatively, you can can set tags to expire for a specified time after their creation date: |
| 131 | ++ |
| 132 | +[source,terminal] |
| 133 | +---- |
| 134 | +$ curl -X POST -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" -H "Content-Type: application/json" -d '{ |
| 135 | + "method": "creation_date", |
| 136 | + "value": "7d" |
| 137 | +}' http://<quay-server.example.com>/api/v1/organization/<quayadmin>/autoprunepolicy/ |
| 138 | +---- |
| 139 | ++ |
| 140 | +.Example output |
| 141 | +[source,terminal] |
| 142 | +---- |
| 143 | +{"uuid": "73d64f05-d587-42d9-af6d-e726a4a80d6e"} |
| 144 | +---- |
| 145 | ++ |
| 146 | +Attempting to create multiple policies returns the following error: |
| 147 | ++ |
| 148 | +[source,terminal] |
| 149 | +---- |
| 150 | +{"detail": "Policy for this namespace already exists, delete existing to create new policy", "error_message": "Policy for this namespace already exists, delete existing to create new policy", "error_type": "invalid_request", "title": "invalid_request", "type": "http://<quay-server.example.com>/api/v1/error/invalid_request", "status": 400} |
| 151 | +---- |
| 152 | + |
| 153 | +. Check your auto-prune policy by entering the following command: |
| 154 | ++ |
| 155 | +[source,terminal] |
| 156 | +---- |
| 157 | +$ curl -X GET -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" http://<quay-server.example.com>/api/v1/organization/<quayadmin>/autoprunepolicy/ |
| 158 | +---- |
| 159 | ++ |
| 160 | +.Example output |
| 161 | ++ |
| 162 | +[source,terminal] |
| 163 | +---- |
| 164 | +{"policies": [{"uuid": "73d64f05-d587-42d9-af6d-e726a4a80d6e", "method": "creation_date", "value": "7d"}]} |
| 165 | +---- |
| 166 | + |
| 167 | +. You can delete the auto-prune policy by entering the following command: |
| 168 | ++ |
| 169 | +[source,terminal] |
| 170 | +---- |
| 171 | +$ curl -X DELETE -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" http://<quay-server.example.com>/api/v1/organization/<quayadmin>/autoprunepolicy/ |
| 172 | +---- |
| 173 | + |
| 174 | +[id="creating-policy-api-current-user"] |
| 175 | +== Creating an auto-prune policy for the current user using the API |
| 176 | + |
| 177 | +You can use {productname} API endpoints to manage auto-pruning policies for your account. |
| 178 | + |
| 179 | +[NOTE] |
| 180 | +==== |
| 181 | +The use of `/user/` in the following commands represents the user that is currently logged into {productname}. |
| 182 | +==== |
| 183 | + |
| 184 | +.Prerequisites |
| 185 | + |
| 186 | +* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file. |
| 187 | +* You have created an OAuth access token. |
| 188 | +* You have logged into {productname}. |
| 189 | + |
| 190 | +.Procedure |
| 191 | + |
| 192 | +. Enter the following `POST` command create a new policy that limits the number of tags for the current user: |
| 193 | ++ |
| 194 | +[source,terminal] |
| 195 | +---- |
| 196 | +$ curl -X POST -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" -H "Content-Type: application/json" -d '{ |
| 197 | + "method": "number_of_tags", |
| 198 | + "value": 10 |
| 199 | +}' http://<quay-server.example.com>/api/v1/user/autoprunepolicy/ |
| 200 | +---- |
| 201 | ++ |
| 202 | +.Example output |
| 203 | ++ |
| 204 | +[source,terminal] |
| 205 | +---- |
| 206 | +{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859"} |
| 207 | +---- |
| 208 | + |
| 209 | +. Check your auto-prune policy by entering the following command: |
| 210 | ++ |
| 211 | +[source,terminal] |
| 212 | +---- |
| 213 | +$ curl -X GET -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859 |
| 214 | +---- |
| 215 | ++ |
| 216 | +Alternatively, you can include the UUID: |
| 217 | ++ |
| 218 | +[source,terminal] |
| 219 | +---- |
| 220 | +$ curl -X GET -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859 |
| 221 | +{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859", "method": "number_of_tags", "value": 10} |
| 222 | +---- |
| 223 | ++ |
| 224 | +.Example output |
| 225 | ++ |
| 226 | +[source,terminal] |
| 227 | +---- |
| 228 | +{"policies": [{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859", "method": "number_of_tags", "value": 10}]} |
| 229 | +---- |
| 230 | + |
| 231 | +. You can delete the auto-prune policy by entering the following command. Note that deleting the policy require the UUID. |
| 232 | ++ |
| 233 | +[source,terminal] |
| 234 | +---- |
| 235 | +$ curl -X DELETE -H "Authorization: Bearer j8mvpgf0rP5wpbS7LCfDaAxE0NZvCmOC123456" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859 |
| 236 | +---- |
| 237 | ++ |
| 238 | +.Example output |
| 239 | ++ |
| 240 | +[source,terminal] |
| 241 | +---- |
| 242 | +{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859"} |
| 243 | +---- |
0 commit comments