博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu16 kubernetes1.6安装(七、kubedns安装)
阅读量:6758 次
发布时间:2019-06-26

本文共 6209 字,大约阅读时间需要 20 分钟。

本章中所使用的镜像为google资源,无法直接使用,本文为自行下载并上传到私有仓库:

gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.1
gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.1
gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.1
其实国内也有部分镜像库把gcr.io 替换成gcr.mirrors.ustc.edu.cn就可以下载了

1、修改默认配置文件,本文把所有配置文件贴出来,其实拿官网的对照着改动下即可,关键要和自己环境预定义的一致,其实整个流程很简单,只是过程较多,容易混乱。

配置文件如下:
root@ubuntu132:~/dnsyaml# ls
kubedns-cm.yaml kubedns-controller.yaml kubedns-sa.yaml kubedns-svc.yaml

root@ubuntu132:~/dnsyaml# cat kubedns-cm.yaml

apiVersion: v1
kind: ConfigMap
metadata:
name: kube-dns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists

root@ubuntu132:~/dnsyaml# cat kubedns-controller.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
spec:

strategy:

rollingUpdate:
maxSurge: 10%
maxUnavailable: 0
selector:
matchLabels:
k8s-app: kube-dns
template:
metadata:
labels:
k8s-app: kube-dns
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
tolerations:

  • key: "CriticalAddonsOnly"
    operator: "Exists"
    volumes:
  • name: kube-dns-config
    configMap:
    name: kube-dns
    optional: true
    containers:
  • name: kubedns
    image: docker.xxx.com:5000/k8s-dns-kube-dns-amd64:v1.14.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:    memory: 170Mi  requests:    cpu: 100m    memory: 70MilivenessProbe:  httpGet:    path: /healthcheck/kubedns    port: 10054    scheme: HTTP  initialDelaySeconds: 60  timeoutSeconds: 5  successThreshold: 1  failureThreshold: 5readinessProbe:  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: 3  timeoutSeconds: 5args:- --domain=cluster.local.  此处的域为事先定义的- --dns-port=10053- --config-dir=/kube-dns-config- --v=2#__PILLAR__FEDERATIONS__DOMAIN__MAP__   #该行注释掉env:- name: PROMETHEUS_PORT  value: "10055"ports:- containerPort: 10053  name: dns-local  protocol: UDP- containerPort: 10053  name: dns-tcp-local  protocol: TCP- containerPort: 10055  name: metrics  protocol: TCPvolumeMounts:- name: kube-dns-config  mountPath: /kube-dns-config
  • name: dnsmasq
    image: docker.xxx.com:5000/k8s-dns-dnsmasq-nanny-amd64:v1.14.1 #image为私有仓库中的
    livenessProbe:
    httpGet:
    path: /healthcheck/dnsmasq
    port: 10054
    scheme: HTTP
    initialDelaySeconds: 60
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
    args:
    • -v=2
    • -logtostderr
    • -configDir=/etc/k8s/dns/dnsmasq-nanny
    • -restartDnsmasq=true
    • --
    • -k
    • --cache-size=1000
    • --log-facility=-
    • --server=/cluster.local/127.0.0.1#10053
    • --server=/in-addr.arpa/127.0.0.1#10053
    • --server=/ip6.arpa/127.0.0.1#10053
      ports:
    • containerPort: 53
      name: dns
      protocol: UDP
    • containerPort: 53
      name: dns-tcp
      protocol: TCP

      see: for details

      resources:

      requests:
      cpu: 150m
      memory: 20Mi
      volumeMounts:

    • name: kube-dns-config
      mountPath: /etc/k8s/dns/dnsmasq-nanny
  • name: sidecar

    image: docker.xxx.com:5000/k8s-dns-sidecar-amd64:v1.14.1
    livenessProbe:
    httpGet:
    path: /metrics
    port: 10054
    scheme: HTTP
    initialDelaySeconds: 60
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
    args:

    • --v=2
    • --probe=kubedns,127.0.0.1:10053,kubernetes.default.svc.cluster.local,5,A
    • --probe=dnsmasq,127.0.0.1:53,kubernetes.default.svc.cluster.local,5,A
      ports:
    • containerPort: 10054
      name: metrics
      protocol: TCP
      resources:
      requests:
      memory: 20Mi
      cpu: 10m
      dnsPolicy: Default # Don't use cluster DNS.
      serviceAccountName: kube-dns

    root@ubuntu132:~/dnsyaml# cat kubedns-sa.yaml

    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: kube-dns
    namespace: kube-system
    labels:
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
    root@ubuntu132:~/dnsyaml# cat kubedns-svc.yaml
    apiVersion: v1
    kind: Service
    metadata:
    name: kube-dns
    namespace: kube-system
    labels:
    k8s-app: kube-dns
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
    kubernetes.io/name: "KubeDNS"
    spec:
    selector:
    k8s-app: kube-dns
    clusterIP: 10.254.0.2
    ports:

    • name: dns
      port: 53
      protocol: UDP
    • name: dns-tcp
      port: 53
      protocol: TCP

