上文我们在一台虚机上演示了Kubernetes基于redis和docker的guestbook留言簿案例,本文我们将通过配置Kubernetes集群的方式继续深入研究。集群组件安装如下配置。
IP NAME Component
192.168.56.103 centos-master etcd,kube-apiserver,kube-controller-manager,kube-scheduler
192.168.56.105 centos-node01 kube-proxy,kubelet,docker
192.168.56.107 centos-node02 kube-proxy,kubelet,docker
主机环境:centos 7,三台虚机。
1.准备工作
以下工作在每台虚机执行。
1.1 停止防火墙
#systemctl disable firewalld
#systemctl stop firewalld
1.2 修改iptables
yum install iptables-services
vi /etc/sysconfig/iptables把icmp-host-prohibited两条注释掉
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
#-A INPUT -j REJECT --reject-with icmp-host-prohibited
#-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
重启iptables
#systemctl restart iptables
1.3 使用阿里镜像(或other)
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1.4 更新主机列表
#echo "192.168.56.103 CentOS7.2  
192.168.56.105 CentOS7-1 
192.168.56.107 CentOS7-2"  >> /etc/hosts
2.安装配置kubernetes master
2.1 在centos-master上安装
#yum install kubernetes-master
#yum install etcd
2.2配置 Kubernetes services
#vi /etc/kubernetes/config
#### kubernetes system config## The following values are used to configure various aspects of all# kubernetes services, including##   kube-apiserver.service#   kube-controller-manager.service#   kube-scheduler.service#   kubelet.service#   kube-proxy.service# logging to stderr means we get it in the systemd journalKUBE_LOGTOSTDERR="--logtostderr=true"# journal message level, 0 is debugKUBE_LOG_LEVEL="--v=0"# Should this cluster be allowed to run privileged docker containersKUBE_ALLOW_PRIV="--allow-privileged=false"# How the controller-manager, scheduler, and proxy find the apiserverKUBE_MASTER="--master=http://centos-master:8080"
2.3配置Kubernetes API server
#vi /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="--insecure-port=8080"# Port minions listen on#KUBELET_PORT="--kubelet-port=10250"# Comma separated list of nodes in the etcd clusterKUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379"# Address range to use for servicesKUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"# default admission control policiesKUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"# Add your own!KUBE_API_ARGS=""
2.4 启动服务
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do     systemctl restart $SERVICES    systemctl enable $SERVICES    systemctl status $SERVICES done

2.5 停止服务

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl stop $SERVICES
done
3.安装配置kubernetes node
3.1 在centos-node01及centos-node02上安装
#yum install kubernetes-node
#vi /etc/kubernetes/config
#### kubernetes system config## The following values are used to configure various aspects of all# kubernetes services, including##   kube-apiserver.service#   kube-controller-manager.service#   kube-scheduler.service#   kubelet.service#   kube-proxy.service# logging to stderr means we get it in the systemd journalKUBE_LOGTOSTDERR="--logtostderr=true"# journal message level, 0 is debugKUBE_LOG_LEVEL="--v=0"# Should this cluster be allowed to run privileged docker containersKUBE_ALLOW_PRIV="--allow-privileged=false"# How the controller-manager, scheduler, and proxy find the apiserverKUBE_MASTER="--master=http://centos-master:8080"
3.2 配置 kubelet文件
vi /etc/kubernetes/kubelet
centos-node01
#### 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 onKUBELET_PORT="--port=10250"# You may leave this blank to use the actual hostnameKUBELET_HOSTNAME="--hostname-override=centos-minion01"# location of the api-serverKUBELET_API_SERVER="--api-servers=http://centos-master:8080"# pod infrastructure containerKUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"# Add your own!KUBELET_ARGS=""
centos-node02
###
# 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 onKUBELET_PORT="--port=10250"# You may leave this blank to use the actual hostnameKUBELET_HOSTNAME="--hostname-override=centos-minion02"# location of the api-serverKUBELET_API_SERVER="--api-servers=http://centos-master:8080"# pod infrastructure containerKUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"# Add your own!KUBELET_ARGS=""
3.3 配置config文件
     vi /etc/kubernetes/config
#### kubernetes system config## The following values are used to configure various aspects of all# kubernetes services, including##   kube-apiserver.service#   kube-controller-manager.service#   kube-scheduler.service#   kubelet.service#   kube-proxy.service# logging to stderr means we get it in the systemd journalKUBE_LOGTOSTDERR="--logtostderr=true"# journal message level, 0 is debugKUBE_LOG_LEVEL="--v=0"# Should this cluster be allowed to run privileged docker containersKUBE_ALLOW_PRIV="--allow-privileged=false"# How the controller-manager, scheduler, and proxy find the apiserverKUBE_MASTER="--master=http://centos-master:8080"
3.4 启动服务
for SERVICES in kube-proxy kubelet docker; do     systemctl restart $SERVICES    systemctl enable $SERVICES    systemctl status $SERVICES done
在centos-node01上启动
[root@centos-minion01 ~]# for SERVICES in kube-proxy kubelet docker; do>     systemctl restart $SERVICES>     systemctl enable $SERVICES>     systemctl status $SERVICES> done
在centos-minion02上启动
[root@centos-minion02 kubernetes]# for SERVICES in kube-proxy kubelet docker; do>     systemctl restart $SERVICES>     systemctl enable $SERVICES>     systemctl status $SERVICES> done
3.5 停止服务
for SERVICES in kube-proxy kubelet docker; do     systemctl stop $SERVICES done
4. 检查及确认状态
#kubectl get nodes
#kubectl cluster-info
我们看到2个节点都正常启动。
[root@CentOS7 yum.repos.d]# kubectl get nodes
NAME LABELS STATUS AGE
127.0.0.1 kubernetes.io/hostname=127.0.0.1 Ready 15d
centos7-1 kubernetes.io/hostname=centos7-1 Ready 4m
centos7-2 kubernetes.io/hostname=centos7-2 Ready 4m
[root@CentOS7 yum.repos.d]# kubectl cluster-info
Kubernetes master is running at http://localhost:8080

