2016-03-25 23 views
5

Tôi đang cố thiết lập hỗ trợ DNS trong Kubernetes 1.2 trên Centos 7. Theo số documentation, có hai cách để thực hiện việc này. Là người đầu tiên áp dụng cho một "kubernetes hỗ trợ cài đặt cluster" và liên quan đến thiết lập các biến môi trường:Lỗi Kubernetes DNS trong Kubernetes 1.2

ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}" 
DNS_SERVER_IP="10.0.0.10" 
DNS_DOMAIN="cluster.local" 
DNS_REPLICAS=1 

tôi đã thêm các cài đặt này/etc/kubernetes/config và khởi động lại, không có hiệu lực, do đó, hoặc tôi không có một hỗ trợ thiết lập cụm kubernetes (đó là cái gì?), hoặc có cái gì khác cần thiết để thiết lập môi trường của nó.

Cách tiếp cận thứ hai yêu cầu thiết lập thủ công hơn. Nó cho biết thêm hai lá cờ để kubelets, mà tôi thiết lập bằng cách cập nhật/etc/kubernetes/kubelet bao gồm:

KUBELET_ARGS="--cluster-dns=10.0.0.10 --cluster-domain=cluster.local" 

và khởi động lại kubelet với systemctl restart kubelet. Sau đó, nó là cần thiết để bắt đầu một bộ điều khiển nhân rộng và một dịch vụ. Trang doc được trích dẫn ở trên cung cấp một vài tệp mẫu cho điều này yêu cầu một số chỉnh sửa, cả cho các thay đổi cục bộ (máy chủ Kubernetes API của tôi lắng nghe địa chỉ IP thực của tên máy chủ thay vì 127.0.0.1, làm cho nó cần thiết để thêm một - cài đặt kube-master-url) và để loại bỏ một số phụ thuộc Salt. Khi tôi thực hiện điều này, bộ điều khiển sao chép bắt đầu Bốn container thành công, nhưng container kube2sky bị chấm dứt khoảng một phút sau khi hoàn thành khởi tạo:

[[email protected] dns]$ kubectl --server="http://centos:8080" --namespace="kube-system" logs -f kube-dns-v11-t7nlb -c kube2sky 
I0325 20:58:18.516905  1 kube2sky.go:462] Etcd server found: http://127.0.0.1:4001 
I0325 20:58:19.518337  1 kube2sky.go:529] Using http://192.168.87.159:8080 for kubernetes master 
I0325 20:58:19.518364  1 kube2sky.go:530] Using kubernetes API v1 
I0325 20:58:19.518468  1 kube2sky.go:598] Waiting for service: default/kubernetes 
I0325 20:58:19.533597  1 kube2sky.go:660] Successfully added DNS record for Kubernetes service. 
F0325 20:59:25.698507  1 kube2sky.go:625] Received signal terminated 

tôi đã xác định rằng việc chấm dứt được thực hiện bằng container healthz sau khi báo cáo:

2016/03/25 21:00:35 Client ip 172.17.42.1:58939 requesting /healthz probe servicing cmd nslookup kubernetes.default.svc.cluster.local 127.0.0.1 >/dev/null 
2016/03/25 21:00:35 Healthz probe error: Result of last exec: nslookup: can't resolve 'kubernetes.default.svc.cluster.local', at 2016-03-25 21:00:35.608106622 +0000 UTC, error exit status 1 

Ngoài ra, tất cả các nhật ký khác đều trông bình thường. Tuy nhiên, có một điều bất thường: cần phải xác định --validate = false khi tạo trình điều khiển nhân bản, vì lệnh khác nhận được thông báo:

error validating "skydns-rc.yaml": error validating data: [found invalid field successThreshold for v1.Probe, found invalid field failureThreshold for v1.Probe]; if you choose to ignore these errors, turn validation off with --validate=false 

Điều này có liên quan không? Các đối số này đến trực tiếp tài liệu Kubernetes. nếu không, những gì cần thiết để có được điều này đang chạy?

Đây là skydns-rc.yaml tôi đã sử dụng:

apiVersion: v1 
kind: ReplicationController 
metadata: 
    name: kube-dns-v11 
    namespace: kube-system 
    labels: 
    k8s-app: kube-dns 
    version: v11 
    kubernetes.io/cluster-service: "true" 
spec: 
    replicas: 1 
    selector: 
    k8s-app: kube-dns 
    version: v11 
    template: 
    metadata: 
     labels: 
     k8s-app: kube-dns 
     version: v11 
     kubernetes.io/cluster-service: "true" 
    spec: 
     containers: 
     - name: etcd 
     image: gcr.io/google_containers/etcd-amd64:2.2.1 
     resources: 
      # TODO: Set memory limits when we've profiled the container for large 
      # clusters, then set request = limit to keep this container in 
      # guaranteed class. Currently, this container falls into the 
      # "burstable" category so the kubelet doesn't backoff from restarting it. 
      limits: 
      cpu: 100m 
      memory: 500Mi 
      requests: 
      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: gcr.io/google_containers/kube2sky:1.14 
     resources: 
      # TODO: Set memory limits when we've profiled the container for large 
      # clusters, then set request = limit to keep this container in 
      # guaranteed class. Currently, this container falls into the 
      # "burstable" category so the kubelet doesn't backoff from restarting it. 
      limits: 
      cpu: 100m 
      # Kube2sky watches all pods. 
      memory: 200Mi 
      requests: 
      cpu: 100m 
      memory: 50Mi 
     livenessProbe: 
      httpGet: 
      path: /healthz 
      port: 8080 
      scheme: HTTP 
      initialDelaySeconds: 60 
      timeoutSeconds: 5 
      successThreshold: 1 
      failureThreshold: 5 
     readinessProbe: 
      httpGet: 
      path: /readiness 
      port: 8081 
      scheme: HTTP 
      # we poll on pod startup for the Kubernetes master service and 
      # only setup the /readiness HTTP server once that's available. 
      initialDelaySeconds: 30 
      timeoutSeconds: 5 
     args: 
     # command = "/kube2sky" 
     - --domain="cluster.local" 
     - --kube-master-url=http://192.168.87.159:8080 
     - name: skydns 
     image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c 
     resources: 
      # TODO: Set memory limits when we've profiled the container for large 
      # clusters, then set request = limit to keep this container in 
      # guaranteed class. Currently, this container falls into the 
      # "burstable" category so the kubelet doesn't backoff from restarting it. 
      limits: 
      cpu: 100m 
      memory: 200Mi 
      requests: 
      cpu: 100m 
      memory: 50Mi 
     args: 
     # command = "/skydns" 
     - -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: gcr.io/google_containers/exechealthz:1.0 
     resources: 
      # keep request = limit to keep this container in guaranteed class 
      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 # Don't use cluster DNS. 

và 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.0.0.10" 
    ports: 
    - name: dns 
    port: 53 
    protocol: UDP 
    - name: dns-tcp 
    port: 53 
    protocol: TCP 

Trả lời

1

Tôi chỉ nhận xét ra các dòng có chứa các giá trị successThresholdfailureThreshold trong skydns-rc.yaml, sau đó chạy lại lệnh kubectl.

kubectl create -f skydns-rc.yaml 
kubectl create -f skydns-svc.yaml 
+0

Cảm ơn đề xuất. Thật không may, nó không có sự khác biệt. –

+1

Giá trị của SERVICE_CLUSTER_IP_RANGE là bao nhiêu? Đảm bảo IP DNS của bạn nằm trong cùng một mạng với giá trị bạn chỉ định ở đó. – ovidiu

+0

Đây là vấn đề! Cảm ơn. –

Các vấn đề liên quan