我一直在努力让 DNS 插件在 CentOS 7.2 集群上运行。我使用此处的说明安装了集群:http: //severalnines.com/blog/installing-kubernetes-cluster-minions-centos7-manage-pods-services
在此配置中,master 正在运行:etcd、kube-scheduler、kube-apiserver 和 kube-controller-manager。节点正在运行:docker、kubelet 和 kube-proxy 和 flanneld。集群在此配置中运行良好。豆荚,服务都在工作。下一步是尝试启用 DNS。
注意: 此集群不使用证书进行身份验证。
有几个关于如何做到这一点的“指南”,但它们似乎都不适用于这种类型的集群。
首先,请您帮我解决一些困惑。dns 插件容器在哪里运行?
- 他们必须在Master上运行吗?
- 它们可以像集群上的任何其他 pod 一样部署吗?
这是我到目前为止所尝试的:
Kubernetes 版本:从 yum 安装香草。
# kubectl version
Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0" GitCommit:"a4463d9a1accc9c61ae90ce5d314e248f16b9f05", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0", GitCommit:"a4463d9a1accc9c61ae90ce5d314e248f16b9f05", GitTreeState:"clean"}
在下面的 sky-dns.yaml 文件中,我已将模板变量替换为 1 个副本集,将 DNS_DOMAIN 设置为“cluster.local”。根据 StackOverflow 上的一些建议,我向“/kube-dns”容器“--kube-master-url= http://10.2.1.245:8080 ”添加了一个命令行。
SkyDNS-rc.yaml(指向 kube-dns v18)
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-dns-v18
namespace: kube-system
labels:
k8s-app: kube-dns
version: v18
kubernetes.io/cluster-service: "true"
spec:
replicas: 1
selector:
k8s-app: kube-dns
version: v18
template:
metadata:
labels:
k8s-app: kube-dns
version: v18
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: kubedns
image: gcr.io/google_containers/kubedns-amd64:1.6
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: 100Mi
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 = "/kube-dns"
- --domain=cluster.local
- --dns-port=10053
- --kube-master-url=http://10.2.1.245:8080
ports:
- containerPort: 10053
name: dns-local
protocol: UDP
- containerPort: 10053
name: dns-tcp-local
protocol: TCP
- name: dnsmasq
image: gcr.io/google_containers/kube-dnsmasq-amd64:1.3
args:
- --cache-size=1000
- --no-resolv
- --server=127.0.0.1#10053
ports:
- containerPort: 53
name: dns
protocol: UDP
- containerPort: 53
name: dns-tcp
protocol: TCP
- name: healthz
image: gcr.io/google_containers/exechealthz-amd64: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 && nslookup kubernetes.default.svc.cluster.local 127.0.0.1:10053 >/dev/null
- -port=8080
- -quiet
ports:
- containerPort: 8080
protocol: TCP
dnsPolicy: Default # Don't use cluster DNS.
在每个节点(主节点和 3 个小节点)上,我更新了 /etc/kubernetes/conf 文件,在末尾添加了 DSN 部分(为完整起见,发布了完整文件)。
如果我使用上面的复制控制器,是否需要添加这些?
/etc/kubernetes/conf
# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR="--logtostderr=true"
# journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0"
# Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false"
# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://127.0.0.1:8080"
# DNS Add-on
ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}"
DNS_SERVER_IP="10.254.100.1"
DNS_DOMAIN="cluster.local"
DNS_REPLICAS=1
这是我在部署 KubeDNS 时看到的。
[root@dcook-kube-c1 dcook]# kubectl create -f kube-fun/skydns-rc.yaml
replicationcontroller "kube-dns-v18" created
[root@dcook-kube-c1 dcook]# kubectl get rc kube-dns-v18 --namespace kube-system
NAME DESIRED CURRENT AGE
kube-dns-v18 1 1 34s
[root@dcook-kube-c1 dcook]# kubectl get pods --namespace kube-system
NAME READY STATUS RESTARTS AGE
kube-dns-v18-cx4ir 3/3 Running 0 46s
日志:
[root@dcook-kube-c1 dcook]# kubectl logs --namespace="kube-system" kube-dns-v18-cx4ir kubedns
I0726 20:17:52.675064 1 server.go:91] Using http://10.2.1.245:8080 for kubernetes master
I0726 20:17:52.676138 1 server.go:92] Using kubernetes API v1
I0726 20:17:52.676498 1 server.go:132] Starting SkyDNS server. Listening on port:10053
I0726 20:17:52.676815 1 server.go:139] skydns: metrics enabled on :/metrics
I0726 20:17:52.676836 1 dns.go:166] Waiting for service: default/kubernetes
I0726 20:17:52.677584 1 logs.go:41] skydns: ready for queries on cluster.local. for tcp://0.0.0.0:10053 [rcache 0]
I0726 20:17:52.677604 1 logs.go:41] skydns: ready for queries on cluster.local. for udp://0.0.0.0:10053 [rcache 0]
I0726 20:17:52.867455 1 server.go:101] Setting up Healthz Handler(/readiness, /cache) on port :8081
I0726 20:17:52.867843 1 dns.go:660] DNS Record:&{10.254.0.1 0 10 10 false 30 0 }, hash:63b49cf0
I0726 20:17:52.867898 1 dns.go:660] DNS Record:&{kubernetes.default.svc.cluster.local. 443 10 10 false 30 0 }, hash:c3f6ae26
I0726 20:17:52.868048 1 dns.go:660] DNS Record:&{kubernetes.default.svc.cluster.local. 0 10 10 false 30 0 }, hash:b9b7d845
I0726 20:17:52.868103 1 dns.go:660] DNS Record:&{10.254.91.7 0 10 10 false 30 0 }, hash:9b59fd9c
I0726 20:17:52.868137 1 dns.go:660] DNS Record:&{my-nginx.default.svc.cluster.local. 0 10 10 false 30 0 }, hash:b0f41a92
[root@dcook-kube-c1 dcook]# kubectl logs --namespace="kube-system" kube-dns-v18-cx4ir healthz
2016/07/26 20:17:11 Healthz probe error: Result of last exec: nslookup: can't resolve 'kubernetes.default.svc.cluster.local'
, at 2016-07-26 20:17:10.667247682 +0000 UTC, error exit status 1
2016/07/26 20:17:21 Healthz probe error: Result of last exec: nslookup: can't resolve 'kubernetes.default.svc.cluster.local'
, at 2016-07-26 20:17:20.667213321 +0000 UTC, error exit status 1
2016/07/26 20:17:31 Healthz probe error: Result of last exec: nslookup: can't resolve 'kubernetes.default.svc.cluster.local'
, at 2016-07-26 20:17:30.667225804 +0000 UTC, error exit status 1
2016/07/26 20:17:41 Healthz probe error: Result of last exec: nslookup: can't resolve 'kubernetes.default.svc.cluster.local'
, at 2016-07-26 20:17:40.667218056 +0000 UTC, error exit status 1
2016/07/26 20:17:51 Healthz probe error: Result of last exec: nslookup: can't resolve 'kubernetes.default.svc.cluster.local'
, at 2016-07-26 20:17:50.667724036 +0000 UTC, error exit status 1