(Kops)Kubernetes服务映射到AWS Route53中的DNS名称吗? [英] (Kops) Kubernetes Service maped to DNS names in AWS Route53?

查看:111
本文介绍了(Kops)Kubernetes服务映射到AWS Route53中的DNS名称吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Kops的新手,也是Kubernetes的新手.我设法用Kops创建了一个集群,并在其上运行了部署和服务.一切顺利,并为我创建了一个ELB,我可以通过此ELB端点访问该应用程序.

I am new to Kops and a bit to kubernetes as well. I managed to create a cluster with Kops, and run a deployment and a service on it. everything went well, and an ELB was created for me and I could access the application via this ELB endpoint.

我的问题是:如何将我的子域(例如my-sub.example.com)映射到生成的ELB端点?我相信这应该由kubernetes自动完成,并且我不应该在代码中对ELB端点进行硬编码.我尝试了与annotation -> DomainName有关的操作,但没有用.(请参见下面的kubernetes yml文件)

My question is: How can I map my subdomain (eg. my-sub.example.com) to the generated ELB endpoint ? I believe this should be somehow done automatic by kubernetes and I should not hardcode the ELB endpoint inside my code. I tried something that has to do with annotation -> DomainName, but it did not work.(see kubernetes yml file below)

apiVersion: v1
kind: Service
metadata:
  name: django-app-service
  labels:
    role: web
    dns: route53
  annotations:
    domainName: "my.personal-site.de"
spec:
  type: LoadBalancer
  selector:
    app: django-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8000

----

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: django-app-deployment
spec:
  replicas: 2
  minReadySeconds: 15
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    metadata:
      labels:
        app: django-app
    spec:
      containers:
        - image: fettah/djano_kubernetes_medium:latest
          name:  django-app
          imagePullPolicy: Always
          ports:
            - containerPort: 8000

推荐答案

在安装了ELB之后,您可以使用外部DNS( https://github.com/kubernetes-incubator/external-dns )插件,该插件可以使用AWS Route53集成将DNS记录附加到那些ELB.您需要为Kubernetes添加适当的权限,以便他可以在Route53中创建DNS记录-您需要在kops集群配置的extraPolicies部分的kops中添加其他策略(根据external-dns插件中的指南).然后使用如下注释:

When you have ELBs in place you can use external-dns (https://github.com/kubernetes-incubator/external-dns) plugin which can attach DNS records to those ELBs using AWS Route53 integration. You need to add proper rights to Kubernetes so he can create DNS record in Route53 - you need to add additional policy in kops (according guide in external-dns plugin) in additionalPolicies section in kops cluster configuration. Then use annotation like:

external-dns.alpha.kubernetes.io/hostname: myservice.mydomain.com.

这篇关于(Kops)Kubernetes服务映射到AWS Route53中的DNS名称吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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