Is Using Ephemeral Namespaces for Feature Branches a Good Strategy?

0
18
Asked By BlueSkyDreamer42 On

I'm looking into a system where we set up a new namespace for each feature branch in our test clusters. The idea is to modify the namespace names with a suffix through the deployment pipeline, while also implementing some useful labels. The controllers would handle database creation and secret population as normal, although we would need to be careful with naming conventions and possibly use validating webhooks. Additionally, I would like to have a way to notify the team post-pipeline about the main entry points for testing.

I have a couple of questions: First, does this approach make sense for ephemeral environments? Is using namespaces the right choice? Secondly, has anyone built a controller that can automatically clean up unused namespaces? Would that be based on metrics or some kind of scheduling?

4 Answers

Answered By TechieTroublemaker On

In my experience, we ran into scaling problems with having a namespace for every feature branch. We switched it up to use an ephemeral namespace for each pull request, which seems to manage resources better. Also, I'm curious about your idea of setting up a database per namespace because that can drastically increase costs. Perhaps it would make more sense for developers to share a non-production database across those ephemeral namespaces.

Answered By DevGuru77 On

We've implemented a similar concept using ArgoCD alongside some bash scripting to handle the setup. We utilize Argo Workflows to kick things off and employ CloudNativePG to maintain an ephemeral state within the cluster. Eventually, I had to create some automation to clean up and garbage collect old namespaces once they were no longer needed.

Answered By NamespaceNerd On

I use this in some of my work projects with shared managed clusters. Even though our official tools don’t support it well, we still manage to make it work, and it’s been fantastic! Instead of a namespace for each branch, we create a new namespace for each automated build and for each developer. Each PR build generates a unique namespace, allowing complete freedom for developers. We deploy a CronJob to clean up the namespace two hours after it’s created, and if tests succeed, we destroy the namespace immediately. This method has dramatically reduced resource usage while helping every developer test in a realistic, production-like environment.

Answered By CodeNinja88 On

If you're not tied to using CRDs, I recommend checking out Project Capsule. It fits your needs perfectly, allowing you to apply labels and enforce a tenant prefix on namespace names. It simplifies management as you can associate your merge requests or pull requests as tenants and create the namespaces accordingly. Once you're finished with a feature branch, just clean up the tenant, and all related namespaces will be deleted automatically.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.