如何将服务从Kubernetes群集曝光到外部网络,以便使用DNS提供它们?
我想通过使用DNS向外部网络公开服务。例如,我有服务my-service
,我想将其展示为my-service.my-cluster.com
。
- 我应该使用一些代理(例如nginx ...)还是Kubernetes支持这一点?
- 是DNS应该手动配置或有一些自动化。
我认为以后将其用于开发和生产 - 也许对两种用例都更好。
例如,我想公开以下内容:
apiVersion: v1
kind: Service
metadata:
labels:
app: my-service
name: my-service
spec:
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
selector:
app: my-service
I want to expose service to external network with use DNS. For example I have service my-service
and I want to expose it as my-service.my-cluster.com
.
- Should I use some proxy (like nginx ...) or Kubernetes support this?
- Is DNS should be configured manually or there is some automation.
I assume use it to development and production later - maybe different methods is better for both use case.
For example I want to expose this:
apiVersion: v1
kind: Service
metadata:
labels:
app: my-service
name: my-service
spec:
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
selector:
app: my-service
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我们谈论的是http服务,因此您应该使用
基本上,Ingress控制器以类型LoadBalancer的服务曝光,并为其找到的每个入口创建基于名称的虚拟主机。
可以通过外部dns - 在某些情况下 - 在某些情况下。也就是说,如果您使用支持的DNS提供商和兼容的入口控制器(大多数)。
Since we are talking of an http service, you should use an ingress:
Basically, an Ingress Controller exposes itself at a Service of type LoadBalancer and creates name-based virtual hosts for each ingress it finds.
Automatic DNS provisioning can be achieved via external-dns – under certain circumstances. Namely if you use a supported DNS provider and a compatible ingress controller (most are).