External-DNS 기반 다중 클러스터 Ingress DNS 실천
6322 단어 dns무리를 이루다용기.kubernetes
개요
External-DNS는 프로그래밍 방식으로 Kubernetes Ingress 자원을 관리하는 DNS 기능을 제공하여 사용자가 Ingress에서 DNS 해석 기록을 관리할 수 있도록 한다.또한kubernetes federation v2 환경에서External-DNS를 사용하면 여러 연방 집단의 Ingress DNS 해석을 신속하게 관리하고 사용자의 조작 원가를 낮출 수 있다.다음은 알리 클라우드 컨테이너 서비스 환경에서 연방 클러스터의 Ingress DNS 해석을 관리하기 위해 External-DNS를 사용하는 방법을 간략하게 소개한다.
연방 집단 준비
아리운 Kubernetes 용기 서비스에서Federation v2를 참고하여 두 개의 집단으로 구성된 연방 집단(kubeconfig를 설정하고 두 개의 집단을 완성하는join)을 구축한다.
RAM 정보 구성
Kubernetes 클러스터 노드 목록에 있는 Worker 노드를 선택하여 해당 노드 목록 정보 페이지를 엽니다.
해당 RAM 역할을 찾아 RAM 콘솔을 열고 해당 역할 이름을 찾아 [AliyunDNSFullAccess] 권한을 추가합니다.
참고 각 클러스터에는 RAM 정보를 구성해야 합니다.
External-DNS 배포
RBAC 구성
다음을 수행합니다.
apiVersion: v1
kind: ServiceAccount
metadata:
name: external-dns
---
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: ["multiclusterdns.federation.k8s.io"]
resources: ["dnsendpoints"]
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: default
External-DNS 서비스 배포
다음을 수행합니다.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: external-dns
spec:
strategy:
type: Recreate
template:
metadata:
labels:
app: external-dns
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: registry.cn-beijing.aliyuncs.com/acs/external-dns:v0.5.8-27
args:
- --source=crd
- --crd-source-apiversion=multiclusterdns.federation.k8s.io/v1alpha1
- --crd-source-kind=DNSEndpoint
- --provider=alibabacloud
- --policy=sync # enable full synchronization
- --registry=txt
- --txt-prefix=cname
- --txt-owner-id=my-identifier
- --alibaba-cloud-config-file= # enable sts token
volumeMounts:
- mountPath: /usr/share/zoneinfo
name: hostpath
volumes:
- name: hostpath
hostPath:
path: /usr/share/zoneinfo
type: Directory
검증 리소스 배포
FederatedDeployment 및 Federated Service를 만들려면 다음과 같이 하십시오.
apiVersion: v1
kind: Namespace
metadata:
name: test-namespace
---
apiVersion: types.federation.k8s.io/v1alpha1
kind: FederatedNamespace
metadata:
name: test-namespace
namespace: test-namespace
spec:
placement:
clusterNames:
- cluster1
- cluster2
---
apiVersion: types.federation.k8s.io/v1alpha1
kind: FederatedDeployment
metadata:
name: test-deployment
namespace: test-namespace
spec:
template:
metadata:
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
resources:
limits:
cpu: 500m
requests:
cpu: 200m
placement:
clusterNames:
- cluster1
- cluster2
---
apiVersion: types.federation.k8s.io/v1alpha1
kind: FederatedService
metadata:
name: test-service
namespace: test-namespace
spec:
template:
spec:
selector:
app: nginx
type: ClusterIP
ports:
- name: http
port: 80
placement:
clusterNames:
- cluster2
- cluster1
개별 클러스터ingress 생성 정보는 다음과 같습니다.
kubectl get ingress -n test-namespace --context cluster1
NAME HOSTS ADDRESS PORTS AGE
test-ingress * 47.93.69.121 80 54m
kubectl get ingress -n test-namespace --context cluster2
NAME HOSTS ADDRESS PORTS AGE
test-ingress * 39.106.232.23 80 54m
FederatedIngress 및 IngressDNSRecord 작성
apiVersion: types.federation.k8s.io/v1alpha1
kind: FederatedIngress
metadata:
name: test-ingress
namespace: test-namespace
spec:
template:
spec:
backend:
serviceName: test-service
servicePort: 80
placement:
clusterNames:
- cluster2
- cluster1
---
apiVersion: multiclusterdns.federation.k8s.io/v1alpha1
kind: IngressDNSRecord
metadata:
name: test-ingress
namespace: test-namespace
spec:
hosts:
- ingress-example.example-domain.club
recordTTL: 600
그 중에서 [ingress-example.example-domain.club]은 아리운이 위탁 관리하는 도메인을 테스트하기 위해 아리운에서 미리 도메인을 구매하고 교체에 주의하십시오.
DNS 확인 확인
dig +short @dns7.hichina.com ingress-example.example-domain.club
47.93.69.121
39.106.232.23
귀속된 도메인 이름이 cluster1과 cluster2의ingress IP로 해석된 것을 볼 수 있습니다.도메인 이름에 해당하는 서비스에 액세스하려면 다음과 같이 하십시오.
curl ingress-example.sigma-host.club
Welcome to nginx!
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
총결산
위에서 소개한 바와 같이 External-DNS를 사용하면federation-v2 환경에서의 Ingress DNS 해석을 매우 편리하게 관리할 수 있다.
본문 저자: 균박
원문을 읽다
본고는 운서 지역사회의 오리지널 내용으로 허락 없이 전재할 수 없다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
DNS 서버 정방향/역방향 목록 정리AD의 머신 계정은 삭제해도 DNS 서버와 연동하지 않았는지, 쓰레기 정보가 모여 버렸다. DNS 매니저로부터 쓰레기는 확인할 수 있지만, 너무 많아, GUI 조작에서는 전부 삭제는 곤란. 리스트 출력 ⇒ 명령으로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.