centos 7 部署k8s集羣

前期準備

systemctl stop firewalld
systemctl disable firewalldnode

yum -y install ntpdocker

systemctl start ntpd
systemctl enable ntpdapi

yum update -y網絡

 

安裝etcd  Kubernetes ide

yum -y install etcd kubernetes  flannelatom

 

配置etcdspa

[root@kubernetes-master ~]# egrep -v "^#|^$" /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"rest

 

配置k8s apiserver

[root@kubernetes-master ~]# egrep -v "^#|^$" /etc/kubernetes/apiserver
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_ETCD_SERVERS="--etcd-servers=http://10.64.8.68:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"
KUBE_API_ARGS=""ip

 

配置flannel網絡

[root@kubernetes-master ~]# egrep -v "^#|^$" /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://10.64.8.68:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"

 

啓動etcd k8s服務

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES 
done

 

定義flannel network

[root@kubernetes-master ~]# etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

打通網絡

[root@localhost data]# etcdctl  ls /atomic.io/network/subnets

/atomic.io/network/subnets/172.17.35.0-24
/atomic.io/network/subnets/172.17.42.0-24
/atomic.io/network/subnets/172.17.67.0-24

[root@localhost data]#  etcdctl get /atomic.io/network/subnets/172.17.35.0-24

{"PublicIP":"192.168.0.164"}

能夠看到164 上面的網段爲172.17.35.0/24

 每一個機器上執行

[root@192-168-0-154 ~]# rm -y /var/run/docker.pid
[root@192-168-0-154 ~]# source /run/flannel/subnet.env
[root@192-168-0-154 ~]# ifconfig docker0 ${FLANNEL_SUBNET}

而後重啓 docker

systemctl restart docker

這樣容器之間網絡就打通了

配置Kubernetes Minions (Nodes節點都執行一遍)

yum -y install flannel kubernetes

配置/etc/sysconfig/flanneld

[root@kubernetes-node2 ~]# egrep -v "^#|^$" /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://10.64.8.68:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
FLANNEL_OPTIONS="" #這裏能夠指定哪一個網卡-iface=ens192

 

配置k8s   /etc/kubernetes/config

[root@kubernetes-node2 ~]# egrep -v "^#|^$" /etc/kubernetes/config
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://10.64.8.68:8080"

 

配置kubelet服務 /etc/kubernetes/kubelet 

[root@kubernetes-node2 ~]# egrep -v "^#|^$" /etc/kubernetes/kubelet 
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_HOSTNAME="--hostname-override=10.64.8.70" #這個是節點本身的IP
KUBELET_API_SERVER="--api-servers=http://10.64.8.68:8080"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

 

 

啓動服務

for SERVICES in kube-proxy kubelet docker flanneld; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES 
done

 

查詢相關節點

[root@kubernetes-master ~]# kubectl get nodesNAME STATUS AGE10.64.8.69 Ready 5d10.64.8.70 Ready 5d10.64.8.72 Ready 5d

相關文章
相關標籤/搜索