Kube-DNS搭建(1.4版本)
目录贴:Kubernetes学习系列
1、介绍
之前介绍过DNS的搭建(基于Kubernetes集群部署skyDNS服务),但那个版本的DNS是随着Kubernetes1.2发布出来的,有点原始。本文主要讲解Kubernetes1.4版本中的DNS插件的安装。与1.2版本相比,1.4中的DNS增加了解析Pod(HostName)对应的域名的新功能,且在部署上也有了一些变化。1.2中,需要部署etcd(或使用master上的Etcd)、kube2sky、skydns三个组件;1.4中,DNS组件由kubedns(监控Kubernetes中service变化)、dnsmasq(DNS服务)和一个健康检查容器——healthz组成。
在搭建PetSet(宠物应用)时,系统首先要为PetSet设置一个HeadLess service,即service的ClusterIP显示的设置成none,而对每一个有特定名称的Pet(Named Pod),可以通过其HostName进行寻址访问。这就用到了1.4中的新功能。以下给出具体的搭建过程。
2、修改配置
2.1修改各个node上的kubelet
修改以下红色部分,完成后重启kubelet服务。
[root@k8s-node- ~]# cat /etc/kubernetes/kubelet
###
# kubernetes kubelet (minion) config # The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0" # The port for the info server to serve on
# KUBELET_PORT="--port=10250" # You may leave this blank to use the actual hostname
#KUBELET_HOSTNAME="--hostname-override=127.0.0.1"
KUBELET_HOSTNAME="--hostname-override=k8s-node-1" # location of the api-server
KUBELET_API_SERVER="--api-servers=http://k8s-master:8080" # pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest" # Add your own!
#KUBELET_ARGS=""
KUBELET_ARGS="--cluster-dns=10.254.10.2 --cluster-domain=cluster.local. --allow-privileged=true"
[root@k8s-node- ~]# systemctl restart kubelet.service
2.2修改APIserver
修改以下红色部分:
[root@k8s-master ~]# cat /etc/kubernetes/apiserver
###
# kubernetes system config
#
# The following values are used to configure the kube-apiserver
# # The address on the local server to listen to.
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" # The port on the local server to listen on.
KUBE_API_PORT="--port=8080" # Port minions listen on
# KUBELET_PORT="--kubelet-port=10250" # Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://etcd:2379" # Address range to use for services
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # default admission control policies
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" # Add your own!
KUBE_API_ARGS=""
2.3 修改yaml文件
修改以下红色部分:
[root@k8s-master dns14]# cat kube-dns-rc_14.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-dns-v20
namespace: kube-system
labels:
k8s-app: kube-dns
version: v20
kubernetes.io/cluster-service: "true"
spec:
replicas: 1
selector:
k8s-app: kube-dns
version: v20
template:
metadata:
labels:
k8s-app: kube-dns
version: v20
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
spec:
containers:
- name: kubedns
image: gcr.io/google_containers/kubedns-amd64:1.8
imagePullPolicy: IfNotPresent
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: 70Mi
livenessProbe:
httpGet:
path: /healthz-kubedns
port:
scheme: HTTP
initialDelaySeconds:
timeoutSeconds:
successThreshold:
failureThreshold:
readinessProbe:
httpGet:
path: /readiness
port:
scheme: HTTP
# we poll on pod startup for the Kubernetes master service and
# only setup the /readiness HTTP server once that's available.
initialDelaySeconds:
timeoutSeconds:
args:
# command = "/kube-dns"
- --domain=cluster.local.
- --dns-port=
- --kube-master-url=http://10.0.251.148:8080
ports:
- containerPort:
name: dns-local
protocol: UDP
- containerPort:
name: dns-tcp-local
protocol: TCP
- name: dnsmasq
image: gcr.io/google_containers/kube-dnsmasq-amd64:1.4.
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /healthz-dnsmasq
port:
scheme: HTTP
initialDelaySeconds:
timeoutSeconds:
successThreshold:
failureThreshold:
args:
- --cache-size=
- --no-resolv
- --server=127.0.0.1#
- --log-facility=-
ports:
- containerPort:
name: dns
protocol: UDP
- containerPort:
name: dns-tcp
protocol: TCP
- name: healthz
image: gcr.io/google_containers/exechealthz-amd64:1.2
imagePullPolicy: IfNotPresent
resources:
limits:
memory: 50Mi
requests:
cpu: 10m
# Note that this container shouldn't really need 50Mi of memory. The
# limits are set higher than expected pending investigation on #.
# The extra memory was stolen from the kubedns container to keep the
# net memory requested by the pod constant.
memory: 50Mi
args:
- --cmd=nslookup kubernetes.default.svc.cluster.local. 127.0.0.1 >/dev/null
- --url=/healthz-dnsmasq
- --cmd=nslookup kubernetes.default.svc.cluster.local. 127.0.0.1: >/dev/null
- --url=/healthz-kubedns
- --port=
- --quiet
ports:
- containerPort:
protocol: TCP
dnsPolicy: Default # Don't use cluster DNS.
[root@k8s-master dns14]# cat kube-dns-svc_14.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:
protocol: UDP
- name: dns-tcp
port:
protocol: TCP
[root@k8s-master dns14]#
2.4 下载镜像
docker pull gcr.io/google_containers/kubedns-amd64:1.8
docker pull gcr.io/google_containers/kube-dnsmasq-amd64:1.4.
docker pull gcr.io/google_containers/exechealthz-amd64:1.2
3、启动
[root@k8s-master dns14]# kubectl create -f kube-dns-rc_14.yaml
replicationcontroller "kube-dns-v20" created
[root@k8s-master dns14]# kubectl create -f kube-dns-svc_14.yaml
service "kube-dns" created
4、验证
注意,以下演示中的web-0与web-1是两个“Named Pod”,是通过创建PetSet创建出来的Pod。详细介绍请参见后续文章。
[root@k8s-master dns14]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
frontend-service--xuysd / Running 3h 10.0.82.5 k8s-node-
web- / Running 3h 10.0.28.3 k8s-node-
web- / Running 3h 10.0.82.6 k8s-node-
[root@k8s-master dns14]# kubectl get svc mysql-service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
mysql-service 10.254.194.71 <nodes> /TCP 4h
[root@k8s-master dns14]# kubectl exec -ti frontend-service--xuysd /bin/bash
[root@frontend-service--xuysd /]# nslookup web-.nginx
Server: 10.254.10.2
Address: 10.254.10.2# Name: web-.nginx.default.svc.cluster.local
Address: 10.0.28.3 [root@frontend-service--xuysd /]# nslookup web-.nginx
Server: 10.254.10.2
Address: 10.254.10.2# Name: web-.nginx.default.svc.cluster.local
Address: 10.0.82.6 [root@frontend-service--xuysd /]# nslookup web-.nginx.default.svc.cluster.local
Server: 10.254.10.2
Address: 10.254.10.2# Non-authoritative answer:
Name: web-.nginx.default.svc.cluster.local
Address: 10.0.82.6
[root@frontend-service--xuysd /]# nslookup mysql-service
Server: 10.254.10.2
Address: 10.254.10.2# Name: mysql-service.default.svc.cluster.local
Address: 10.254.194.71
Kube-DNS搭建(1.4版本)的更多相关文章
- centos下搭建python双版本环境
		
目录 centos下搭建python双版本环境 一.安装python3 1.理清自带python位置 2.更新用于下载编译python3的相关包 3.安装pip 4.用pip安装wget 5.用wge ...
 - linux虚拟机环境快速搭建redis5.x版本的主从集群总结
		
文/朱季谦 我在阿里云服务器上曾参与过公司redis集群的搭建,但时间久了,都快忘记当时的搭建过程了,故而决定在虚拟机centOS 7的环境,自行搭建一套redis5.x版本的集群,该版本集群的搭建比 ...
 - 快速搭建ELK7.5版本的日志分析系统--搭建篇
		
title: 快速搭建ELK7.5版本的日志分析系统--搭建篇 一.ELK安装部署 官网地址:https://www.elastic.co/cn/ 官网权威指南:https://www.elastic ...
 - k8s1.20环境搭建部署(二进制版本)
		
1.前提知识 1.1 生产环境部署K8s集群的两种方式 kubeadm Kubeadm是一个K8s部署工具,提供kubeadm init和kubeadm join,用于快速部署Kubernetes集群 ...
 - 实战搭建SVN代码版本服务器
		
前言:公司要求搭建一台SVN代码版本管理服务器,用于管理所有代码资产: 项目架构图 1.环境安装 [root@host_centos ~]#yum –y install subversion mod_ ...
 - SVN+post-commit 搭建自动同步版本库
		
