Skip to content

Commit

Permalink
Revert "feat: run blob reaper every 72h (#152)"
Browse files Browse the repository at this point in the history
This reverts commit b7ab57f.
  • Loading branch information
emosbaugh authored Oct 8, 2024
1 parent 4582df6 commit 08d1ed1
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 57 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
env:
HEROKU_API_KEY: ${{secrets.HEROKU_API_KEY}}
steps:
- name: checkout
- name: Checkout
uses: actions/checkout@v2

- name: heroku registry login
Expand Down Expand Up @@ -52,12 +52,3 @@ jobs:

- name: release reaper
run: heroku container:release -a ttlsh-hooks reap

- name: build blob reaper
run: docker build -f registry/Dockerfile.blob-reap -t registry.heroku.com/ttlsh-hooks/blob-reap registry

- name: push blob reaper
run: docker push registry.heroku.com/ttlsh-hooks/blob-reap

- name: release blob reaper
run: heroku container:release -a ttlsh-hooks blob-reap
47 changes: 36 additions & 11 deletions kustomize/overlays/dev/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ spec:
spec:
containers:
- name: ttl-registry
image: ttl-registry
command: ["registry", "serve", "/etc/docker/registry/config.yml"]
image: registry:2
command: ["/entrypoint.sh"]
ports:
- containerPort: 5000
volumeMounts:
- name: registry-data
mountPath: /var/lib/registry
- name: registry-scripts
mountPath: /entrypoint.sh
subPath: entrypoint.sh
- name: registry-scripts
mountPath: /garbage-collect.sh
subPath: garbage-collect.sh
- name: registry-config
mountPath: /etc/docker/registry/config.yml
subPath: config.yml
Expand All @@ -36,21 +42,40 @@ spec:
path: /
port: 5000
scheme: HTTP
- name: ttl-blob-reap
image: ttl-blob-reap
command: ["/garbage-collect.sh"]
volumeMounts:
- name: registry-data
mountPath: /var/lib/registry
- name: registry-config
mountPath: /etc/docker/registry/config.yml
subPath: config.yml
volumes:
- name: registry-data
emptyDir: {}
- name: registry-config
configMap:
name: ttl-registry-config
- name: registry-scripts
configMap:
name: ttl-registry-scripts
defaultMode: 0755
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ttl-registry-scripts
labels:
app: ttl-registry
data:
entrypoint.sh: |
#!/bin/sh
set -e
# /garbage-collect.sh &
registry serve /etc/docker/registry/config.yml
garbage-collect.sh: |
#!/bin/sh
while true; do
sleep 1m
if [ ! -d "/var/lib/registry/docker" ]; then
echo "No registry data found, skipping garbage collection"
else
echo "Starting garbage collection..."
registry garbage-collect /etc/docker/registry/config.yml || true
fi
done
---
apiVersion: v1
kind: ConfigMap
Expand Down
8 changes: 0 additions & 8 deletions okteto.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
build:
ttl-registry:
context: ./registry
dockerfile: ./registry/Dockerfile
ttl-blob-reap:
context: ./registry
dockerfile: ./registry/Dockerfile.blob-reap
ttl-hooks:
context: ./hooks
dockerfile: ./hooks/Dockerfile.hooks
Expand All @@ -13,8 +7,6 @@ build:
dockerfile: ./hooks/Dockerfile.reap

deploy:
- cd kustomize/overlays/dev && kustomize edit set image ttl-registry=${OKTETO_BUILD_TTL_REGISTRY_IMAGE}
- cd kustomize/overlays/dev && kustomize edit set image ttl-blob-reap=${OKTETO_BUILD_TTL_BLOB_REAP_IMAGE}
- cd kustomize/overlays/dev && kustomize edit set image ttl-hooks=${OKTETO_BUILD_TTL_HOOKS_IMAGE}
- cd kustomize/overlays/dev && kustomize edit set image ttl-reaper=${OKTETO_BUILD_TTL_REAPER_IMAGE}

Expand Down
5 changes: 1 addition & 4 deletions registry/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM registry:2.7.1

ADD ./entrypoint.sh /entrypoint.sh
ADD ./config.yml /etc/docker/registry/config.tmpl.yml
ADD ./config.yml /etc/docker/registry/config.yml
ADD ./garbage-collect.sh /garbage-collect.sh

# entrypoint.sh will copy config.tmpl.yml to config.yml and replace variables
RUN rm -f /etc/docker/registry/config.yml

ENTRYPOINT ["/entrypoint.sh"]
CMD ["/etc/docker/registry/config.yml"]
12 changes: 0 additions & 12 deletions registry/Dockerfile.blob-reap

This file was deleted.

26 changes: 15 additions & 11 deletions registry/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

set -e

# in dev we mount this file into the container, so we can ignore the template
if [ ! -f /etc/docker/registry/config.yml ]; then
cp /etc/docker/registry/config.tmpl.yml /etc/docker/registry/config.yml
sed -i "s/__PORT__/$PORT/g" /etc/docker/registry/config.yml
sed -i "s/__HOOK_TOKEN__/$HOOK_TOKEN/g" /etc/docker/registry/config.yml
sed -i "s/__HOOK_URI__/$HOOK_URI/g" /etc/docker/registry/config.yml
sed -i "s/__REPLREG_HOST__/$REPLREG_HOST/g" /etc/docker/registry/config.yml
sed -i "s/__REPLREG_SECRET__/$REPLREG_SECRET/g" /etc/docker/registry/config.yml
fi
sed -i "s/__PORT__/$PORT/g" /etc/docker/registry/config.yml
sed -i "s/__HOOK_TOKEN__/$HOOK_TOKEN/g" /etc/docker/registry/config.yml
sed -i "s/__HOOK_URI__/$HOOK_URI/g" /etc/docker/registry/config.yml
sed -i "s/__REPLREG_HOST__/$REPLREG_HOST/g" /etc/docker/registry/config.yml
sed -i "s/__REPLREG_SECRET__/$REPLREG_SECRET/g" /etc/docker/registry/config.yml

if [ -z "${GCS_KEY_ENCODED}" ]; then
if [[ -z "${GCS_KEY_ENCODED}" ]]; then
echo "Set GCS_KEY_ENCODED variable"
else
echo "${GCS_KEY_ENCODED}" | base64 -d > /etc/gcs.json
echo ${GCS_KEY_ENCODED} | base64 -d > /etc/gcs.json
chmod 0400 /etc/gcs.json
fi

# Run garbage collection job in background
# /garbage-collect.sh &

case "$1" in
*.yaml|*.yml) set -- registry serve "$@" ;;
serve|garbage-collect|help|-*) set -- registry "$@" ;;
esac

exec "$@"
2 changes: 1 addition & 1 deletion registry/garbage-collect.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

while true; do
sleep 72h # every 3 days
sleep 1m
echo "Starting garbage collection..."
registry garbage-collect /etc/docker/registry/config.yml || true
done

0 comments on commit 08d1ed1

Please sign in to comment.