gongdear

gongdear的技术博客

欢迎大家参观我的博客
  menu
104 文章
89355 浏览
0 当前访客
ღゝ◡╹)ノ❤️

Kubernetes安装kube-dns服务发现

在各个node节点上
vim /etc/kubernetes/kubelet

添加如下配置 其他配置为自动生成的建议不要修改

KUBELET_ARGS="--cluster-dns=10.254.10.2 --cluster-domain=sky --allow-privileged=true"

master上
etcdctl mk /skydns/config '{"dns-addr":"10.254.10.2:53","ttl":3600,"domain":"sky."}'

编辑skydns_dpm.yaml 文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-dns
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
name: kube-dns
tier: platform
subsystem: unconfirmed
k8s-app: kube-dns
version: v9
partition: "no"
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: kube2sky
#填写你自己的镜像名称
image: gcr.io/google_containers/kube2sky:1.11
resources:
limits:
cpu: 100m
memory: 50Mi
args:
# 同etcd中配置的/skydns/config中的domain名
- -domain=sky
# master地址
- --kube_master_url=http://192.168.1.120:8080
# etcd地址
- -etcd-server=http://192.168.1.120:2379
- name: skydns
#你的镜像名称
image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c
resources:
limits:
cpu: 100m
memory: 50Mi
args:
# command = "/skydns"
# etcd地址
- -machines=http://192.168.1.120:2379
- -addr=0.0.0.0:53
- -ns-rotate=false
#同etcd中配置的/skydns/config中的domain名,最后有‘点’
- -domain=sky.
ports:
- containerPort: 53
name: dns
protocol: UDP
- containerPort: 53
name: dns-tcp
protocol: TCP
dnsPolicy: Default # Don't use cluster DNS.

编辑skydns-svc.yaml

文件
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.10.2
ports:

  • name: dns
    port: 53
    protocol: UDP
  • name: dns-tcp
    port: 53
    protocol: TCP
宝剑锋从磨砺出,梅花香自苦寒来.