[英]Kubernetes expose multiple pods
I have a kubernetes cluster with multiple pods from different images. 我有一个Kubernetes集群,其中包含来自不同图像的多个Pod。
I want to be able to expose each of those pods so I will be able to access them using an external DNS record (outside the cluster). 我希望能够公开每个吊舱,以便能够使用外部DNS记录(在群集外部)访问它们。
For example: Let's say I have 3 pods (pod1,pod2,pod3), I want to be able to access them from outside the cluster this way: 例如:假设我有3个Pod(pod1,pod2,pod3),我希望能够以这种方式从集群外部访问它们:
http://pod1.mydomain.com http://pod1.mydomain.com
http://pod2.mydomain.com http://pod2.mydomain.com
http://pod3.mydomain.com http://pod3.mydomain.com
Is there a way to do it? 有办法吗?
Thanks 谢谢
In AWS you can easily expose PODs using ELB - Kubernetes can automatically create proper ELBs for you. 在AWS中,您可以使用ELB轻松公开POD-Kubernetes可以自动为您创建合适的ELB。 It means that Kubernetes spawn ELB and then attach it to proper services using nodes ports.
这意味着Kubernetes会生成ELB,然后使用节点端口将其附加到适当的服务。 When you have ELBs in place you can use external-dns plugin metioned by GarMan which can attach DNS records to those ELBs using AWS Route53 integration.
放置好ELB后,您可以使用GarMan提及的external-dns插件,该插件可以使用AWS Route53集成将DNS记录附加到那些ELB。 So you need to:
因此,您需要:
Example service would look like: 服务示例如下所示:
apiVersion: v1
kind: Service
metadata:
name: public-pod1
namespace: your-deployment
labels:
app: pod1
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
external-dns.alpha.kubernetes.io/hostname: pod1.mydomain.com.
spec:
type: LoadBalancer
loadBalancerSourceRanges:
- 0.0.0.0/0 # Ingress SG for your ELB
ports:
- port: 80
protocol: TCP
targetPort: 80 #That should match your app's port
selector:
app: pod1
外部dns( https://github.com/kubernetes-incubator/external-dns )就是为了做到这一点,您用您要为其提供的dns名称来注释您的服务,而external-dns为此创建了相关的dns条目。您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.