Kubernetes最小集群配置

Docker那么轻量意味着一个机器上可以跑很多的容器,容器一多,那么必然会涉及到管理,微服务需要进行管理,同样的容器也需要管理,这时候各种各样的管理工具出现了,而Kubernetes正是其中一款比较火热滴一个~

Kubernetes架构图:(来源:http://blog.csdn.net/lic95/article/details/55015284):

各个组件起什么作用,有什么职责,前人之述备矣,不再赘述。
下面记录一下安装的过程:
环境:
master:centos 7.0  192.168.32.128 
node1:centos 7.0   192.168.32.129
准备工作(所有机器需要做的操作):
1.安装Docker
略...
2.关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
3.为了保证各个机器之间的时间同步,需要安装ntp服务
yum -y install ntp
对所有的选项都选择y,直接安装
主机部分:
[root@localhost ~]# yum install etcd kubernetes flannel-y
在主机master上同时部署etcd server,kubernetes master,并且安装docker。

更改etcd配置(标红处):
# [member]
ETCD_NAME=master
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
#ETCD_WAL_DIR=""
#ETCD_SNAPSHOT_COUNT="10000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_LISTEN_PEER_URLS="http://localhost:2380"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379,http://0.0.0.0:4001"
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
#ETCD_CORS=""
#
#[cluster]
#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"
# if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."
#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"
#ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.32.128:2379,http://192.168.32.128:4001"


配置
[root@localhost ~]# vi /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://192.168.32.128:2379"
# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/coreos.com/network"
# Any additional options that you want to pass
#FLANNEL_OPTIONS=""

启动
[root@localhost ~]# systemctl start etcd
添加如下的命令,配置etcd中关于flannel的key:
[root@localhost ~]# etcdctl set /coreos.com/network/config '{ "Network": "192.168.0.0/16" }'(设置了一个B类的IP地址网段,和上边的
FLANNEL_ETCD_PREFIX="/coreos.com/network"的要对应)

参考文章:
http://www.cnblogs.com/zhenyuyaodidiao/p/6237019.html
修改k8s 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=127.0.0.1"
# 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://192.168.32.128:2379"
# Address range to use for services
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=192.168.0.0/16"
# default admission control policies

 

[root@localhost ~]# vi /etc/kubernetes/controller-manager
修改:
# Add your own!
KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --pod-eviction-timeout=10s"
 

[root@localhost ~]# vi /etc/kubernetes/config
修改:
# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://192.168.32.128:8080"
 

启动
systemctl enable kube-apiserver kube-scheduler kube-controller-manager
systemctl start kube-apiserver kube-scheduler kube-controller-manager

显示端口号:
ss -antl


 

启动成功。
----------------------
node1设置:
安装kubernetes-nodes以及flanneld
[root@localhost ~]# yum install kubernetes flannel -y
修改配置文件
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 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://192.168.32.128:8080"

[root@localhost ~]# vi /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=192.168.32.129"
# location of the api-server
KUBELET_API_SERVER="--api-servers=http://192.168.32.128: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=""


[root@localhost ~]# vi /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://192.168.32.128:2379"
# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/coreos.com/network"
# Any additional options that you want to pass
#FLANNEL_OPTIONS=""
 

最后,
Master:
[root@localhost ~]# systemctl start flanneld.service 
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart  docker.service
[root@localhost ~]# systemctl restart kube-apiserver.service
[root@localhost ~]# systemctl restart kube-controller-manager.service
[root@localhost ~]# systemctl restart kube-scheduler.service
node节点:
[root@localhost ~]# systemctl enable flanneld.service
[root@localhost ~]# systemctl start flanneld.service
Redirecting to /bin/systemctl restart  docker.service
[root@localhost ~]# systemctl restart kubelet.service
[root@localhost ~]# systemctl restart kube-proxy.service

至此,一个最简单的kubernetes集群创建完毕。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值