4.k8s kube-apiserver kube-scheduler kube-controller-manager服务的部署
Master节点:
#kubernets安装 yum -y install kubernetes #k8s需要配置的东西比较多,master上需要运行以下组件: kube-apiserver kube-scheduler kube-controller-manager #配置 apiserver sed -i 's#--insecure-bind-address=127.0.0.1#--insecure-bind-address=0.0.0.0#g' /etc/kubernetes/apiserver sed -i 's#--etcd-servers=http://127.0.0.1:2379#--etcd-servers=http://etcd:2379#g' /etc/kubernetes/apiserver sed -i 's#ServiceAccount,##g' /etc/kubernetes/apiserver #配置/etc/kubernetes/config文件 sed -i 's#--master=http://127.0.0.1:8080#--master=http://k8s-master:8080#g' /etc/kubernetes/config #启动和设置开机自己启动 kube-apiserver kube-scheduler kube-controller-manager systemctl start kube-apiserver.service systemctl start kube-controller-manager.service systemctl start kube-scheduler.service systemctl enable kube-apiserver.service systemctl enable kube-controller-manager.service systemctl enable kube-scheduler.service wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
首次安装K8S并启动这三个服务的脚本:
yum -y install kubernetes && sed -i 's#--insecure-bind-address=127.0.0.1#--insecure-bind-address=0.0.0.0#g' /etc/kubernetes/apiserver && sed -i 's#--etcd-servers=http://127.0.0.1:2379#--etcd-servers=http://etcd:2379#g' /etc/kubernetes/apiserver && sed -i 's#ServiceAccount,##g' /etc/kubernetes/apiserver && sed -i 's#--master=http://127.0.0.1:8080#--master=http://k8s-master:8080#g' /etc/kubernetes/config && systemctl start kube-apiserver.service && systemctl start kube-controller-manager.service && systemctl start kube-scheduler.service && systemctl enable kube-apiserver.service && systemctl enable kube-controller-manager.service && systemctl enable kube-scheduler.service && wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm && rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem && docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Node节点:
yum -y install kubernetes sed -i 's#--master=http://127.0.0.1:8080#--master=http://k8s-master:8080#g' /etc/kubernetes/config sed -i 's#--address=127.0.0.1#--address=0.0.0.0#g' /etc/kubernetes/kubelet sed -i 's#--api-servers=http://127.0.0.1:8080#--api-servers=http://k8s-master:8080#g' /etc/kubernetes/kubelet sed -i 's#--hostname-override=127.0.0.1#--hostname-override=k8s-node-1#g' /etc/kubernetes/kubelet systemctl start kubelet.service systemctl start kube-proxy.service systemctl enable kubelet.service systemctl enable kube-proxy.service wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
首次安装K8S并启动这 ( kubelet | kubernets-proxy) 两个服务的脚本:
yum -y install kubernetes && sed -i 's#--master=http://127.0.0.1:8080#--master=http://k8s-master:8080#g' /etc/kubernetes/config && sed -i 's#--address=127.0.0.1#--address=0.0.0.0#g' /etc/kubernetes/kubelet && sed -i 's#--api-servers=http://127.0.0.1:8080#--api-servers=http://k8s-master:8080#g' /etc/kubernetes/kubelet && sed -i 's#--hostname-override=127.0.0.1#--hostname-override=k8s-node-1#g' /etc/kubernetes/kubelet && systemctl start kubelet.service && systemctl start kube-proxy.service && systemctl enable kubelet.service && systemctl enable kube-proxy.service && wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm && rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem && docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest