检查etcd cluster状态
[iyunv@localhost ~]# etcdctl cluster-health
member eb1f405cbdb8358 is healthy: got healthy result from http://localhost:2379
cluster is healthy
[iyunv@localhost ~]#
检查etcd集群成员列表,这里只有一台
[iyunv@localhost ~]# etcdctl member list
eb1f405cbdb8358: name=default peerURLs=http://10.111.131.51:2380 clientURLs=http://localhost:2379 isLeader=true
[iyunv@localhost ~]
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://10.111.131.51:8080"
/etc/kubernetes/apiserver
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://10.111.131.51: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=""
2) 配置kube-controller-manager配置文件
# The following values are used to configure the kubernetes controller-manager
# defaults from config and apiserver should be adequate
# Add your own!
KUBE_CONTROLLER_MANAGER_ARGS=""
3) 配置kube-scheduler配置文件
/etc/kubernetes/scheduler
###
# kubernetes scheduler config
# default config should be adequate
# Add your own!
KUBE_SCHEDULER_ARGS="--address=0.0.0.0"
4) 启动服务
service kube-apiserver restart
service kube-controller-manager restart
service kube-scheduler restart
# Flanneld configuration options
# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://10.111.131.51:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/k8s/network"
# Any additional options that you want to pass
FLANNEL_OPTIONS="eno16777736"
7)配置node的kube-proxy
/etc/kubernetes/config (注意:本机是master也是node,因为前面已经配过,所以这里不用再配)
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://10.111.131.51:8080"
/etc/kubernetes/proxy
进行以下配置
config should be adequate
# Add your own!
KUBE_PROXY_ARGS="--bind=address=0.0.0.0"
8) 配置node的kubelet
在/etc/hosts下加入:10.111.131.51 k8s-master
/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=127.0.0.1"
# 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=k8s-master"
# location of the api-server
KUBELET_API_SERVER="--api-servers=http://10.111.131.51: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=""
9) 启动node服务
service flanneld start
service kube-proxy start
service kubelet start
10)至此,整个Kubernetes单机版环境搭建完,下面创建一个deployment进行测试
mysql-deployment.yaml
[iyunv@localhost ~]# kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
mysql-test 1 0 0 0 1m
[iyunv@localhost ~]#
出现上面的信息,表示Kubernetes安装成功。