Kubernetes, Automatic Service fallback to another namespace

10/22/2018

I have multiple environments represented by multiple namespaces in my kubernetes.

All application has its service endpoints defined in each namespace. And we have three environments, dev, alpha, and beta. (Which is equivalent of dev, test, and stage). These environments are permanent, which means all the applications are running there.

Now in my team, there are few parallel development happening, for which we are planning to create multiple environments for the release and which will be only having few applications which are part of that release.

Let's think of this example: I am building feature1 and have an impact on app1 and app2

There are 10 other apps which are not having any impact.

So for my development and the parallel testing majority of services that I have to point to existing alpha or beta env and only point the app1 and app2 in the namespace.

I could achieve this by having an ExternalName mapping for all other services.

But if I have more than 100 services and managing the external endpoint in a yaml I feel very difficult.

Is there any way that I can route all the traffic to another namespace(If there exist no service with that name.)

Is there a way for global ExternalName for a Namespace?

-- Ysak
kube-dns
kubernetes
kubernetes-namespace
kubernetes-service

1 Answer

10/22/2018

As far as I know, it is not possible to redirect traffic to a different namespace based on the existing pods or Services in the current namespace. You can select a destination for Service only by changing its YAML configuration, and it is only possible to select pods in the same namespace.

You can simplify the deployment procedure by using Helm charts. It allows you to put variables into YAML configuration of Deployments, Services, etc, and use separate value file to substitute them during installation to the cluster. Here is a link to a blog post on Using Helm to deploy to Kubernetes

-- Crou
Source: StackOverflow