怎么在centos7系统中安装配置k8s集群-创新互联
这篇文章给大家介绍怎么在centos 7系统中安装配置k8s集群,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
在南芬等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、网站制作、外贸营销网站建设 网站设计制作按需求定制设计,公司网站建设,企业网站建设,成都品牌网站建设,成都全网营销推广,外贸网站建设,南芬网站建设费用合理。配置背景介绍
kubernetes是google开源的容器集群管理系统,提供应用部署、维护、扩展机制等功能,利用kubernetes能方便管理跨集群运行容器化的应用,简称:k8s(k与s之间有8个字母)
实验环境
centos7.3 64位
安装
yum-config-manager --add-repo https://docs.docker.com/v1.13/engine/installation/linux/repo_files/centos/docker.repo yum makecache fast yum -y install docker-engine-1.13.1 yum install epel-release -y yum remove -y docker-engine* yum install -y kubernetes etcd docker flannel
修改配置文件
注意下面的10.135.163.237换成自己服务器ip
sed -i "s/localhost:2379/10.135.163.237:2379/g" /etc/etcd/etcd.conf sed -i "s/localhost:2380/10.135.163.237:2380/g" /etc/etcd/etcd.conf sed -i "s/10.135.163.237:2379/10.135.163.237:2379,http:\/\/127.0.0.1:2379/g" /etc/etcd/etcd.conf sed -i "s/127.0.0.1:2379/10.135.163.237:2379/g" /etc/kubernetes/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/--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota/--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota/g" /etc/kubernetes/apiserver sed -i "s/--hostname-override=127.0.0.1/--hostname-override=10.135.163.237/g" /etc/kubernetes/kubelet sed -i "s/127.0.0.1:8080/10.135.163.237:8080/g" /etc/kubernetes/kubelet sed -i "s/--address=127.0.0.1/--address=0.0.0.0/g" /etc/kubernetes/kubelet sed -i "s/127.0.0.1:8080/10.135.163.237:8080/g" /etc/kubernetes/config sed -i "s/127.0.0.1:2379/10.135.163.237:2379/g" /etc/sysconfig/flanneld
修改host
vi /etc/hosts 10.135.163.237 k8s_master
添加网络
systemctl enable etcd.service systemctl start etcd.service etcdctl mk //atomic.io/network/config '{"Network":"172.17.0.0/16"}'
启动服务
service docker start for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet docker flanneld ; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done;
第一个demo
编写文件a.yaml
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: my-app spec: replicas: 2 template: metadata: labels: app: my-app spec: containers: - name: my-app image: registry.alauda.cn/yubang/paas_base_test ports: - containerPort: 80 command: ["/bin/bash", "/var/start.sh"] resources: limits: cpu: 0.5 memory: 64Mi
编写文件b.yaml
apiVersion: v1 kind: Service metadata: name: my-app-svc labels: app: my-app spec: ports: - port: 80 targetPort: 80 nodePort: 30964 type: NodePort selector: app: my-app
创建服务
kubectl create -f a.yaml --validate kubectl create -f b.yaml --validate
删除服务
kubectl delete -f a.yaml kubectl delete -f b.yaml
增加子节点
安装软件
yum-config-manager --add-repo https://docs.docker.com/v1.13/engine/installation/linux/repo_files/centos/docker.repo yum makecache fast yum -y install docker-engine-1.13.1 yum install epel-release -y yum remove -y docker-engine* yum install -y kubernetes docker flannel
修改配置文件(10.135.163.237为主节点ip,139.199.0.29为当前节点ip)
sed -i "s/--hostname-override=127.0.0.1/--hostname-override=139.199.0.29/g" /etc/kubernetes/kubelet sed -i "s/127.0.0.1:8080/10.135.163.237:8080/g" /etc/kubernetes/kubelet sed -i "s/--address=127.0.0.1/--address=0.0.0.0/g" /etc/kubernetes/kubelet sed -i "s/127.0.0.1:8080/10.135.163.237:8080/g" /etc/kubernetes/config sed -i "s/127.0.0.1:2379/10.135.163.237:2379/g" /etc/sysconfig/flanneld sed -i "s/--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota/--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota/g" /etc/kubernetes/apiserver
启动服务
service docker start for SERVICES in kube-proxy kubelet docker flanneld; do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done;
在主服务器查看节点
kubectl get node
重启服务(重新加入集群)
systemctl restart kube-apiserver.service
删除节点
kubectl delete node 节点ip
关于怎么在centos 7系统中安装配置k8s集群就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享文章:怎么在centos7系统中安装配置k8s集群-创新互联
转载注明:http://hbruida.cn/article/dhdhjp.html