Heutzutage gibt es in jedem Haus einen Kubernetes-Cluster. Anwendungen werden durch das Tag auf den Cluster übertragen. Das Image der bereitgestellten Anwendung wird als Tag an das Repository des Registry GitLab-Projekts gesendet, das allmählich auf unglaubliche Größen ansteigt.
Bestehende Lösungen
Out-of-the-Box-Lösung
Settings → CI/CD → CleanUp policy for tags. , Bulk Delete , , . - , .
community
" "
.
, :
. , - , ( Job, CronJob ). , .
GitLab
GitLab registry , . , .
ron ,
sudo gitlab-ctl registry-garbage-collect
sudo gitlab-ctl registry-garbage-collect -m
: registry, push, pull.
registry readonly.
sudo vi /etc/gitlab/gitlab.rb
registry['storage'] = {
'maintenance' => {
'readonly' => {
'enabled' => true
}
}
}
sudo gitlab-ctl reconfigure
enabled false sudo gitlab-ctl reconfigure.
GitLab
GitLab GitLab API api + read_repository write_registry.
, registry GitLab, id id registry.
GitLab pagination
GitLab , 20 , 100 . X-Total, , .
/api/v4/projects, endpoint . , id.
, .
project[id] /api/v4/projects/{project[id]}/registry/repositories. id .
, , /api/v4/projects/{repo['project_id']}/registry/repositories/{repo['id']}/tags
, :
{
"location": "mygitlab.abc.ru:3000/dev/my-awsome-app/base:deploy_123",
"name": "deploy_123",
"path": "dev/my-awsome-app/base:deploy_123"
}
del_url, URL .
- , .
Kubernetes
Kubernetes kubernetes. , , - .
Kubernetes , kubectl rollout history < >, ReplicaSet . . , . replicaset namespace + label app replica_set.spec.template.spec.service_account. - , - . , N .
- Kubernetes, GitLab .
: Job CronJob ReplicaSet. .
, :)
" " ...
GitLab, , . .
, CronJob Job. .
Die Automatisierung ist in Python geschrieben , aber das ist nicht so wichtig. Mit ein wenig Überlegung können Sie die Codegröße und die Speicherkosten erheblich reduzieren.