当前位置:网站首页>Self built DNS to realize the automatic intranet resolution of tke cluster apiserver domain name
Self built DNS to realize the automatic intranet resolution of tke cluster apiserver domain name
2022-06-24 03:19:00 【Nieweixing】
Tencent cloud tke Cluster access apiserver Addresses are accessed by domain names , Support intranet and public network access apiserver, For public network access, a public network type will be created clb, Then automatically resolve the domain name to clb Of vip On . If it is an intranet access, an intranet will be created clb Type of service,default Under the namespace kube-user, However, the intranet does not automatically resolve domain names , Therefore, it is usually necessary to configure on the client side hosts The cluster can only be accessed through resolution . When there are many client machines , Each configuration is required host Parsing is troublesome , Is it possible to achieve tke colony apiserver The domain name is automatically resolved on the intranet ?
Tencent cloud has launched a Private DNS The service of is used for automatic resolution of intranet , We can do it in Private DNS Add the cluster domain name and the corresponding intranet clb Of A Record , That is to say vpc The intranet resolves itself , Refer to the documentation for specific configuration https://cloud.tencent.com/document/product/457/55348
Of course, you can also build your own dns To achieve tke colony apiserver The domain name is automatically resolved on the intranet , Today, let's talk about how to tke Cluster self built dns Come to the intranet for automatic resolution , The concrete implementation is to deploy a dnsmasq Into the cluster ,dnsmasq Mirror project address https://github.com/jpillora/docker-dnsmasq, Then provide an intranet clb Of service As dns Entrance , Finally at the node or vpc Configure lower Intranet clb Of vip As nameserver, That is to say vpc Automatic resolution of the intranet .
1. establish namesapce Deploy dnsmasq
# kubectl create ns dnsmasq
2. To configure dnsmasq The configuration file
dnsmasq The configuration file of configmap Mount it in the same way , Concrete configmap The configuration is as follows , For the description of the configuration file, please refer to http://oss.segetech.com/intra/srv/dnsmasq.conf
apiVersion: v1
data:
dnsmasq.conf: |-
#dns Parsing log
log-queries
# The domain name and IP mapping
address=/cls-b3mg1p92.ccs.tencent-cloud.com/10.0.0.60
address=/cls-jmdg96ew.ccs.tencent-cloud.com/10.0.0.71
kind: ConfigMap
metadata:
name: dnsmasq-conf
namespace: dnsmasq3. establish dnsmasq The workload
Next, deploy a dnsmasq Of deployment, It's configured here HTTP_USER and HTTP_PASS The environment variable is used for authentication login of front-end configuration
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: dnsmasq
qcloud-app: dnsmasq
name: dnsmasq
namespace: dnsmasq
spec:
replicas: 1
selector:
matchLabels:
k8s-app: dnsmasq
qcloud-app: dnsmasq
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
k8s-app: dnsmasq
qcloud-app: dnsmasq
spec:
containers:
- env:
- name: HTTP_USER
value: admin
- name: HTTP_PASS
value: "123456"
image: jpillora/dnsmasq
imagePullPolicy: Always
name: dnsmasq
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 256Mi
securityContext:
privileged: false
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/dnsmasq.conf
name: vol
subPath: dnsmasq.conf
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: dnsmasq-conf
name: vol4. Create... That provides access service
Because Tencent cloud clb type serivce Rules for deploying different protocols are not supported ,dnsmasq Of 53 The port needs to use udp, The port of the front-end management page 8080 yes tcp, So here we create 2 individual service To expose the service . Service udp agreement 53 Port we use the intranet clb type , Front end configuration page 8080 For port clusterip type service, Then configure a ingress Just visit .
dnsmasq Service for service, The intranet here clb vip yes 10.0.21.13, Later, we will this ip Configuration to nameserve that will do
apiVersion: v1
kind: Service
metadata:
annotations:
service.kubernetes.io/qcloud-loadbalancer-internal-subnetid: subnet-xxxxx
name: dnsmasq
namespace: dnsmasq
spec:
externalTrafficPolicy: Cluster
ports:
- name: 53-53-udp
nodePort: 31198
port: 53
protocol: UDP
targetPort: 53
selector:
k8s-app: dnsmasq
qcloud-app: dnsmasq
sessionAffinity: None
type: LoadBalancerThe front-end configuration webui Of service as follows
apiVersion: v1
kind: Service
metadata:
name: dashboaed
namespace: dnsmasq
spec:
ports:
- name: 8080-8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
k8s-app: dnsmasq
qcloud-app: dnsmasq
sessionAffinity: None
type: ClusterIP5. by dnsmasq Front page configuration ingress
Let's go through a ingress Let's use the domain name model dnsmasq Of webui
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: ingress
name: dnsmasq-ingress
namespace: dnsmasq
spec:
rules:
- host: dnsmasq.tke.niewx.cn
http:
paths:
- backend:
serviceName: dashboaed
servicePort: 8080
path: /Browser access domain name access webui, The login account password is the environment variable of the previous workload configuration
After logging in , We can see dnsmasq Configuration and logging of , If modification is needed dnsmasq Configuration of , You can also modify it directly in the front end , Then save and restart the service .
6. Node or vpc To configure nameserver
To use our custom dns To automatically resolve domain names , It also needs to be in the node /etc/resolv.conf Under configuration nameserver, If you want the whole vpc All nodes are configured , Can be in vpc To configure , stay dns Configuration item plus 10.0.21.13, This is effective for the stock node , The node needs to be restarted , The new node will add this by default .
If some stock nodes cannot be restarted , We need to manually set the node /etc/resolv.conf To configure 10.0.21.13 This nameserver.
7. Test resolution access domain name
Finally, let's test the domain name resolution
[[email protected] kubernetes]# nslookup cls-b3mg1p92.ccs.tencent-cloud.com 10.0.21.13 Server: 10.0.21.13 Address: 10.0.21.13#53 Name: cls-b3mg1p92.ccs.tencent-cloud.com Address: 10.0.0.60
At the same time, we turn off the cluster public network access , And then use kubectl Visit the cluster to see if it succeeds
Normal access indicates that the automatic resolution configuration is successful .
边栏推荐
- Simple and beautiful weather code
- Process kill problem
- Coding CD of Devops
- RI Geng series: tricks of using function pointers
- Why use code signing? What certificates are required for code signing?
- [new double 11] the latest interpretation of Tencent cloud double 11! Get 11000 yuan voucher now!!
- An example of SPM manual binding execution plan
- System library golang Org/x/time/rate frequency limiter bug
- What port does the fortress machine use? What is the role of the fortress machine?
- US Treasury secretary says extortion software poses a threat to the economy, Google warns 2billion chrome users | global network security hotspot
猜你喜欢

