ITPub博客

首页 > 云计算 > 虚拟化 > kubernetes分布式

kubernetes分布式

虚拟化 作者:hxw2ljj 时间:2015-11-19 16:31:26 0 删除 编辑

一、kubernetes简介

   Kubernetes 是Google开源的容器集群管理系统,基于Docker构建一个容器的调度服务,提供资源调度、均衡容灾、服务注册、动态扩缩容等功能套件,目前最新版本为1.1.1。本文介绍如何基于Centos7构建Kubernetes平台。

二、架构环境

系统:Centos7

网络配置: kubernetes_master-192.168.122.207 

       kubernetes_etcd-192.168.122.196 

       kubernetes_nodes-192.168.122.131

应用:kubernetes + etcd + docker

三、kubernetes_etcd安装etcd并升级

#yum install -y etcd

#wget https://github.com/coreos/etcd/releases/download/v2.3.0-alpha.0/etcd-v2.3.0-alpha.0-linux-amd64.tar.gz

#tar zxvf etcd-v2.3.0-alpha.0-linux-amd64.tar.gz

#cd etcd-v2.3.0-alpha.0-linux-amd64

#cp etcd* /usr/local/bin

#systemctl start etcd.service

#systemctl enable etcd.service

四、配置etcd(改动标红)

#vim /etc/etcd/etcd.conf

# [member]

ETCD_NAME=default

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

#ETCD_SNAPSHOT_COUNTER="10000"

#ETCD_HEARTBEAT_INTERVAL="100"

#ETCD_ELECTION_TIMEOUT="1000"

#ETCD_LISTEN_PEER_URLS="http://localhost:2380"

ETCD_LISTEN_CLIENT_URLS="http://192.168.122.196:2379"

#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.122.196:2379"

#ETCD_DISCOVERY=""

#ETCD_DISCOVERY_SRV=""

#ETCD_DISCOVERY_FALLBACK="proxy"

#ETCD_DISCOVERY_PROXY=""

#[proxy]

#ETCD_PROXY="off"

#[security]

#ETCD_CERT_FILE=""

#ETCD_KEY_FILE=""

#ETCD_CLIENT_CERT_AUTH="false"

#ETCD_TRUSTED_CA_FILE=""

#ETCD_PEER_CERT_FILE=""

#ETCD_PEER_KEY_FILE=""

#ETCD_PEER_CLIENT_CERT_AUTH="false"

#ETCD_PEER_TRUSTED_CA_FILE=""

#[logging]

#ETCD_DEBUG="false"

# examples for -log-package-levels etcdserver=WARNING,security=DEBUG

五、kubernetes_master安装kubernetes并升级

#yum install -y kubernetes

#wget https://github.com/kubernetes/kubernetes/releases/download/v1.1.1/kubernetes.tar.gz

#tar zxvf kubernetes.tar.gz

#cd kubernetes

#tar zxf kubernetes/server/kubernetes-server-linux-amd64.tar.gz

#cp kubernetes/server/kube* /usr/bin

六、配置kubernetes_master(改动标红)

#vim /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.122.207:8080"

#vim /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="--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://192.168.122.196: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=""

vim /etc/kubernetes/controller-manager

# The following values are used to configure the kubernetes controller-manager

KUBELET_ADDRESSES="--machines= 192.168.122.131"

# defaults from config and apiserver should be adequate

# Add your own!

KUBE_CONTROLLER_MANAGER_ARGS=""

七、启动服务

#systemctl start kube-apiserver.service kube-controller-manager.service kube-scheduler.service

#systemctl enable kube-apiserver.service kube-controller-manager.service kube-scheduler.service

八、kubernetes_nodes安装kubernetes和docker并升级

#yum install -y kubernetes docker

#wget https://github.com/kubernetes/kubernetes/releases/download/v1.1.1/kubernetes.tar.gz

#tar zxvf kubernetes.tar.gz

#cd kubernetes

#tar zxf kubernetes/server/kubernetes-server-linux-amd64.tar.gz

#cp kubernetes/server/kube* /usr/bin

九、配置kubernetes_nodes(改动标红)

# 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.122.207"

# location of the api-server

KUBELET_API_SERVER="--api_servers=http://192.168.122.207:8080"

# Add your own!

KUBELET_ARGS=""

十、启动kubernetes_nodes服务

#systemctl enable docker.service kubelet.service kube-proxy.service

#systemctl start docker.service kubelet.service

十一、测试连通性

#kubecel version

Client Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.1", GitCommit:"6a5c06e3d1eb27a6310a09270e4a5fb1afa93e74", GitTreeState:"clean"}

Server Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.1", GitCommit:"6a5c06e3d1eb27a6310a09270e4a5fb1afa93e74", GitTreeState:"clean"}

(证明apiserver以启动)

#kubectl get nodes

NAME          LABELS                        STATUS

192.168.122.207   kubernetes.io/hostname=192.168.122.207   Ready

(证明kubernetes_master和kubernetes_nodes连接成功)

十二、总结

   拜读了很多大牛的博文终于把最新的kubernetes分布式架构起来,期间太多的坑不言而喻,希望同行小伙伴们看到此篇博文能有一些启发,后面还会有kubernetes分布式管理docker容器博文和大家分享,已达到抛砖引玉的效果。希望大牛路过指点一二,不胜感激。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18796236/viewspace-1841203/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 虚拟化技术
下一篇: RESTful与Openstack
全部评论

注册时间:2010-11-22

  • 博文量
    58
  • 访问量
    42895