centos 7 部署k8s集群

2022-02-21 02:58:18 字數 3370 閱讀 4204

systemctl stop firewalld

systemctl disable firewalld

yum -y install ntp

systemctl start ntpd

systemctl enable ntpd

yum update -y

安裝etcd  kubernetes 

yum -y install etcd kubernetes  flannel

配置etcd

配置k8s api

[root@kubernetes-master ~]# egrep -v "^#|^$" /etc/kubernetes/apiserver

kube_api_address="--insecure-bind-address=0.0.0.0"

kube_etcd_servers="--etcd-servers="

kube_service_addresses="--service-cluster-ip-range=10.254.0.0/16"

kube_admission_control="--admission-control=namespacelifecycle,namespaceexists,limitranger,resourcequota"

kube_api_args=""

配置flannel網路

[root@kubernetes-master ~]# egrep -v "^#|^$" /etc/sysconfig/flanneld

flannel_etcd_endpoints=""

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 ''

[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

可以看到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 $

然後重啟 docker

systemctl restart docker

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

yum -y install flannel kubernetes

配置/etc/sysconfig/flanneld

[root@kubernetes-node2 ~]# egrep -v "^#|^$" /etc/sysconfig/flanneld

flannel_etcd_endpoints=""

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="

配置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

啟動服務

for services in kube-proxy kubelet docker flanneld; do

systemctl restart $services

systemctl enable $services

systemctl status $services 

done

查詢相關節點

[root@kubernetes-master ~]# kubectl get nodes

name status age

10.64.8.69 ready 5d

10.64.8.70 ready 5d

10.64.8.72 ready 5d

centos 7 部署k8s集群,並發布nginx

k8s已成潮流,一般用來做容器排程,這裡簡單記錄下本機安裝和體驗的過程。k8s選擇 minikube。curl lo sudo install minikube linux amd64 usr local bin minikube yum install conntrack y yum remove...

CentOS7 部署K8S私有映象倉庫

現在嘗試搭建乙個私有的docker registry,並且配置使k8s.gcr.io gcr.io和quay.io等統統指向它來加快k8s搭建速度 依據 centos7實驗機模板搭建部署 部署一台實驗機 registry 192.168.77.10 依據 centos7部署安裝docker和dock...

K8S部署步驟 6 部署etcd集群

kuberntes系統使用etcd儲存所有資料,本文件介紹部署乙個三節點高可用的etcd集群的步驟,這三個節點復用kubernetes master機器,分別命名為erp kube test erp kube test2 erp kube test3 source root local bin en...