本文按照官网部署
详情参考http://kubernetes.io/v1.1/docs/getting-started-guides/centos/centos_manual_config.html
- 两台相同的centos7主机分别命名为master, minion
- 配置静态IP地址,并且在hosts文件写入对应的地址解析
- 更换yum地址为国内源, ali 或者 163都可以
- 添加kubernetes源地址
http://cbs.centos.org/repos/virt7-docker-common-testing/x86_64/os/- 关闭firewall , selinux
- 更新系统软件包后重启机器
两台机器均要安装
yum install kubernetes
yum install http://cbs.centos.org/kojifiles/packages/etcd/0.4.6/7.el7.centos/x86_64/etcd-0.4.6-7.el7.centos.x86_64.rpm
两台机器修改以下配置,编辑/etc/kubernetes/config
# Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://master:4001"
# 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"
KUBE_MASTER="--master=http://master:8080"
在master机器修改, 编辑/etc/kubernetes/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"
# How the replication controller and scheduler find the kube-apiserver
KUBE_MASTER="--master=http://master:8080"
# 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=""
启动服务
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart $SERVICES
systemctl enable $SERVICES
done
在minion机器修改编辑 /etc/kubernetes/kubelet
# 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=minion"
# location of the api-server
KUBELET_API_SERVER="--api-servers=http://master:8080"
# Add your own!
KUBELET_ARGS=""
启动服务
for SERVICES in kube-proxy kubelet docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
done
检查集群状态
在master机器上执行
[root@master ~]# kubectl get nodes
NAME LABELS STATUS AGE
minion kubernetes.io/hostname=minion Ready 14m