Skip to content

A simple tool that can be deployed to Kubernetes clusters to clean up old Gitlab CI environment namespaces.

License

Notifications You must be signed in to change notification settings

anton-johansson/gitlab-ci-kubernetes-namespace-cleaner

Repository files navigation

Gitlab CI Kubernetes namespace cleaner

Build status

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. 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

$ make

Running outside cluster

$ 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.

License

Apache License 2.0 © Anton Johansson

About

A simple tool that can be deployed to Kubernetes clusters to clean up old Gitlab CI environment namespaces.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published