Eneco / landscaper

Deprecated. Takes a set of Helm Chart references with values (a desired state), and realizes this in a Kubernetes cluster
Apache License 2.0
336 stars 31 forks source link

Release Filter using Prefix #93

Open otaviof opened 7 years ago

otaviof commented 7 years ago

Considering that we have two namespaces, one test and another acceptance, and a release named nginx with prefix prereq is being deployed on both environments. My expected outcome would be that both namespaces would get prereq-nginx installed, but what happens is that it get removed from the first namespace (what is not the target of Landscaper's current run).

On debugging logging we can observe:

time="2017-09-05T21:25:40Z" level=debug msg=listHelmReleases 
2017/09/05 21:25:40 warning: destination for annotations is a table. Ignoring non-table value <nil>
[snip]
time="2017-09-05T21:25:40Z" level=debug msg="Reading secrets for component" component=prereq-nginx namespace=acceptance 
time="2017-09-05T21:25:40Z" level=debug msg="No secrets found for component" component=prereq-nginx namespace=acceptance
[snip]
time="2017-09-05T21:25:40Z" level=debug msg="Reading secrets for component" component=prereq-test-nginx namespace=test
time="2017-09-05T21:25:41Z" level=debug msg="No secrets found for component" component=prereq-test-nginx namespace=test 
[snip]
time="2017-09-05T21:25:41Z" level=info msg="Retrieved Releases (Components)" landscapedComponents=18 totalReleases=18 
time="2017-09-05T21:25:41Z" level=info msg="Apply desired state" create=0 delete=5 update=0 
[snip]
time="2017-09-05T21:25:41Z" level=info msg="Delete: prereq-test-nginx"

At state_provider.go +271 we have:

    filter := helm.ReleaseListFilter(fmt.Sprintf("^%s.+", cp.releaseNamePrefix))

So it only filters by the regexp applied on prefix, on which the example here it matches on two different namespaces, then would be possible to exclude releases that are not currently on target namespace? I think the desired behavior is to only "delete" the release if it's deployed on the same (target) namespace, and on this example both prereq-nginx would be kept.

ImMiracleMax commented 6 years ago

We ran into the same problem, we end up using --disable delete all over the place.

johnhofman commented 6 years ago

We include the environment in our prefix, but that is getting unwieldy. Another solution is to use a separate tiller namespace per environment, we are planning to move to this because we can also keep the configmaps and tiller rbac separate.