2022-2028 global marine wet exhaust hose industry research and trend analysis report

2022-2028 global cell-based seafood industry research and trend analysis report

Simple and beautiful weather code
![[51nod] 3395 n-bit gray code](/img/b5/2c072a11601de82cb92ade94672ecd.jpg)
[51nod] 3395 n-bit gray code
![[51nod] 2102 or minus and](/img/68/0d966b0322ac1517dd2800234d386d.jpg)
[51nod] 2102 or minus and

2022-2028 global portable two-way radio equipment industry research and trend analysis report

Get to know MySQL database

2022-2028 global aircraft wireless intercom system industry research and trend analysis report
![[51nod] 2653 section XOR](/img/2d/cb4bf4e14939ce432cac6d35b6a41b.jpg)
[51nod] 2653 section XOR

2022-2028 global aircraft audio control panel system industry research and trend analysis report
随机推荐
LeetCode 1047. Delete all adjacent duplicates in the string
What does elastic public IP mean? The advantages of elastic public IP
EIP maximum EIP EIP remote desktop access
Highlights of future cloud native CIF Forum
Chapter 5: key led demo case of PS bare metal and FreeRTOS case development
Which brand is a good backup all-in-one machine price
What is the edge calculator force? What about the edge calculator?
Where is the cloud game server? Can individuals rent cloud game servers?
What is fortress resource authorization? What is barrier machine?
Grpc: implement service end flow restriction
What is cloud desktop and how to connect to the server? What does the mainstream architecture of cloud desktop include?
What is the price of the elastic public network IP bandwidth
Grand summary of boutique idea plug-ins! Worth collecting
What is the GPU usage for cloud desktops and servers? What can cloud desktop do?
Is it necessary to buy EIP? Price analysis of EIP
How much is a fortress machine? Why do you need a fortress machine?
Grpc: how to implement distributed log tracing?
[51nod] 3216 Awards
Why does the fortress machine use an application publisher? What are the main functions of the fortress machine
"Sharp weapon" for enterprise resumption? When the sale comes, the contract should be signed like this!