首页 > 代码库 > k8s dns 服务安装配置说明
k8s dns 服务安装配置说明
1. 提前条件
安装k8s 集群
2. dns 安装配置
安装方式: 使用controller service
controller 脚本:
基于官方改动
apiVersion: v1 kind: ReplicationController metadata: name: kube-dns-v8 namespace: kube-system labels: k8s-app: kube-dns version: v8 kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: k8s-app: kube-dns version: v8 template: metadata: labels: k8s-app: kube-dns version: v8 kubernetes.io/cluster-service: "true" spec: containers: - name: etcd image: tlitiwwhtmi/etcd resources: limits: cpu: 100m memory: 50Mi command: - /usr/local/bin/etcd - -data-dir - /var/etcd/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: /var/etcd/data - name: kube2sky image: outrider/kube2sky resources: limits: cpu: 100m memory: 50Mi args: # command = "/kube2sky" - --domain=cluster.local - --kube_master_url=http://10.25.143.50:8080 - name: skydns image: outrider/skydns resources: limits: cpu: 100m memory: 50Mi args: # command = "/skydns" - -machines=http://localhost:4001 - -addr=0.0.0.0:53 - -domain=cluster.local ports: - containerPort: 53 name: dns protocol: UDP - containerPort: 53 name: dns-tcp protocol: TCP livenessProbe: httpGet: path: /healthz port: 8080 scheme: HTTP initialDelaySeconds: 30 timeoutSeconds: 5 - name: healthz image: outrider/exechealthz resources: limits: cpu: 10m memory: 20Mi args: - -cmd=nslookup kubernetes.default.svc.cluster.local localhost >/dev/null - -port=8080 ports: - containerPort: 8080 protocol: TCP volumes: - name: etcd-storage emptyDir: {} dnsPolicy: Default # Don‘t use cluster DNS.
service
apiVersion: v1 kind: Service metadata: name: kube-dns namespace: kube-system labels: k8s-app: kube-dns kubernetes.io/cluster-service: "true" kubernetes.io/name: "KubeDNS" spec: selector: k8s-app: kube-dns clusterIP: 10.254.0.3 ports: - name: dns port: 53 protocol: UDP - name: dns-tcp port: 53 protocol: TCP
创建namespace
apiVersion: v1 kind: Namespace metadata: name: kube-system
3. node 进行 dns 配置
在启动脚本添加:
--cluster-dns=10.254.0.3 --cluster-domain=cluster.local
4. 重启node
5. 测试pod
apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - image: busybox command: - sleep - "3600" imagePullPolicy: IfNotPresent name: busybox restartPolicy: Always
6. 测试
kubectl exec busybox -- nslookup ngservice
测试结果
Server: 10.254.0.3 Address 1: 10.254.0.3 Name: ngservice Address 1: 10.254.52.109
k8s dns 服务安装配置说明
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。