首页 > 解决方案 > 动态访问 Kubernetes 命名空间

问题描述

是否可以定义入口,使其指向不同的命名空间。

例如,为不同的客户运行相同的应用程序。命名空间 - Customer1、Customer2

两者都有相同的 api - /api/v1/images/

两者都托管在同一个集群上 - api-dev

现在我们可以根据 api 中的客户名称将流量引导到不同的命名空间,例如

Customer1/api/v1/images/- 将显示存储在 Customer1 命名空间中的图像

Customer2/api/v1/images/- 将显示存储在 Customer2 命名空间中的图像

客户名称将由在默认命名空间中运行的另一个服务提供

在此处输入图像描述

标签: kubernetesgoogle-cloud-platformgoogle-kubernetes-enginekubernetes-ingress

解决方案


There are several ways to do this:

  1. You can create a DNS entry per Service in each namespace and have each namespace have its own LoadBalancer (perhaps costly but each app can be independently scaled etc)

  2. You can use Istio and create a single Gateway and create a VirtualServices to each Namespace. This allows one DNS to your cluster and Istio can redirect traffic to each namespace without having to update the cluster DNS

  3. You can write a short CodeZero provisioner for your app (https://github.com/c6o/provisioners) and CodeZero will automatically do the DNS/ingress for each app instance in each namespace. You can test this out using an existing app


推荐阅读