一.需求. 本地文件上传到测试环境svn,测试环境同步到生产环境rsync.开发环境与测试环境与生产环境分离. 二.搭建SVN服务器. yum -y install subversion && ...
 - 微信小程序的开发环境搭建(Windows版本)
		
前言: 小程序是指微信公众平台小程序,小程序可以帮助开发者快速的开发小程序,小程序可以在微信内被便捷地获取和传播:是一种不需要下载安装即可使用的应用小程序,和原有的三种公众号是并行的体系.2017年1 ...
 - linux dns搭建
		
DNS:域名解析(Domain Nmae System)正向解析:根据主机名称(域名)查找其对应的ip地址,这是最基本,最常用的功能反向解析:根据ip地址查找其对应的主机名称(域名),反垃圾邮件/安全 ...
 - 基于dns搭建eureka集群
		
eureka集群方案: 1.通常我们部署的eureka节点多于两个,根据实际需求,只需要将相邻节点进行相互注册(eureka节点形成环状),就达到了高可用性集群,任何一个eureka节点挂掉不会受到影 ...
 - 用pyenv和virtualenv搭建单机多版本python虚拟开发环境
		
作为主流开发语言, 用python 开发的程序越来越多. 方便的是大多linux系统里面都默认集成了python, 开发可以随时随地开始. 但有时候这也成为了一个短板, 比如说有时候我们需要开发和调试 ...
 
随机推荐
- IT观察】网络通信、图片显示、数据库操作……Android程序员如何利用开源框架
			
每个Android 程序员都不是Android应用开发之路上孤军奋战的一个人,GitHub上浩如烟海的开源框架或类库就是前人为我们发明的轮子,有的轮子能提高软件性能,而有的轮子似乎是以牺牲性能为代价换 ...
 - js 原型链和继承(转)
			
在理解继承之前,需要知道 js 的三个东西: 什么是 JS 原型链 this 的值到底是什么 JS 的 new 到底是干什么的 1. 什么是 JS 原型链? 我们知道 JS 有对象,比如 var ob ...
 - 乾坤合一~Linux设备驱动之终端设备驱动
			
多想拥你在我的怀里 却无法超越那距离 美好回忆渐渐地远去 盼望今生出现奇迹 无尽的想念 荒了容颜 无助的爱恋 从未改变 这是今天的旋律,,,,今生今世,遥不可及~ 1 终端设备 终端是一种字符型设备, ...
 - jQuery UI =>jquery-ui.js中sortable方法拖拽对象位置偏移问题
			
今天要处理sortable方法处理的对象,拖拽的时候,位置偏移的问题. 按理应该是鼠标在哪,对象就跟着在哪的 百度了一下问题,http://blog.csdn.net/samed/article/de ...
 - Ext JS 6 入门学习资料大全(2018-03-07)
			
现在 sencha touch已经升级为 Ext JS 6 了重新整理下资料 官方网站:https://www.sencha.com/ 在线文档:http://docs.sencha.com/extj ...
 - HTML load事件和DOMCOntentLoaded事件
			
JS高程 p14 “异步脚本一定会在页面的load事件前执行,但可能会在DOMContentLoaded事件触发之前或之后执行” 普通script标签会阻塞DOM的解析 DOMcontentLoa ...
 - socket与http
			
参考文档:http://blog.csdn.net/zeng622peng/article/details/5546384 1.TCP连接 手机能够使用联网功能是因为手机底层实现了TCP/IP协议,可 ...
 - C#压缩图片时保留原始的Exif信息
			
啥是Exif信息,有啥用,百度百科有解释: Exif百科 总之,这东西对摄影爱好者来说是不可或缺的,通常使用Photoshop来压缩只要不是保存为Web格式都会保留Exif信息. 而我们写代码来压缩图 ...
 - webservice接口测试wsdl
			
http和webservice接口测试有什么区别? webservice的基础组成是http+xml 三要素:soap传输协议,uddi,wsdl(webservice描述语言xml格式) 优点:跨平 ...
 - stm8s 引脚电平异常
			
特别注意: 1.有iic 的引脚为了兼容电平,一般来说都是可忍受电平,同时该引脚也将被去除推挽输出和强输出能力,甚至是上拉,使用时候特别注意,这种引脚在stm8上非常常见 2.stm引脚对电平不匹配非 ...