root@ubuntu132:~/dnsyaml# cat kubedns-svc.yaml

apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/name: "KubeDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: 10.254.0.2
ports:

  • name: dns
    port: 53
    protocol: UDP
  • name: dns-tcp
    port: 53
    protocol: TCP
    2、启动以及验证
    root# kubectl create -f . 启动所有组件
    首先验证kubedns的三个镜像是否正常

验证service是否存在,从下面命令看dns的service ip和预定义的一致,svc正常

root@ubuntu132:~/dnsyaml# kubectl get svc kube-dns --namespace=kube-system
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns 10.254.0.2 <none> 53/UDP,53/TCP 6d

验证kubedns 的三个镜像是否正常,如发现pod状态为 2/3之类的,意味着有问题,具体可到相应node上使用docker logs xxxx 查看具体原因。

root@ubuntu132:~/dnsyaml# kubectl get pods --namespace=kube-system -l k8s-app=kube-dns
NAME READY STATUS RESTARTS AGE
kube-dns-2598890466-xc0xd 3/3 Running 37 6d

最后使用node节点部署的验证方法,启动一个nginx或者其他镜像都行,然后进入容器进行kubedns的测试

root@ubuntu132:~/dnsyaml# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-2958629218-44rcm 1/1 Running 0 15h
nginx-2958629218-qd5rt 1/1 Running 0 15h
root@ubuntu132:~/dnsyaml# kubectl exec -it nginx-2958629218-44rcm /bin/bash
简要ping一下,看是否能够解析
root@nginx-2958629218-44rcm:/# ping kubernetes
PING kubernetes.default.svc.cluster.local (10.254.0.1): 56 data bytes
^C--- kubernetes.default.svc.cluster.local ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
root@nginx-2958629218-44rcm:/# ping kube-dns.kube-system.svc.cluster.local
PING kube-dns.kube-system.svc.cluster.local (10.254.0.2): 56 data bytes
^C--- kube-dns.kube-system.svc.cluster.local ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss

至此kubernetes1.6.4版本安装过程到此结束,后续插件dashboard同kubedns类似,仿照官网的配置文件进行修改。

转载于:https://blog.51cto.com/11448017/2048628

你可能感兴趣的文章
C#获取系统版本信息
查看>>
linux磁盘阵列实战
查看>>
Android应用程序进程启动过程的源代码分析(3)
查看>>
【畅谈百度轻应用】云时代·轻应用·大舞台
查看>>
Forefront_TMG_2010-TMG发布Web服务器
查看>>
MySQL字符集的一个坑
查看>>
区块链将成支付宝国际化的有力武器!
查看>>
理论上分析IP报文的结构各字段的意义
查看>>
OCS 2007 R2搭建准备虚机及快照
查看>>
Oracle 高可用概述
查看>>
存储虚拟化技术之解读
查看>>
X5Pro惊艳双子塔,vivo国际化渐入佳境
查看>>
(运维)VMware-vShield 5.0 安装与部署
查看>>
报表,是件容易的事吗?
查看>>
技术,技术人员,谁是风,谁是草
查看>>
Android应用程序内部启动Activity过程(startActivity)的源代码分析
查看>>
iOS网络编程-ASIHTTPRequest框架同步请求
查看>>
Gartner:2011年北美MSS市场分析
查看>>
一个网上找到的,在Grid中嵌套Grid的示例:Nested Grids Example
查看>>
IT群侠传第四回大鱼小虾
查看>>