k8s

Kubernetes集群搭建

实验环境
server2:172.25.50.2 (master)
server3:172.25.50.3 (node1)
server3:172.25.50.4 (node2)

yum 源配置

vim /etc/yum.repos.d/rhel.repo

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

yum -y install etcd kubernetes-master ##安装master
yum -y install flannel kubernetes-node ##安装node
修改配置文件:
vim /etc/etcd/etcd.conf

ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

vim /etc/kubernetes/apiserver

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" KUBE_API_PORT="--port=8080" KUBELET_PORT="--kubelet-port=10250" KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379" KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=172.25.0.0/16" KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" KUBE_API_ARGS=""

启动etcd、kube-apiserver、kube-controller-manager、kube-scheduler等服务

在etcd中定义flannel网络

etcdctl mk /atomic.io/network/config ‘{“Network”:”172.25.0.0/16”}’

修改配置文件

vim /etc/sysconfig/flanneld

FLANNEL_ETCD="http://172.25.50.2:2379"
 FLANNEL_ETCD_KEY="/atomic.io/network"

修改/etc/kubernetes/config文件

KUBE_LOGTOSTDERR="--logtostderr=true" KUBE_LOG_LEVEL="--v=0" KUBE_ALLOW_PRIV="--allow-privileged=false" KUBE_MASTER="--master=http://172.25.50.2:8080"

vim /etc/kubernetes/kubelet ##修改node文件

KUBELET_ADDRESS="--address=0.0.0.0" KUBELET_PORT="--port=10250" KUBELET_HOSTNAME="--hostname-override=172.25.50.3" KUBELET_API_SERVER="--api-servers=http://172.25.50.2:8080" KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest" KUBELET_ARGS=""

在所有Node节点上启动kube-proxy,kubelet,docker,flanneld等服务

验证集群是否安装成功

Master:kubectl get node

NAME                LABELS                              STATUS  
172.25.50.3         kubernetes.io/hostname=172.25.50.3  Ready       

你可能感兴趣的:(集群,k8s)