安装kubernetes 环境

master: 10.6.2.170     #master节点兼做仓库

node-1: 10.6.2.171

node-2: 10.6.2.172

 

1、添加host解析

# cat <<EOF >>/etc/hosts
10.6.2.170  master workstation
10.6.2.171  node-1
10.6.2.172  node-2
EOF

 

2、安装master节点

第1步:配置安装并配置kubenetes-master相关的配置文件

# yum install etcd  kubernetes-master  flannel -y
# vim
/etc/etcd/etcd.conf #第1步:修改etcd的配置文件,要修改2处,IP地址指向自己
ETCD_LISTEN_CLIENT_URLS="http://10.6.2.170:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://10.6.2.170:2379"
# vim /etc/kubernetes/config    #是一个共同的配置文件所有的服务共用这个配置,主要配置日志、API Server、root权限等,指向master
KUBE_MASTER="--master=http://10.6.2.170:8080"
# vim /etc/kubernetes/apiserver     #修改以下配置,注释红色部份
KUBE_API_ADDRESS="--insecure-bind-address=10.6.2.170"
KUBE_ETCD_SERVERS="--etcd-servers=http://10.6.2.170:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
#KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
# vim /etc/kubernetes/controller-manager   #不需要修改
# vim /etc/kubernetes/scheduler   #不需要修改

第2步:配置flannel网络

# vim /etc/sysconfig/flanneld     #修改flannel的配置文件
FLANNEL_ETCD_ENDPOINTS="HTTP://10.6.2.170:2379"
FLANNEL_ETCD_PREFIX="/coreos.com/network"
# etcdctl -C http://10.6.2.170:2379 set /coreos.com/network/config '{"network":"192.168.0.0/16"}'   #修改flannel网络的网段

# systemctl enable flanneld.service 
# systemctl start flanneld.service 
# systemctl restart docker

第3步:配置启动服务和测试

# systemctl enable etcd.service 
# systemctl start etcd

# systemctl enable kube-apiserver.service 
# systemctl start kube-apiserver.service 

# systemctl enable kube-controller-manager.service 
# systemctl start kube-controller-manager.service 

# systemctl enable kube-scheduler.service 
# systemctl start kube-scheduler.service 

# kubectl get node -s 10.6.2.170:8080
NAME      STATUS    AGE
node-1    Ready     34m
node-2    Ready     32m

 

3、安装node节点 (2个节点配置一致)

# yum install kubernetes-node flannel -y
# vim /etc/kubernetes/config 
KUBE_MASTER="--master=http://10.6.2.170:8080"

# vim /etc/kubernetes/kubelet 
KUBELET_ADDRESS="--address=10.6.2.171"
KUBELET_HOSTNAME="--hostname-override=node-1"
KUBELET_API_SERVER="--api-servers=http://10.6.2.170:8080"
#KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"  #注释这一行

# vim /etc/sysconfig/flanneld 
FLANNEL_ETCD_ENDPOINTS="http://10.6.2.170:2379"
FLANNEL_ETCD_PREFIX="/coreos.com/network"

# systemctl enable flanneld.service 
# systemctl start flanneld.service 
# systemctl restart docker

# systemctl enable kubelet
# systemctl start kubelet
# systemctl enable kube-proxy.service 
# systemctl restart kube-proxy.service 

 

posted on 2018-04-23 20:43  tengq  阅读(230)  评论(0编辑  收藏  举报

导航