Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure k8s cluster in centos 7 system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to install and configure K8s cluster in centos 7 system, the content is very detailed, interested friends can refer to it, hope to be helpful to you.

Configuration background introduction

Kubernetes is an open source container cluster management system of google, which provides application deployment, maintenance, extension mechanism and other functions. Kubernetes can be used to easily manage containerized applications running across clusters, abbreviated as: K8s (there are 8 letters between k and s)

Experimental environment

Centos7.3 64 bit

Installation

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

Modify the configuration file

Note that the following 10.135.163.237 is replaced by your own server ip

Sed-I "s/localhost:2379/10.135.163.237:2379/g" / etc/etcd/etcd.confsed-I "s/localhost:2380/10.135.163.237:2380/g" / etc/etcd/etcd.confsed-I "s Unix 10.135.163.237Vue 2379max 10.135.163.237Vue 2379 Http:\ / 127.0.0.1Val 2379ZPG "/ etc/etcd/etcd.confsed-I" sAccount127.0.0.1With etc/kubernetes/apiserversed-I "s/--insecure-bind-address=127.0.0.1/--insecure-bind-address=0.0.0.0/g" / etc/kubernetes/apiserversed-I "makeshift", NamespaceLifecyclemNamespaceExistsLimitRangermSecurityContextDenyDenyServiceAccountLever ResourceQuotaqimicanmissioncontrolist NamespaceLifecycleists LimitRanger ResourceQuota/g "/ etc/kubernetes/apiserversed-I" s/--hostname-override=127.0.0.1/--hostname-override=10.135.163.237/g "/ etc/kubernetes/kubeletsed-I" s s/--address=127.0.0.1/--address=0.0.0.0/g 127.0.0.1V 8080max 10.135.163.237 s/--hostname-override=127.0.0.1/--hostname-override=10.135.163.237/g 8080max g "/ etc/kubernetes/kubeletsed-I" s/--address=127.0.0.1/--address=0.0.0.0/g "/ etc/kubernetes/kubeletsed-I" Splash 127.0.0.1 8080max 10.135.163.237V 80max g "/ etc/kubernetes/configsed-I" s debase 127.0.0.1 2379max 10.135.163.237g "/ etc/sysconfig/flanneld

Modify host

Vi / etc/hosts 10.135.163.237 k8s_master

Add Network

Systemctl enable etcd.servicesystemctl start etcd.serviceetcdctl mk / / atomic.io/network/config'{"Network": "172.17.0.0max 16"}'

Start the service

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

The first demo

Write a file a.yaml

ApiVersion: extensions/v1beta1 kind: Deployment metadata: name: my-appspec: replicas: 2 template: metadata: labels: app: my-appspec: 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

Write a file b.yaml

ApiVersion: v1 kind: Service metadata: name: my-app-svc labels: app: my-appspec: ports:-port: 80 targetPort: 80 nodePort: 30964 type: NodePort selector: app: my-app

Create a service

Kubectl create-f a.yaml-- validate kubectl create-f b.yaml-- validate

Delete a service

Kubectl delete-f a.yaml kubectl delete-f b.yaml

Add child nodes

Install softwar

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

Modify the configuration file (10.135.163.237 primary node ip,139.199.0.29 is the current node ip)

Sed-I "s/--hostname-override=127.0.0.1/--hostname-override=139.199.0.29/g" / etc/kubernetes/kubeletsed-I "s etc/kubernetes/kubeletsed 127.0.0.1A 800.0.1V 8080A / g" / etc/kubernetes/kubeletsed-I "s/--address=127.0.0.1/--address=0.0.0.0/g" / etc/kubernetes/kubeletsed-I "s 127.0.0.1: 8080Universe 10.135.163.237 s/--admission-control=NamespaceLifecycle 8080Compact g "/ etc/kubernetes/configsed-I" s/--admission-control=NamespaceLifecycle 127.0.0.1 Vortex 2379Compare 10.135.163.237Rank NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota/--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota/g "/ etc/kubernetes/apiserver

Start the service

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

View nodes on the primary server

Kubectl get node

Restart the service (rejoin the cluster)

Systemctl restart kube-apiserver.service

Delete nod

Kubectl delete node node ip on how to install and configure K8s cluster in centos 7 system is shared here. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report