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

K8s cluster construction of operation and maintenance

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Summary of prerequisites for deploying K8s cluster with kubeadm: 1, time synchronization of each node; 2, host name resolution of each node: dns OR hosts 3 / etc/hosts 3, iptables and firewalld services of each node are disable1:master (192.168.1.179) components:

Https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/

Configure yum Warehouse Import docker download docker-ce.repowget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repocd / etc/yum.repos.d/vim k8s.repo # configure kubetnetes Repository [K8s] name=K8s Repobaseurl= https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/gpgcheck=0gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpgenabled=1yum repolist check whether the two repositories are available for installation Docker-ce kubelet kubeadm kubectlyum install docker-ce kubelet kubeadm kubectl-y if there is an error manually download key execute the following command wget https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpgrpm-- import yum-key.gpg initialize docker start docker service systemctl daemon-reload # reload file systemctl start docker.service # start docker systemctl enable docker.service # set boot self-boot systemctl enable kubelet.service docker needs to automatically go to docker warehouse The library downloads the image or downloads each dependent image file through the local repository. Automatically download the dependent image cd / usr/lib/systemd/system/docker.service through docker and add the environment variable Environment= "HTTPS_PROXY= http://www.ik8s.io:10080"" under # for containers run by docker to access the image file Environment= "NO_PROXY=127.0.0.0/8172.20.0.0/16" 2 that needs to be loaded through the proxy. Download dependent images manually with the kubeadm config images listk8s.gcr.io/kube-apiserver:v1.13.1k8s.gcr.io/kube-controller-manager:v1.13.1k8s.gcr.io/kube-scheduler:v1.13.1k8s.gcr.io/kube-proxy:v1.13.1k8s.gcr.io/pause:3.1k8s.gcr.io/etcd:3.2.24k8s.gcr.io/coredns:1.2.6 download command docker pull docker.io/mirrorgooglecontainers/kube-apiserver : v1.13.1 download image docker tag docker.io/mirrorgooglecontainers/kube-apiserver:v1.13.1 k8s.gcr.io/kube-apiserver:v1.13.1 label image docker pull docker.io/mirrorgooglecontainers/kube-controller-manager:v1.13.1docker tag docker.io/mirrorgooglecontainers/kube-controller-manager:v1.13.1 k8s.gcr.io/kube-controller-manager:v1.13.1docker pull docker.io/mirrorgooglecontainers/kube-scheduler: V1.13.1docker tag docker.io/mirrorgooglecontainers/kube-scheduler:v1.13.1 k8s.gcr.io/kube-scheduler:v1.13.1docker pull docker.io/mirrorgooglecontainers/kube-proxy:v1.13.1docker tag docker.io/mirrorgooglecontainers/kube-proxy:v1.13.1 k8s.gcr.io/kube-proxy:v1.13.1docker pull docker.io/mirrorgooglecontainers/pause:3.1docker tag docker.io/mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1docker pull docker .io / mirrorgooglecontainers/etcd:3.2.24docker tag docker.io/mirrorgooglecontainers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24docker pull docker.io/coredns/coredns:1.2.6docker tag docker.io/coredns/coredns:1.2.6 k8s.gcr.iopool corednsvvl 1.2.6muri- -- initialize kubelet to edit the configuration file / etc/sysconfig/kubelet of kubelet Set it to ignore the state error enabled by Swap The content is as follows: KUBELET_EXTRA_ARGS= "--fail-swap-on=false" sets kubelet boot self-boot systemctl enable kubelet.service initialization kubeadm init-- kubernetes-version=v1.13.1-- pod-network-cidr=192.168.0.0/6-- service.cidr=192.168.1.0/12-- ignore-preflight-errors=Swap-- kubernetes-version=v1.11.1 # the K8s version to be initialized-- pod-network-cidr=10.244.0.0/16 # pod The network used-- the network address used by service.cidr=10.96.0.0/12 # service-- ignore-preflight-errors=Swap # double negates the subordinate exchange configuration. If there is an error error during initialization, then check what error it is. Generally, the error will be reported. The image tag tag error cannot be found. The image can be re-tagged when it indicates initial if you see the following. Your Kubernetes master has initialized successfully fulfilled to start using your cluster You need to run the following as a regular user: mkdir ~ / .kube # to create a .kube file will generally prompt you to create it with sudo permission. Here I directly use the root user to create sudo cp / etc/kubernetes/admin.conf ~ / .kube/ # copy admin.conf to. / kube file sudo chown $(id-u): $(id-g) $HOME/.kube/config # change the group owner of. / kube To create a user's generic group master You should now deploy a podnetwork to the cluster.Run "kubectl apply-f [podnetwork] .yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/You can now join any number of machines by running the following on each nodeas root:# adds node to the cluster with the following command (it is recommended to save the following command) kubeadm join 192.168.1.179podnetwork 6443-- token 5m7gg1 .czd5td6itn9g2fhz-- discovery-token-ca-cert-hash sha256:50c64cac88defae6beecf7bdde9b212094d7cc937b709b94f0baaeaaa4246e7e created by the root user: mkdir ~ / .kubecp / etc/kubernetes/admin.conf ~ / .kube / because if created by the root user, there is no need to reassign the group master kubectl get cs # View component health status kubectl get nodes # View node information NAME STATUS ROLES AGE VERSIONmaster NotReady master 19h v1.13.1 # the status is not open here because Here is a missing flannel plug-in installation flannel plug-in https://github.com/coreos/flannel # flannel address and help picture # if you want to use the installation, execute the following command to automatically install kubectl apply-f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml# and then check the node information NAME STATUS ROLES AGE VERSIONmaster Ready master 19h v1.13 after deployment . "View component status information (all pod components currently running by master) kubectl get pods-n kube-systemNAME READY STATUS RESTARTS AGEcoredns-86c58d9df4-4frfz 1 Running 0 19hcoredns-86c58d9df4-hlr72 1 19hkube 1 Running 0 19hetcd-master 1 Running 0 19hkube -apiserver-master 1 to 1 Running 0 19hkube-controller-manager-master 1 to 1 Running 0 19hkube-flannel-ds-amd64-4c7jx 1 to 1 Running 0 19hkube-flannel-ds-amd64-89m8l 1 to 1 Running 0 17hkube-flannel-ds-amd64-rmxj9 1 to 1 Running 0 19hkube-proxy-8pnqs 1 Running 0 17hkube-proxy-b4hlj 1 19h# 1 Running 0 19hkube-proxy-fzp2m 1 19h# 1 Running 0 19hkube-scheduler-master 1 19h# 1 Running 0 default if no namespace is specified, then the namespace kube-systemkubectl get nsNAME STATUS AGEdefault Active 19hkube-public Active 19hkube-system Active 19h# master node initialization completes node01 installation initialization

If you use the first method to let docker automatically download dependent images, then copy the docker.service file in master to node01.

Configure the k8s.repo in master and the yum repository of downloaded docker-ce. If an error is reported in the yum process, follow the method in master.

Yum install docker-ce kubelet kubeadm-Y1, enable docker service 2, set docker and kubelet settings to boot systemctl start docker.service # boot docker systemctl enable docker.service # set boot systemctl enable kubelet.service to manually download kube-proxy, Pause image and mark through download image configuration in master add the node01 node to the cluster with the just saved kubeadm job command kubeadm join 192.168.1.179kubeadm job 6443-- token 5m7gg1.czd5td6itn9g2fhz-- discovery-token-ca-cert-hash sha256:50c64cac88defae6beecf7bdde9b212094d7cc937b709b94f0baaeaaa4246e7e-- ignore-preflight-errors=Swap # add this sentence on the main node to check the kubectl get nodes, but whether you have joined the kubectl get nodesNAME STATUS ROLES AGE VERSIONmaster Ready master 20h v1.13.1node01 Ready 19h v1.13.1 # has joined # node02 does the same steps as node01 to join the cluster

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