kubernetes+Dashboard+Heapster(一) 安装配置

简介: Kubernetes(k8s)是自动化容器操作的开源平台,这些操作包括部署,调度和节点集群间扩展。如果你曾经用过Docker容器技术部署容器,那么可以将Docker看成Kubernetes内部使用的低级别组件。Kubernetes不仅仅支持Docker,还支持Rocket,这是另一种容器技术。

阿里云专属镜像加速器

bqr1dr1n.mirror.aliyuncs.com

基本概念

  • pod 最小的基本单位,就像一个个对应的容器。对于一个简单的网站来说,一个POD是前台,一个POD是后台,一个POD是数据库。三个包含容器的POD各自独立运行。
  • replicationController 是对于POD的抽象组合,用于解决POD的伸缩问题。一般情况下,rc能够保持部分POD失效时自动维持可用POD数量的机制。
  • service 是对一些列POD以及访问这些POD的策略的一层抽象。service 通过label找到POD组,对外提供访问端口。
  • label POD中的label就是一个键值对,用来传递用户自定义的属性。简单说就是用来标记的,而且可以使用选择器选择特定的POD。
  • deployment 是对于RC的升级,提供了一种更加简单有效更新POD和RC的机制。通过yml文件中描述的期望的集群状态,deployment会将现在的集群状态在可控的速度下逐步更新成所期望的状态。集成了上线部署、滚动升级、创建副本、暂停上线任务,恢复上线任务,回滚到以前某一版本(成功/稳定)的Deployment等功能,在某种程度上,Deployment可以实现无人值守的上线,大大降低上线过程的复杂沟通、操作风险。
  • node 所有的服务都运行在node上,是一切服务的基础,就像虚拟机的宿主机。

安装配置

版本

  • OS:CentOS Linux release 7.3.1611 (Core) 3.10.0-514.16.1.el7.x86_64
  • Kubernetes 1.5.2
  • Docker 1.12.6(使用yum安装)
  • Etcd 3.1.5
  • Flannel 0.7.1 vxlan或者host-gw 网络
  • TLS 认证通信 (所有组件,如 etcd、kubernetes master 和 node)
  • kubedns、dashboard、heapster(influxdb、grafana)、EFK(elasticsearch、fluentd、kibana) 集群插件

环境准备

关闭防火墙

systemctl disable iptables-services firewalld
systemctl stop iptables-services firewalld

主机名

hosts

centos-master = 10.10.30.102
centos-minion-1 = 10.10.30.102
centos-minion-2 = 10.10.30.103
centos-minion-3 = 10.10.30.104

配置主机名,如果没有的话

echo "10.10.30.102    centos-master
10.10.30.102    centos-minion-1
10.10.30.103  centos-minion-2
10.10.30.104  centos-minion-3" >> /etc/hosts

yum 源

vim /etc/yum.repos.d/virt7-docker-common-release.repo

[virt7-docker-common-release]
name=virt7-docker-common-release
baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
gpgcheck=0

安装

yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel

版本

[root@localhost ~]# docker version
Client:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-1.12.6-68.gitec8512b.el7.centos.x86_64
 Go version:      go1.8.3
 Git commit:      ec8512b/1.12.6
 Built:           Mon Dec 11 16:08:42 2017
 OS/Arch:         linux/amd64

Server:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-1.12.6-68.gitec8512b.el7.centos.x86_64
 Go version:      go1.8.3
 Git commit:      ec8512b/1.12.6
 Built:           Mon Dec 11 16:08:42 2017
 OS/Arch:         linux/amd64

配置文件

/etc/kubernetes/config

修改以下内容

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://centos-master:8080"
KUBE_ETCD_SERVERS=”–etcd_servers=http://centos-master:4001″

主节点配置

/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://centos-master: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,ServiceAccount,ResourceQuota"

# Add your own!
KUBE_API_ARGS=""

/etc/etcd/etcd.conf

# [member]
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"

#[cluster]
ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"

配置etcd

systemctl start etcd
etcdctl mkdir /kube-centos/network
etcdctl mk /kube-centos/network/config "{ \"Network\": \"172.30.0.0/16\", \"SubnetLen\": 24, \"Backend\": { \"Type\": \"vxlan\" } }"

启动服务

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

节点配置

/etc/kubernetes/kubelet

node 增加

# The address for the info server to serve on
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=centos-minion”

# Add your own!
KUBELET_ARGS=””

启动节点服务

for SERVICES in kube-proxy kubelet docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

Configure kubectl

kubectl config set-cluster default-cluster --server=http://centos-master:8080
kubectl config set-context default-context --cluster=default-cluster --user=default-admin
kubectl config use-context default-context

检查状态

$ kubectl get nodes
NAME LABELS STATUS
centos-minion  Ready

更多参考:
Kubernetes + Dashboard + Heapster (一) 安装配置
Kubernetes + Dashboard + Heapster (二) 监控部署
Kubernetes + Dashboard + Heapster (三) ingress负载均衡
Kubernetes + Dashboard + Heapster (四) 慢慢填坑

你可能感兴趣的:(kubernetes+Dashboard+Heapster(一) 安装配置)