在Kubernates部署中如何使ELB附加到route53中的域名 [英] How to make the ELB attach to a domain name in route53 in Kubernates deployments

查看:78
本文介绍了在Kubernates部署中如何使ELB附加到route53中的域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在执行部署并使用loadbalancer类型创建服务.我可以通过创建的ELB访问POD.然后使用路由53,我使用别名将ELB附加到k8-test.abc.com.下面是代码段.

Currently I am doing deployment and creating a service with type loadbalancer. I can access the POD via the created ELB. Then using route 53 I am attaching the ELB with k8-test.abc.com using alias. Below is the snippet.

apiVersion: v1
kind: Service
metadata:
  name: %APP_FULL_NAME%-service-lb-http
  labels:
    appname: %APP_FULL_NAME%
    stage: %APP_ENV%
    component: app-kube-aws-elb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "True"
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:XXXXXXXXXXXXX:certificate/XXXXXXXXXXXXXXX
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http

spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 443
    targetPort: 8080
    protocol: TCP
  selector:
    appname: %APP_FULL_NAME%
    stage: %APP_ENV%

但是我想知道有什么方法可以对部署和将要创建的ELB进行一些更改,这些更改会在创建时自动附加到k8-test.abc.com上.

But I was wondering is there any way by which I can do some changes on deployment and the ELB which will be created, automatically get attached to the k8-test.abc.com while creating.

推荐答案

有一个名为

There is an Incubator project (read: you may use it, but don't complain if it breaks) called external-dns. I haven't used it myself, but it looks like it may do what you ask for. Among other DNS providers, it also offers support for Route53.

设置后(此处有关如何在AWS上设置 external-dns 的文档),您可以使用 external-dns.alpha.kubernetes.io/hostname定义服务的DNS名称注释:

After set-up (here's the documentation on how to set-up external-dns on AWS), you can define a DNS name for a Service using the external-dns.alpha.kubernetes.io/hostname annotation:

apiVersion: v1
kind: Service
metadata:
  name: %APP_FULL_NAME%-service-lb-http
  labels:
    appname: %APP_FULL_NAME%
    stage: %APP_ENV%
    component: app-kube-aws-elb
  annotations:
    external-dns.alpha.kubernetes.io/hostname: k8-test.abc.com
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "True"
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:XXXXXXXXXXXXX:certificate/XXXXXXXXXXXXXXX
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 443
    targetPort: 8080
    protocol: TCP
  selector:
    appname: %APP_FULL_NAME%
    stage: %APP_ENV%

这将自动创建相应的DNS记录,这些DNS记录会将DNS名称 k8-test-abc.com 别名为您的ELB.

This will automatically create the respective DNS records that will alias the DNS name k8-test-abc.com to your ELB.

这篇关于在Kubernates部署中如何使ELB附加到route53中的域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