问题描述
我按照 this 部署了 K8s ExternalDNS 并执行了以下操作:
- 创建了 Azure 应用服务域和 DNS 区域(即
demo.com
) - 为 AKS 群集启用托管标识
- 为 DNS 区域的 AKS 托管标识分配了参与者角色
- 为 ExternalDNS 创建了 K8s 密钥(使用
azure.json
) - 在默认的 K8s (AKS) 命名空间中部署了 ExternalDNS
- 使用
host: api.demo.com
和路径/foo
&/bar
创建了 2 个入口(仅供参考,AKS AGIC 已启用,应用程序网关正在使用“静态公共 IP”)
如果我理解正确,ExternalDNS 应该在 Azure DNS 区域中创建记录集,并且入口应该可以工作。但是 ExternalDNS 没有创建记录集(入口不起作用)。
仅供参考,如果我执行以下操作,则一切正常
- 使用
"Alias type: Azure resource"
创建别名记录集,指向应用程序网关使用的“静态公共 IP” - 分别用
[Route("api/foo")]
和[Route("api/bar")]
注释的控制器 - 使用
host: demo.com
和路径api/foo/*
&api/bar/*
创建 2 个入口 - 对每个入口使用注释:
appgw.ingress.kubernetes.io/backend-path-prefix: "/foo/"
(Bar API 相同:"/bar/"
)
但是,我想要的是使用 api.demo.com
(以及 SSL 和 Let's Encrypt)托管我的 API
foo-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
Metadata:
name: foo-api
namespace: default
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/ssl-redirect: "false"
appgw.ingress.kubernetes.io/backend-path-prefix: "/foo/"
spec:
rules:
- host: api.demo.com
http:
paths:
- path: /foo/*
pathType: Prefix
backend:
service:
name: foo-api
port:
number: 80
external-dns.yaml
apiVersion: v1
kind: ServiceAccount
Metadata:
name: external-dns
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Metadata:
name: external-dns
rules:
- apiGroups: [""]
resources: ["services","endpoints","pods"]
verbs: ["get","watch","list"]
- apiGroups: ["extensions","networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get","list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list"]
---
apiVersion: rbac.authorization.k8s.io/v1
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: default
---
apiVersion: apps/v1
kind: Deployment
Metadata:
name: external-dns
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: external-dns
template:
Metadata:
labels:
app: external-dns
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: k8s.gcr.io/external-dns/external-dns:v0.8.0
args:
- --source=service
- --source=ingress
- --domain-filter=demo.com
- --provider=azure
- --azure-resource-group=my-poc-rg
volumeMounts:
- name: azure-config-file
mountPath: /etc/kubernetes
readOnly: true
volumes:
- name: azure-config-file
secret:
secretName: azure-config-file
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)