Skip to content

Commit

Permalink
feat: support docker operations for image in drydock backups (#53)
Browse files Browse the repository at this point in the history
* feat: support docker operations for image in drydock backups

* fix: update image variable in defaults and jobs template

* fix: update .gitignore

* fix: using BACKUP_VARIABLE

* fix: update readme

* fix: update gitignore for /build/ folder
  • Loading branch information
marbonilla authored Nov 29, 2023
1 parent 98f2cb3 commit 07d0371
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ __pycache__
# Packages
*.egg
*.egg-info
/build/
dist
build
eggs
parts
bin
Expand Down
2 changes: 1 addition & 1 deletion drydock_backups/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can enable it adding `drydock-backups` to the `plugins` section of the `conf
Configuration variables
-----------------------

- **BACKUP_IMAGE**: The image used to run the cronjob. (default: `ednxops/shipyard-utils:v1.0.0`)
- **BACKUP_DOCKER_IMAGE**: The image used to run the cronjob. (default: `ednxops/shipyard-utils:v{{BACKUP_VERSION}}`)
- **BACKUP_CRON_SCHEDULE**: Cron schedule to run the backup. (default: `0 2 * * *`)
- **BACKUP_STORAGE_SERVICE**: Storage service to use. (default: `aws-s3`) (options: `aws-s3`, `azure-blob`)
- **BACKUP_AWS_ACCESS_KEY**: AWS access key to access the bucket or minIO user.
Expand Down
4 changes: 2 additions & 2 deletions drydock_backups/patches/drydock-multipurpose-jobs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
restartPolicy: OnFailure
containers:
- name: backup
image: {{ BACKUP_IMAGE }}
image: {{ BACKUP_DOCKER_IMAGE }}
env:
- name: MYSQL_HOST
value: '{{ MYSQL_HOST }}'
Expand Down Expand Up @@ -100,7 +100,7 @@ spec:
restartPolicy: OnFailure
containers:
- name: backup
image: {{ BACKUP_IMAGE }}
image: {{ BACKUP_DOCKER_IMAGE }}
env:
- name: MONGODB_HOST
value: '{{ MONGODB_HOST }}'
Expand Down
55 changes: 22 additions & 33 deletions drydock_backups/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import pkg_resources
from tutor import hooks

from .__about__ import __version__
from drydock.__about__ import __version__

config = {
"defaults": {
"VERSION": __version__,
"IMAGE": "ednxops/shipyard-utils:v15.4.0",
"DOCKER_IMAGE": "ednxops/shipyard-utils:v{{BACKUP_VERSION}}",
"CRON_SCHEDULE": '0 2 * * *',
"STORAGE_SERVICE": "aws-s3",
"AWS_ACCESS_KEY": "",
Expand Down Expand Up @@ -88,47 +88,36 @@
# Images to be built by `tutor images build`.
# Each item is a quadruple in the form:
# ("<tutor_image_name>", ("path", "to", "build", "dir"), "<docker_image_tag>", "<build_args>")
hooks.Filters.IMAGES_BUILD.add_items(
[
# To build `myimage` with `tutor images build myimage`,
# you would add a Dockerfile to templates/drydock-backups/build/myimage,
# and then write:
### (
### "myimage",
### ("plugins", "drydock-backups", "build", "myimage"),
### "docker.io/myimage:{{ DRYDOCK_BACKUPS_VERSION }}",
### (),
### ),
]
)
hooks.Filters.IMAGES_BUILD.add_items([
(
"backups",
("plugins", "drydock-backups", "build", "backups"),
"{{BACKUP_DOCKER_IMAGE}}",
(),
)
])


# Images to be pulled as part of `tutor images pull`.
# Each item is a pair in the form:
# ("<tutor_image_name>", "<docker_image_tag>")
hooks.Filters.IMAGES_PULL.add_items(
[
# To pull `myimage` with `tutor images pull myimage`, you would write:
### (
### "myimage",
### "docker.io/myimage:{{ DRYDOCK_BACKUPS_VERSION }}",
### ),
]
)
hooks.Filters.IMAGES_PULL.add_items([
(
"backups",
"{{BACKUP_DOCKER_IMAGE}}",
)
])


# Images to be pushed as part of `tutor images push`.
# Each item is a pair in the form:
# ("<tutor_image_name>", "<docker_image_tag>")
hooks.Filters.IMAGES_PUSH.add_items(
[
# To push `myimage` with `tutor images push myimage`, you would write:
### (
### "myimage",
### "docker.io/myimage:{{ DRYDOCK_BACKUPS_VERSION }}",
### ),
]
)
hooks.Filters.IMAGES_PUSH.add_items([
(
"backups",
"{{BACKUP_DOCKER_IMAGE}}",
)
])


########################################
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 07d0371

Please sign in to comment.