Kubernetes集群初探的更多相关文章

  1. 基于Python+Django的Kubernetes集群管理平台

    ➠更多技术干货请戳:听云博客 时至今日,接触kubernetes也有一段时间了,而我们的大部分业务也已经稳定地运行在不同规模的kubernetes集群上,不得不说,无论是从应用部署.迭代,还是从资源调 ...

  2. Kubernetes集群搭建过程中遇到的问题

    1. 创建Nginx Pod过程中报如下错误: #kubectlcreate -f nginx-pod.yaml Error from server: error when creating &quo ...

  3. kubernetes集群部署

    鉴于Docker如此火爆,Google推出kubernetes管理docker集群,不少人估计会进行尝试.kubernetes得到了很多大公司的支持,kubernetes集群部署工具也集成了gce,c ...

  4. 在Openstack上创建并访问Kubernetes集群

    第一部分:创建集群 在Openstack部署Kubernetes集群运行Nginx容器的步骤,其中包括: 利用Murano部署Kubernetes集群 配置Openstack的安全性使Kubernet ...

  5. Centos7上安装Kubernetes集群部署docker

    一.安装前准备1.操作系统详情需要三台主机,都最小化安装 centos7.3,并update到最新 [root@master ~]# (Core) 角色 主机名 IPMaster master 192 ...

  6. 和我一步步部署 kubernetes 集群

    和我一步步部署 kubernetes 集群 本系列文档介绍使用二进制部署最新 kubernetes v1.6.1 集群的所有步骤,而不是使用 kubeadm 等自动化方式来部署集群: 在部署的过程中, ...

  7. 在Kubernetes集群中使用calico做网络驱动的配置方法

    参考calico官网:http://docs.projectcalico.org/v2.0/getting-started/kubernetes/installation/hosted/kubeadm ...

  8. 使用acs-engine在Azure中国区部署kubernetes集群详解

    转载请注明出处:http://www.cnblogs.com/wayneiscoming/p/7649642.html 1. acs-engine简介 ACS是微软在2015年12月推出的一项基于容器 ...

  9. Traefik实现Kubernetes集群服务外部https访问

    转载请注明出处:http://www.cnblogs.com/wayneiscoming/p/7707942.html traefik 是一个前端http反向代理服务器以及负载均衡器,支持多种微服务后 ...

随机推荐

  1. java-final关键字

    一.final理解 编程语言中关键字,final类不能被继承,因此final类的成员方法没有机会被覆盖,默认都是final的.在设计类时候,如果这个类不需要有子类,类的实现细节不允许改变,并且确信这个 ...

  2. nginx(tengine)的一些小优化(持续更新)

    1.nginx日志切割脚本 需求来源:nginx本身并没有日志切割的功能,由访问产生的大日志很难进行分析. 实现目的:每天对nginx日志进行切割,并备份至指定文件夹. 简要指令: mv /usr/l ...

  3. A 最熟悉的陌生人 (纪念当年就读的梅州市江南高级中学)

    最熟悉的陌生人 作者:张慧桥 “枪与玫瑰” 就象瘟98有时会死机天有时会下雨枪有时会走火美国战机有时会掉下来那样,我上网聊天也只是个偶然. 都是栀子那死丫头惹的祸.让每天都觉得是情人节的我那天我自己都 ...

  4. 在 Web 项目中应用 Apache Shiro

    Apache Shiro 是功能强大并且容易集成的开源权限框架,它能够完成认证.授权.加密.会话管理等功能.认证和授权为权限控制的核心,简单来说,"认证"就是证明你是谁? Web ...

  5. Struts1.x有两个execute方法,不要重写错哦HttpServletRequest才是对的(转)

    Struts1.x 的 Action 有两个 execute 哦,小心搞错! by agate - Published: 2008-05-01 [9:42 下午] - Category: 程序编码 不 ...

  6. System.Data.EntityState”在未被引用的程序集中定义

    类型“System.Data.EntityState”在未被引用的程序集中定义.必须添加对程序集“System.Data.Entity, Version=4.0.0.0, Culture=neu 错误 ...

  7. log4net 配置

    1.是直接在代码中通过调用XmlConfigurator.Configure()来解析配置文件,配置日志环境. log4net.Config.XmlConfigurator.Configure(); ...

  8. OAF_开发系列04_实现OAF查询4种不同的实现方式的比较和实现(案例)

    2014-06-02 Created By BaoXinjian

  9. 在linux上通过yum安装JDK

    完全转载自:https://my.oschina.net/andyfeng/blog/601291 这里完整粘贴一份留存 卸载centos自带的jdk 1.查看当前的jdk版本,并卸载 [root@l ...

  10. [转]-CSS 元素垂直居中的6种方法

    原文地址:http://blog.zhourunsheng.com/2012/03/css-%E5%85%83%E7%B4%A0%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD ...