kubernetes 集群搭建

来源:互联网 发布:淘宝开店怎么取店名 编辑:程序博客网 时间:2024/06/06 06:42
安装主要分成3部分:etcd集群、master节点和minionsmaster  192.168.1.1minion  192.168.1.2master, minion:vim  /etc/yum.repos.d/virt7-docker-common-release.repo添加源:[virt7-docker-common-release]name=virt7-docker-common-releasebaseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/gpgcheck=0安装Kubernetes, etcd 和 flannel yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel加hosts:echo "192.168.1.1   centos-master192.168.1.2    centos-minion-1" >> /etc/hostsvi  /etc/kubernetes/config# logging to stderr means we get it in the systemd journalKUBE_LOGTOSTDERR="--logtostderr=true"# journal message level, 0 is debugKUBE_LOG_LEVEL="--v=0"# Should this cluster be allowed to run privileged docker containersKUBE_ALLOW_PRIV="--allow-privileged=false"# How the replication controller and scheduler find the kube-apiserverKUBE_MASTER="--master=http://centos-master:8080"master:vi /etc/etcd/etcd.conf 添加:# [member]ETCD_NAME=defaultETCD_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"vi  /etc/kubernetes/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 kubelets listen onKUBELET_PORT="--kubelet-port=10250"# Comma separated list of nodes in the etcd clusterKUBE_ETCD_SERVERS="--etcd-servers=http://centos-master:2379"# Address range to use for servicesKUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"# Add your own!KUBE_API_ARGS=""
systemctl start etcdetcdctl mkdir /kube-centos/networketcdctl mk /kube-centos/network/config "{ \"Network\": \"172.30.0.0/16\", \"SubnetLen\": 24, \"Backend\": { \"Type\": \"vxlan\" } }"vi /etc/sysconfig/flanneld# Flanneld configuration options# etcd url location.  Point this to the server where etcd runsFLANNEL_ETCD_ENDPOINTS="http://centos-master:2379"# etcd config key.  This is the configuration key that flannel queries# For address range assignmentFLANNEL_ETCD_PREFIX="/kube-centos/network"# Any additional options that you want to pass#FLANNEL_OPTIONS=""for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do    systemctl restart $SERVICES    systemctl enable $SERVICES    systemctl status $SERVICESdonevi  /etc/kubernetes/kubelet
# The address for the info server to serve onKUBELET_ADDRESS="--address=0.0.0.0"# The port for the info server to serve onKUBELET_PORT="--port=10250"# You may leave this blank to use the actual hostname# Check the node number!KUBELET_HOSTNAME="--hostname-override=centos-minion-n"# Location of the api-serverKUBELET_API_SERVER="--api-servers=http://centos-master:8080"# Add your own!KUBELET_ARGS=""for SERVICES in kube-proxy kubelet flanneld docker; do    systemctl restart $SERVICES    systemctl enable $SERVICES    systemctl status $SERVICESdone配置kubectlkubectl config set-cluster default-cluster --server=http://centos-master:8080kubectl config set-context default-context --cluster=default-cluster --user=default-adminkubectl config use-context default-context在master上检查是否能看到其他节点kubectl get nodesNAME              STATUS    AGEcentos-minion-n   Ready     1m到此集群已经跑起来了!

原创粉丝点击