Used code from https://github.com/nzelepukin/kube_gittlab_regcleaner
Do you have a Kubernetes cluster and GitLab registry full of unused images? Delete unused images from GitLab and keep images used by apps in Kubernetes.
CPU_REQUEST = 0.05
RAM_REQUEST = 64
MbCPU_LIMIT = 0.5
RAM_LIMIT = 128
Mb
python3.9 start.py
docker build -t gitlab-regcleaner .
-
CI_API_V4_URL=https://gitlab.example.com/api/v4
- The GitLab API v4 root URL -
CI_PROJECT_ID=100
- The ID of the current project. This ID is unique across all projects on the GitLab instance -
GITLAB_REGCLEAN_TOKEN=asdasdasd
- GitLab token (api, read_registry, write_registry) -
GITLAB_INCLUDE_TAGS
- Regexp mask for the tag included in the deletion -
GITLAB_EXCLUDE_TAGS
- Regexp mask for the tag excluded from deletion -
GITLAB_REMOVE_UNUSED_TAGS=false
- false - inspect, true - remove unused images -
KUBECONFIG=~/.kube/config
- kubernetes config path (recommended permissions - get, list, watch) -
KUBE_NAMESPACE
- The namespace associated with the project -
KUBE_HISTORY=5
- How much images from rollout history you want to keep.
cleanup:
image: vfilon/gitlab-regcleaner:latest
stage: cleanup
variables:
GIT_STRATEGY: none
environment:
name: $ENV_NAME
url: $DEPLOY_URL
action: prepare
script:
- cleanup.sh