首页 > 解决方案 > 不为入口资源创建 DNS 记录

问题描述

我的配置:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: external-dns
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: external-dns
rules:
- apiGroups: [""]
  resources: ["services"]
  verbs: ["get","watch","list"]
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get","watch","list"]
- apiGroups: ["extensions"] 
  resources: ["ingresses"] 
  verbs: ["get","watch","list"]
- apiGroups: [""]
  resources: ["nodes"]
  verbs: ["list"]
- apiGroups: ["networking.istio.io"]
  resources: ["gateways"]
  verbs: ["get","watch","list"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: external-dns-viewer
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: external-dns
subjects:
- kind: ServiceAccount
  name: external-dns
  namespace: kube-system
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: external-dns
  namespace: kube-system
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      serviceAccountName: external-dns
      containers:
      - name: external-dns
        image: registry.opensource.zalan.do/teapot/external-dns:latest
        args:
        - --source=ingress
        - --source=istio-gateway
        - --domain-filter=xxx
        - --policy=upsert-only
        - --provider=azure
        volumeMounts:
        - name: azure-config-file
          mountPath: /etc/kubernetes
          readOnly: true
      volumes:
      - name: azure-config-file
        secret:
          secretName: azuredns-config

正在解析 Istio 网关对象并正在创建 DNS 记录(这发生在前一段时间,我现在在日志中看不到任何内容)。由于某种原因,没有解析入口记录。我试过--source=service用: 添加和注释服务external-dns.alpha.kubernetes.io/hostname: my.host.name,也没有效果。

有任何想法吗?这看起来不错,但不知何故不起作用。入口工作,证书管理器创建证书,如果我手动创建 DNS 记录入口工作正常。

标签: azurekubernetesazure-aks

解决方案


我建议使用适当的云提供商角色运行https://github.com/kubernetes-incubator/external-dns,例如 AWS 中允许修改 Route53 记录的 IAM 角色。

对于 Azure:https ://github.com/kubernetes-incubator/external-dns/blob/master/docs/tutorials/azure.md

当你运行它时,确保你启用了入口源:https ://github.com/helm/charts/blob/master/stable/external-dns/values.yaml#L8-L12

它具有调试日志记录,因此您可以准确检查您的记录发生了什么。


推荐阅读