使用Helm运算符为Kubernetes自动化通配符子域支持 [英] Automating wildcard subdomain support for Kubernetes using Helm operator
问题描述
这是我的用例:
我们有一个客户,他们的每项服务都必须在专用子域上可用.命名约定应为service-name.customerdomain.com
,其中service-name
是已部署的服务,而customerdomain.com
是客户域.创建新服务后,该服务应该自动可用,即,一旦service-name
服务部署到群集中,它就必须在service-name.customerdomain.com
上可用.
Here is my use case:
We have a customer, where each of their services has to be available on dedicated subdomain. Naming convention should be service-name.customerdomain.com
, where service-name
is the deployed service and customerdomain.com
is the customer domain. When a new service is created, it should be available automatically, i.e. once service-name
service is deployed into the cluster, it has to be available on service-name.customerdomain.com
.
我知道,这可以通过以下步骤手动实现:
I know, this can be achieved manually by following steps:
-
将Ingress控制器添加到集群
Add Ingress controller to the cluster
创建通配符DNS *.customerdomain.com
,并将其指向
入口控制器
Create wildcard DNS *.customerdomain.com
and point it to the
Ingress controller
Spec:
rules:
- host: helloworld.awesome-customer.com
http:
paths:
- path: /*
backend:
serviceName: helloworld
servicePort: 8080
- host: nextfineapp.awesome-customer.com
http:
paths:
- path: /*
backend:
serviceName: nextfineapp
servicePort: 8080
- [...]
- 为每个新添加的Ingress资源文件添加新的
-host
部分 部署的服务 - 对于每个已删除的目录,删除Ingress资源文件
-host
部分 服务
- Add Ingress resource file new
-host
section for each newly deployed service - Remove Ingress resource file
-host
section for each removed service
基本上-我想自动执行第4步和第2步. 5.我知道Ingress无法自行处理此问题,但是,四处搜寻,看来每次部署新服务/删除现有服务时都可以通过
Basically - I would like to automate steps 4 & 5. I am aware Ingress cannot handle this by itself, however, googling around, it appears that updating ingress.yaml
file each time a new service is deployed / an existing one is removed can be achieved via Helm and its values files.
如果能指出/描述以下示例解决方案,我将不胜感激.
I would appreciate if a sample solution can be pointed out / described below.
推荐答案
通常,通过将Ingress资源的模板作为基础应用程序图表的一部分来实现此目的.您可以有多个Ingress对象,并且它们都将在运行时被多路复用以为您的控制器构建路由表.
You would generally do this by having a template for the Ingress resource as a part of your base application chart. You can have more than one Ingress object and they will all get muxed at run time to build the routing table for your controller.
这篇关于使用Helm运算符为Kubernetes自动化通配符子域支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!