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 build Kubernetes Cluster

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

Share

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

In this issue, the editor will bring you about how to build a Kubernetes cluster. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Yum installation requires components, I specified a specific version here, I use the version is relatively old, but if you are the first time to use, the problem is not very big, if you are the boss, then do not spray me ~ ~ install

Yum-y install kubeadm-1.11.1 yum-y install kubectl-1.11.1 yum-y install kubelet-1.11.1 yum-y install kubernetes-cni-0.6.0yum-y install docker-ce-17.03.0.ce-1.el7.centos

Set up docker startup

Systemctl enable dockersystemctl start dockersystemctl enable kubelet.servicesystemctl start kubelet

Here is the more difficult part, the online processing methods are more or less the same here to write down what I use.

Kubernetes belongs to Google, and his image is hosted on Google Cloud. Domestic downloads are rather rough. Go to this address to download the https://github.com/anjia0532/gcr.io_mirror script here.

Vim pullimages.sh # A specific version is specified here. If you are not in this version, you need to modify the script ~ #! / bin/bashimages= (kube-proxy-amd64:v1.11.1 kube-scheduler-amd64:v1.11.1 kube-controller-manager-amd64:v1.11.1kube-apiserver-amd64:v1.11.1 etcd-amd64:3.2.18 coredns:1.1.3 pause:3.1) for imageName in ${images [@]} Dodocker pull anjia0532/google-containers.$imageNamedocker tag anjia0532/google-containers.$imageName k8s.gcr.io/$imageNamedocker rmi anjia0532/google-containers.$imageNamedone

In fact, kubeadm can deploy Master nodes with one click, but in order to show you how to build a cluster, I wrote a kubeadm.yaml here.

ApiVersion: kubeadm.k8s.io/v1alpha1kind: MasterConfigurationcontrollerManagerExtraArgs: horizontal-pod-autoscaler-use-rest-clients: "true" horizontal-pod-autoscaler-sync-period: "10s" node-monitor-grace-period: "10s" apiServerExtraArgs: runtime-config: "api/all=true" kubernetesVersion: "v1.11.1"

Horizontal-pod-autoscaler-use-rest-clients: "true" is used here, which means that future deployments of kube-controlller-manger can be automatically scaled horizontally using custom resources.

Deploy kunernetes Master nodes

Kubeadm init-config kubeadm.yaml

A long string of code will be generated here, and I will excerpt some of it here for your reference.

[init] using Kubernetes version: v1.11.1 [preflight] running pre-flight checks...Your Kubernetes master has initialized successfully!To start using your cluster You need to run the following as a regular user: mkdir-p $HOME/.kube sudo cp-I / etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id-u): $(id-g) $HOME/.kube/configYou 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: kubeadm join 192.168.72.132 token q1nck1.4znr09ayrj6xpsdw 6443-- discovery-token-ca-cert-hash sha256:095e199243fad6ee350beb9869942f54ee4074cd5bcef1222a2cca712b8b4878

This kubeadm join command is to add a working node to the Master node. Of course, I can't use a single node here, but I still want to explain it to you, as long as you know it.

Configure the directory where the security configuration file is stored, which is mentioned in the above code. You can take a closer look at it.

Mkdir-p $HOME/.kubecp-I / etc/kubernetes/admin.conf $HOME/.kube/configchown $(id-u): $(id-g) $HOME/.kube/config

Why are you writing this? The reason is that the kubernetes cluster needs encrypted access by default. The purpose of these commands is to place the configuration file of the newly deployed cluster in the current user's .kube directory. Kubectl accesses the kubernetes cluster using the authorization information in this directory by default.

View node status

[root@localhost yum.repos.d] # kubectl get nodesNAME STATUS ROLES AGE VERSIONlocalhost.localdomain NotReady master 6m v1.11.1

The status of my deployment here is NotReady because I do not have network components installed

Install the network plug-in

Kubectl apply-f https://git.io/weave-kube-1.6

After deployment, we can re-check the Pod status via kubectl.

[root@localhost yum.repos.d] # kubectl get pods-n kube-systemNAME READY STATUS RESTARTS AGEcoredns-78fcdf6894-8w8dx 1 Running 0 11mcoredns-78fcdf6894-w9sk2 1 Running 0 11metcd-localhost .localdomain 1/1 Running 0 10mkube-apiserver-localhost.localdomain 1/1 Running 0 10mkube-controller-manager-localhost.localdomain 1/1 Running 0 10mkube-proxy-cpxmx 1/1 Running 0 11mkube-scheduler-localhost.localdomain 1/1 Running 0 10mweave-net-pt2l7 2/2 Running 0 23s

Here you can see that all the Pod I deployed have started successfully, and if you can see these, congratulations, so far the deployment of the kubernetes Master node is complete.

The above is the editor for you to share how to build a Kubernetes cluster, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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