简体   繁体   English

如何将 DNS 配置为 kubernetes 入口?

[英]How do I configure DNS to a kubernetes ingress?

I have purchased 3 VPS and have IP address like我已经购买了 3 个 VPS 并且有 IP 地址,例如

   172.168.1.146
   72.168.43.245
   98.156.56.123

I have got an ingress controller我有一个入口 controller

I have installed metallb which loadbalances traffic and sends it to any of the IP address.我已经安装了metallb,它可以对流量进行负载平衡并将其发送到任何 IP 地址。

Now how do I provide a static IP to my kubernetes cluster endpoint?现在如何向我的 kubernetes 集群端点提供 static IP?

Should I purchase a virtual IP and configure it to metallb?我应该购买虚拟 IP 并将其配置为 metallb 吗? If so how?如果有怎么办?

or或者

Should I configure keepalived in all the above nodes and configure a virtual IP.我是否应该在上述所有节点中配置keepalived并配置虚拟IP。 In this case can I configure the same virtual IP to all the nodes?在这种情况下,我可以为所有节点配置相同的虚拟 IP 吗? Will there not be an IP conflict?不会有 IP 冲突吗? If one of the node dies will the virtual IP be automatically assigned to another node which is alive?如果其中一个节点死亡,虚拟 IP 是否会自动分配给另一个活着的节点? If so what would be the usual duration of automatically assigning the IP address to another node which is alive?如果是这样,自动将 IP 地址分配给另一个活动的节点的通常持续时间是多少?

MetalLB is currently in beta. MetalLB 目前处于测试阶段。 Read about the Project maturity and make sure you inform yourself by reading the official documentation thoroughly.阅读有关项目成熟度的信息,并确保您通过彻底阅读官方文档来了解自己。

MetalLB can be deployed either with a simple Kubernetes manifest or with Helm. MetalLB 可以使用简单的 Kubernetes 清单或 Helm 进行部署。 The rest of this example assumes MetalLB was deployed following the Installation instructions.此示例的 rest 假设 MetalLB 已按照安装说明进行部署。 MetalLB requires a pool of IP addresses in order to be able to take ownership of the ingress-nginx Service. MetalLB 需要一个 IP 地址池,以便能够获得 ingress-nginx 服务的所有权。 This pool can be defined in a ConfigMap named config located in the same namespace as the MetalLB controller.该池可以在名为 config 的 ConfigMap 中定义,该 ConfigMap 位于与 MetalLB controller 相同的命名空间中。 This pool of IPs must be dedicated to MetalLB's use, you can't reuse the Kubernetes node IPs or IPs handed out by a DHCP server.此 IP 池必须专用于 MetalLB 使用,您不能重复使用 Kubernetes 节点 IP 或 DHCP 服务器分发的 IP。

Given the following 3-node Kubernetes cluster (the external IP is added as an example给定如下3节点Kubernetes集群(外加IP为例

$ kubectl get node
NAME     STATUS   ROLES    EXTERNAL-IP
host-1   Ready    master   203.0.113.1
host-2   Ready    node     203.0.113.2
host-3   Ready    node     203.0.113.3

After creating the following ConfigMap, MetalLB takes ownership of one of the IP addresses in the pool and updates the loadBalancer IP field of the ingress-nginx Service accordingly.创建以下 ConfigMap 后,MetalLB 获得池中 IP 地址之一的所有权,并相应地更新 ingress-nginx 服务的 loadBalancer IP 字段。

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 203.0.113.10-203.0.113.15

You include the IPs in the MetalLB config file.您在 MetalLB 配置文件中包含 IP。 Or really just one since that's all it needs.或者真的只是一个,因为这就是它所需要的。 https://metallb.universe.tf/configuration/#layer-2-configuration https://metallb.universe.tf/configuration/#layer-2-configuration

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.1.240-192.168.1.250 

That's for L2 mode which is more likely what you want, but you should confirm with your networking upstream that gratuitous ARP will 1) work and 2) not get you banned from the network.这适用于 L2 模式,这更可能是您想要的,但您应该向上游网络确认无偿 ARP 将 1) 工作并且 2) 不会让您被禁止进入网络。 Neither of these are assured from a baseline of "random VPS you just setup".从“您刚刚设置的随机 VPS”的基线来看,这些都没有得到保证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM