Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anton-johansson/gitlab-ci-kubernetes-namespace-cleaner
A simple tool that can be deployed to Kubernetes clusters to clean up old Gitlab CI environment namespaces.
https://github.com/anton-johansson/gitlab-ci-kubernetes-namespace-cleaner
cleanup continuous-delivery docker-image gitlab-ci golang kubernetes
Last synced: about 7 hours ago
JSON representation
A simple tool that can be deployed to Kubernetes clusters to clean up old Gitlab CI environment namespaces.
- Host: GitHub
- URL: https://github.com/anton-johansson/gitlab-ci-kubernetes-namespace-cleaner
- Owner: anton-johansson
- License: apache-2.0
- Created: 2020-02-21T14:15:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-07T17:19:22.000Z (about 4 years ago)
- Last Synced: 2024-06-19T06:48:11.176Z (5 months ago)
- Topics: cleanup, continuous-delivery, docker-image, gitlab-ci, golang, kubernetes
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gitlab CI Kubernetes namespace cleaner
[![Build status](https://travis-ci.org/anton-johansson/gitlab-ci-kubernetes-namespace-cleaner.svg)](https://travis-ci.org/anton-johansson/gitlab-ci-kubernetes-namespace-cleaner)
If you are using Gitlab to automatically deploy to Kubernetes using Gitlab CI and Gitlab environments, you might have noticed that when environments (deployments) are removed, the `Namespace` resource will stay around forever. Gitlab simply does not remove it (yet). There is an official issue for this that you can find [here](https://gitlab.com/gitlab-org/gitlab/issues/27501). Until the issue is resolved, this cleaning tool might help you out! It's a simple tool, written in Golang, that can be deployed to your cluster as a `CronJob` that removes these stale namespaces on a daily basis.
**Note:** This will check all namespaces that matches the pattern `^gitlab-ci-test-.+` and has no running pods and **delete** them. If you have namespaces that matches this pattern that does not run any pods and you want to keep them, **do not run this tool**.
## Building
```shell
$ make
```## Running outside cluster
```shell
$ bin/gitlab-ci-kubernetes-namespace-cleaner-linux-amd64 clean --kubeconfig /home/myuser/.kube/config
```## Running inside cluster
You can find Kubernetes manifests for running this tool inside the cluster [here](./deploy).
## License
Apache License 2.0 © [Anton Johansson](https://github.com/anton-johansson)