首页 > 代码库 > kubernetes 1.3 使用skydns + kube2dns +etcd部署DNS服务器

kubernetes 1.3 使用skydns + kube2dns +etcd部署DNS服务器

1. 直接从Docker中拉取skydns,kube2dns,etcd容器,放到一个Pod中

  • kube2sky:1.14
  • etcd:2.0.9
  • skydns-amd64

2. 创建RC

apiVersion: v1
kind: ReplicationController
metadata:
  name: kube-dns-v6
  namespace: default
  labels:
    k8s-app: kube-dns
    version: v6
    kubernetes.io/cluster-service: "true"
spec:
  replicas: 1
  selector:
    k8s-app: kube-dns
    version: v6
  template:
    metadata:
      labels:
        k8s-app: kube-dns
        version: v6
        kubernetes.io/cluster-service: "true"
    spec:
      containers:
      - name: etcd
        image: 109.105.46.94:5000/dns/etcd:2.0.9
        command:
        - /usr/local/bin/etcd
        - -listen-client-urls
        - http://0.0.0.0:2379,http://0.0.0.0:4001
        - -advertise-client-urls
        - http://127.0.0.1:2379,http://127.0.0.1:4001
        - -initial-cluster-token
        - skydns-etcd
      - name: kube2sky
        #image: 109.105.46.94:5000/dns/kube2sky:1.11
        image: 109.105.46.94:5000/dns/kube2sky:1.14
        resources:
          limits:
            cpu: 100m
            memory: 50Mi
        command:
        - /kube2sky
       # - -kube_master_url=http://109.105.46.94:8080
       # - -domain=cluster.local
        - --kube-master-url=http://109.105.46.94:8080
        - --domain=cluster.local
      - name: skydns
        image:  109.105.46.94:5000/dns/skydns-amd64
        resources:
        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
      dnsPolicy: Default

3.创建SVC

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: 192.168.3.100
  ports:
  - name: dns
    port: 53
    protocol: UDP
  - name: dns-tcp
    port: 53
    protocol: TCP

4. 启动dns:

kubectl create -f skydns-etcd-rc.yaml
kubectl create -f skydns-etcd-svc.yaml

5.修改各node节点上的/etc/kubernetes/kubelet.service配置文件,增加启动参数:

--cluster-dns=192.168.3.100 \
--cluster-domain=cluster.local \

6.重启各节点:

systemctl daemon-reload
systemctl restart kubelet

kubernetes 1.3 使用skydns + kube2dns +etcd部署DNS服务器