k8s集羣搭建(centos)

0.準備: centos ip爲 192.168.26.129(master) centos ip爲 192.168.26.131(node1) 兩臺機器都操做node

/etc/hosts添加
192.168.26.129 master
192.168.26.129 etcd
192.168.26.131 node1

1.中止centos的firewalld,關閉linuxlinux

systemctl disable firewalld
systemctl stop firewalld

編輯/etc/selinux/config,將SELINUX=enforcing改成SELINUX=disabled (爲的是重啓後也不啓動selinux) 本次也不啓動,先臨時關閉docker

setenforce 0

2.安裝 etcd,kubernetesvim

yum update
yum install -y etcd kubernetes

3.修改docker配置文件 vim /etc/sysconfig/dockercentos

OPTIONS='--selinux-enabled=false --insecure-registry gcr.io'

master節點api

4.修改etcd配置文件 vim /etc/etcd/etcd.confide

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://etcd:2379"

5.修改 apiserver 的配置文件 vim /etc/kubernetes/apiserver,綁定etcdspa

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" ## 必須
KUBE_ETCD_SERVERS="--etcd-servers=http://etcd:2379" ## 必須
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"

依次啓動服務code

systemctl start etcd
systemctl start docker(不是必須)
systemctl start kube-apiserver
systemctl start kube-controller-manager
systemctl start kube-scheduler

###### 若是master節點也是工做節點的話就啓動kubelet,不然不須要
systemctl start kubelet
systemctl start kube-proxy

192.168.26.131的node節點配置 vim /etc/kubernetes/kubeletserver

KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_HOSTNAME="--hostname-override=node1"
KUBELET_API_SERVER="--api-servers=http://master:8080"

節點啓動

systemctl start docker
systemctl start kubelet
systemctl start kube-proxy

此時在 master 節點上執行 kubectl get node

看到node1,ready表示成功

相關文章
相關標籤/搜索