当前位置:网站首页>Kubernetes cluster configuration DNS Service
Kubernetes cluster configuration DNS Service
2022-07-28 08:58:00 【Brother Xing plays with the clouds】
On the basis of the previous article, this article will introduce kubernetes colony Configuration in environment dns service , stay k8s colony in ,pod The life cycle of life is short ,pod After restart ip The address will change , This is unacceptable for applications , To solve this problem ,K8S colony Cleverly introduced dns Service to realize service discovery , stay k8s In the cluster dns A total of 4 A component , The division of labor of each component is as follows : etcd:DNS Storage kube2sky: take Kubernetes Master Medium service( service ) Sign up to etcd. skyDNS: Provide DNS Domain name resolution service . healthz: Provide right skydns Health check of service .
One 、 Download relevant image files , And incorporated into the local warehouse for unified management
# docker pull docker.io/elcolio/etcd # docker pull docker.io/port/kubernetes-kube2sky # docker pull docker.io/skynetservices/skydns # docker pull docker.io/wu1boy/healthz
# docker tag docker.io/elcolio/etcd registry.fjhb.cn/etcd # docker tag docker.io/port/kubernetes-kube2sky registry.fjhb.cn/kubernetes-kube2sky # docker tag docker.io/skynetservices/skydns registry.fjhb.cn/skydns # docker tag docker.io/wu1boy/healthz registry.fjhb.cn/healthz
# docker push registry.fjhb.cn/etcd # docker push registry.fjhb.cn/kubernetes-kube2sky # docker push registry.fjhb.cn/skydns # docker push registry.fjhb.cn/healthz # docker images |grep fjhb
Two 、 adopt rc File creation pod One of them pod Contains 4 A component , A component runs in a docker In the container
# cat skydns-rc.yaml apiVersion: v1 kind: ReplicationController metadata: name: kube-dns namespace: default labels: k8s-app: kube-dns version: v12 kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: k8s-app: kube-dns version: v12 template: metadata: labels: k8s-app: kube-dns version: v12 kubernetes.io/cluster-service: "true" spec: containers: - name: etcd image: registry.fjhb.cn/etcd resources: limits: cpu: 100m memory: 50Mi requests: cpu: 100m memory: 50Mi command: - /bin/etcd - --data-dir - /tmp/data - --listen-client-urls - http://127.0.0.1:2379,http://127.0.0.1:4001 - --advertise-client-urls - http://127.0.0.1:2379,http://127.0.0.1:4001 - --initial-cluster-token - skydns-etcd volumeMounts: - name: etcd-storage mountPath: /tmp/data - name: kube2sky image: registry.fjhb.cn/kubernetes-kube2sky resources: limits: cpu: 100m memory: 50Mi requests: cpu: 100m memory: 50Mi args: - -kube_master_url=http://192.168.115.5:8080 - -domain=cluster.local - name: skydns image: registry.fjhb.cn/skydns resources: limits: cpu: 100m memory: 50Mi requests: cpu: 100m memory: 50Mi args: - -machines=http://127.0.0.1:4001 - -addr=0.0.0.0:53 - -ns-rotate=false - -domain=cluster.local ports: - containerPort: 53 name: dns protocol: UDP - containerPort: 53 name: dns-tcp protocol: TCP - name: healthz image: registry.fjhb.cn/healthz resources: limits: cpu: 10m memory: 20Mi requests: cpu: 10m memory: 20Mi args: - -cmd=nslookup kubernetes.default.svc.cluster.local 127.0.0.1 >/dev/null - -port=8080 ports: - containerPort: 8080 protocol: TCP volumes: - name: etcd-storage emptyDir: {} dnsPolicy: Default
3、 ... and 、 adopt srv File creation service
# cat skydns-svc.yaml apiVersion: v1 kind: Service metadata: name: kube-dns namespace: default labels: k8s-app: kube-dns kubernetes.io/cluster-service: "true" kubernetes.io/name: "KubeDNS" spec: selector: k8s-app: kube-dns clusterIP: 10.254.16.254 ports: - name: dns port: 53 protocol: UDP - name: dns-tcp port: 53 protocol: TCP# kubectl create -f skydns-rc.yaml # kubectl create -f skydns-svc.yaml # kubectl get rc # kubectl get pod # kubectl get svc
# kubectl describe svc kube-dns
# kubectl describe rc kube-dns
# kubectl describe pod kube-dns-9fllp Name: kube-dns-9fllp Namespace: default Node: 192.168.115.6/192.168.115.6 Start Time: Tue, 23 Jan 2018 10:55:19 -0500 Labels: k8s-app=kube-dns kubernetes.io/cluster-service=true version=v12 Status: Running IP: 172.16.37.5 Controllers: ReplicationController/kube-dns Containers: etcd: Container ID: docker://62ad76bfaca1797c5f43b0e9eebc04074169fce4cc15ef3ffc4cd19ffa9c8c19 Image: registry.fjhb.cn/etcd Image ID: docker-pullable://docker.io/elcolio/[email protected]:3b4dcd35a7eefea9ce2970c81dcdf0d0801a778d117735ee1d883222de8bbd9f Port: Command: /bin/etcd --data-dir /tmp/data --listen-client-urls http://127.0.0.1:2379,http://127.0.0.1:4001 --advertise-client-urls http://127.0.0.1:2379,http://127.0.0.1:4001 --initial-cluster-token skydns-etcd Limits: cpu: 100m memory: 50Mi Requests: cpu: 100m memory: 50Mi State: Running Started: Tue, 23 Jan 2018 10:55:23 -0500 Ready: True Restart Count: 0 Volume Mounts: /tmp/data from etcd-storage (rw) /var/run/secrets/kubernetes.io/serviceaccount from default-token-6pddn (ro) Environment Variables: <none> kube2sky: Container ID: docker://6b0bc6e8dce83e3eee5c7e654fbaca693730623fb7936a1fd9d73de1a1dd8152 Image: registry.fjhb.cn/kubernetes-kube2sky Image ID: docker-pullable://docker.io/port/[email protected]:0230d3fbb0aeb4ddcf903811441cf2911769dbe317a55187f58ca84c95107ff5 Port: Args: -kube_master_url=http://192.168.115.5:8080 -domain=cluster.local Limits: cpu: 100m memory: 50Mi Requests: cpu: 100m memory: 50Mi State: Running Started: Tue, 23 Jan 2018 10:55:25 -0500 Ready: True Restart Count: 0 Volume Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-6pddn (ro) Environment Variables: <none> skydns: Container ID: docker://ebc2aaaa54e2f922e370e454ec537665d813c69d37a21e3afd908e6dad056627 Image: registry.fjhb.cn/skydns Image ID: docker-pullable://docker.io/skynetservices/[email protected]:6f8a9cff0b946574bb59804016d3aacebc637581bace452db6a7515fa2df79ee Ports: 53/UDP, 53/TCP Args: -machines=http://127.0.0.1:4001 -addr=0.0.0.0:53 -ns-rotate=false -domain=cluster.local Limits: cpu: 100m memory: 50Mi Requests: cpu: 100m memory: 50Mi State: Running Started: Tue, 23 Jan 2018 10:55:27 -0500 Ready: True Restart Count: 0 Volume Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-6pddn (ro) Environment Variables: <none> healthz: Container ID: docker://f1de1189fa6b51281d414d7a739b86494b04c8271dc6bb5f20c51fac15ec9601 Image: registry.fjhb.cn/healthz Image ID: docker-pullable://docker.io/wu1boy/[email protected]:d6690c0a8cc4f810a5e691b6a9b8b035192cb967cb10e91c74824bb4c8eea796 Port: 8080/TCP Args: -cmd=nslookup kubernetes.default.svc.cluster.local 127.0.0.1 >/dev/null -port=8080 Limits: cpu: 10m memory: 20Mi Requests: cpu: 10m memory: 20Mi State: Running Started: Tue, 23 Jan 2018 10:55:29 -0500 Ready: True Restart Count: 0 Volume Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-6pddn (ro) Environment Variables: <none> Conditions: Type Status Initialized True Ready True PodScheduled True Volumes: etcd-storage: Type: EmptyDir (a temporary directory that shares a pod's lifetime) Medium: default-token-6pddn: Type: Secret (a volume populated by a Secret) SecretName: default-token-6pddn QoS Class: Guaranteed Tolerations: <none> Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 7m 7m 1 {default-scheduler } Normal Scheduled Successfully assigned kube-dns-9fllp to 192.168.115.6 7m 7m 1 {kubelet 192.168.115.6} spec.containers{etcd} Normal Pulling pulling image "registry.fjhb.cn/etcd" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{etcd} Normal Pulled Successfully pulled image "registry.fjhb.cn/etcd" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{etcd} Normal Created Created container with docker id 62ad76bfaca1; Security:[seccomp=unconfined] 7m 7m 1 {kubelet 192.168.115.6} spec.containers{kube2sky} Normal Pulled Successfully pulled image "registry.fjhb.cn/kubernetes-kube2sky" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{etcd} Normal Started Started container with docker id 62ad76bfaca1 7m 7m 1 {kubelet 192.168.115.6} spec.containers{kube2sky} Normal Pulling pulling image "registry.fjhb.cn/kubernetes-kube2sky" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{kube2sky} Normal Created Created container with docker id 6b0bc6e8dce8; Security:[seccomp=unconfined] 7m 7m 1 {kubelet 192.168.115.6} spec.containers{skydns} Normal Pulled Successfully pulled image "registry.fjhb.cn/skydns" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{skydns} Normal Pulling pulling image "registry.fjhb.cn/skydns" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{kube2sky} Normal Started Started container with docker id 6b0bc6e8dce8 7m 7m 1 {kubelet 192.168.115.6} spec.containers{skydns} Normal Created Created container with docker id ebc2aaaa54e2; Security:[seccomp=unconfined] 7m 7m 1 {kubelet 192.168.115.6} spec.containers{skydns} Normal Started Started container with docker id ebc2aaaa54e2 7m 7m 1 {kubelet 192.168.115.6} spec.containers{healthz} Normal Pulling pulling image "registry.fjhb.cn/healthz" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{healthz} Normal Pulled Successfully pulled image "registry.fjhb.cn/healthz" 7m 7m 1 {kubelet 192.168.115.6} spec.containers{healthz} Normal Created Created container with docker id f1de1189fa6b; Security:[seccomp=unconfined] 7m 7m 1 {kubelet 192.168.115.6} spec.containers{healthz} Normal Started Started container with docker id f1de1189fa6b
Four 、 modify kubelet Configure the file and restart the service
Be careful :
--cluster-dns Parameters should be the same as before svc In the document clusterIP Parameters are consistent
--cluster-domain Parameters should be the same as before rc In the document -domain Parameters are consistent
All of the kubelet Nodes need to be modified
# grep 'KUBELET_ADDRESS' /etc/kubernetes/kubelet KUBELET_ADDRESS="--address=192.168.115.5 --cluster-dns=10.254.16.254 --cluster-domain=cluster.local" # systemctl restart kubelet
5、 ... and 、 Run one busybox and curl To test
# cat busybox.yaml apiVersion: v1 kind: Pod metadata: name: busybox spec: containers: - name: busybox image: docker.io/busybox command: - sleep - "3600"# cat curl.yaml apiVersion: v1 kind: Pod metadata: name: curl spec: containers: - name: curl image: docker.io/webwurst/curl-utils command: - sleep - "3600"# kubectl create -f busybox.yaml # kubectl create -f curl.yaml
adopt busybox Container pair kubernetes Of service To analyze , Find out service It is automatically parsed into the corresponding cluster ip Address , It's not 172.16 The network segment docker Address
# kubectl get svc # kubectl exec busybox -- nslookup frontend # kubectl exec busybox -- nslookup Redis-master # kubectl exec busybox -- nslookup redis-slave
adopt curl The container accesses the previously created php Message board
# kubectl exec curl -- curl frontend
边栏推荐
- Wechat applet - wechat applet browsing PDF files
- Mongodb (compare relational database, cloud database, common command line, tutorial)
- When I use MySQL CDC, there are 100 million pieces of data in the source table. In the full volume phase, when I synchronize 10 million, I stop, and then pass
- Round C financing has been completed! Smart software leads domestic Bi ecological empowerment, and products and services are a step forward
- 第2章-2 计算分段函数[1]
- When will brain like intelligence, which is popular in academia, land? Let's listen to what the industry masters say - qubits, colliders, x-knowledge Technology
- Bash shell interaction free
- Basic syntax of jquey
- 创建线程的3种方式
- Quickly build a gateway service, dynamic routing and authentication process, and watch the second meeting (including the flow chart)
猜你喜欢

