{"version": "2.0","statement": [{"effect": "allow","action": ["dnspod:ModifyRecord","dnspod:DeleteRecord","dnspod:CreateRecord","dnspod:DescribeRecordList","dnspod:DescribeDomainList"],"resource": ["*"]},{"effect": "allow","action": ["privatedns:DescribePrivateZoneList","privatedns:DescribePrivateZoneRecordList","privatedns:CreatePrivateZoneRecord","privatedns:DeletePrivateZoneRecord","privatedns:ModifyPrivateZoneRecord"],"resource": ["*"]}]}
--tencent-cloud-zone-type=private--tencent-cloud-zone-type=publicapiVersion: v1kind: ServiceAccountmetadata:name: external-dns---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata:name: external-dnsrules:- apiGroups: [""]resources: ["services","endpoints","pods"]verbs: ["get","watch","list"]- apiGroups: ["extensions","networking.k8s.io"]resources: ["ingresses"]verbs: ["get","watch","list"]- apiGroups: [""]resources: ["nodes"]verbs: ["list"]---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: external-dns-viewerroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: external-dnssubjects:- kind: ServiceAccountname: external-dnsnamespace: default---apiVersion: v1kind: ConfigMapmetadata:name: external-dnsdata:tencent-cloud.json: |{"regionId": "ap-shanghai", # (Required) ID of the region where the cluster locates"secretId": "******","secretKey": "******","vpcId": "vpc-******" (Required), ID of the VPC where the cluster is deployed}---apiVersion: apps/v1kind: Deploymentmetadata:name: external-dnsspec:strategy:type: Recreateselector:matchLabels:app: external-dnstemplate:metadata:labels:app: external-dnsspec:containers:- args:- --source=service- --source=ingress- --domain-filter=external-dns-test.com # Make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones- --provider=tencentcloud- --policy=sync # Set it to `upssert-only` to prevent ExternalDNS from deleting any records- --tencent-cloud-zone-type=private # Only look at private hosted zones. To use public DNS service, set it to `public`.- --tencent-cloud-config-file=/etc/kubernetes/tencent-cloud.jsonimage: ccr.ccs.tencentyun.com/tke-market/external-dns:v1.0.0imagePullPolicy: Alwaysname: external-dnsresources: {}terminationMessagePath: /dev/termination-logterminationMessagePolicy: FilevolumeMounts:- mountPath: /etc/kubernetesname: config-volumereadOnly: truednsPolicy: ClusterFirstrestartPolicy: AlwaysschedulerName: default-schedulersecurityContext: {}serviceAccount: external-dnsserviceAccountName: external-dnsterminationGracePeriodSeconds: 30volumes:- configMap:defaultMode: 420items:- key: tencent-cloud.jsonpath: tencent-cloud.jsonname: external-dnsname: config-volume
apiVersion: v1kind: Servicemetadata:name: nginxannotations:external-dns.alpha.kubernetes.io/hostname: nginx.external-dns-test.com # Public domain name addressexternal-dns.alpha.kubernetes.io/internal-hostname: nginx-internal.external-dns-test.com # Private domain name addressexternal-dns.alpha.kubernetes.io/ttl: "600"spec:type: LoadBalancerports:- port: 80name: httptargetPort: 80selector:app: nginx---apiVersion: apps/v1kind: Deploymentmetadata:name: nginxspec:selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- image: nginxname: nginxports:- containerPort: 80name: http
nginx.external-dns-test.com will record the service's loadbalancer VIP.nginx-internal.external-dns-test.com will record the service's ClusterIP. The TTL of all DNS records is 600.192.168.254.214 and Loadbalancer VIP 129.211.179.31. As shown below:


フィードバック