Shell programming specifications and variables

You're not still using xshell, are you? This open source terminal tool is yyds!

Customer first | domestic Bi leader, smart software completes round C financing

Div tags and span Tags
![[soft test software evaluator] 2013 comprehensive knowledge over the years](/img/c5/183acabd7015a5e515b7d83c127b2c.jpg)
[soft test software evaluator] 2013 comprehensive knowledge over the years

Ciou loss

Explain cache consistency and memory barrier

Digital signatures and Ca certificates
![[activity registration] User Group Xi'an - empowering enterprise growth with modern data architecture](/img/92/88be42faf0451cb19067672dab69c8.jpg)
[activity registration] User Group Xi'an - empowering enterprise growth with modern data architecture

Mongodb (compare relational database, cloud database, common command line, tutorial)
随机推荐
Detailed explanation of switch link aggregation [Huawei ENSP]
Flink window & time principle
Mobaxtermsession synchronization
Digital signatures and Ca certificates
Analysis of model predictive control (MPC) (IX): numerical solution of quadratic programming (II)
象棋机器人夹伤7岁男孩手指,软件测试工程师的锅?我笑了。。。
Round C financing has been completed! Smart software leads domestic Bi ecological empowerment, and products and services are a step forward
Deployment of kubernetes
PostgreSQL: cannot change the type of column used by a view or rule
Source code analysis of linkedblockingqueue
I use SqlClient normally, and dlink submission will report this error. What should I do?
NDK series (6): let's talk about the way and time to register JNI functions
Redis 基本知识,快来回顾一下
Chapter 2-2 calculation of piecewise function [1]
Div tags and span Tags
Detailed explanation of DHCP distribution address of routing / layer 3 switch [Huawei ENSP]
说透缓存一致性与内存屏障
阿里巴巴内部面试资料
客户至上 | 国产BI领跑者,思迈特软件完成C轮融资
Blog building 7: Hugo