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+dashboard cluster deployment under centos7-(2) k8s deployment

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

I. K8s deployment

1. Each node installs kubectl,kubelet,kubeadm, which needs to be installed through yum, so configure the yum source first.

Cat / etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetesbaseurl= https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=0repo_gpgcheck=0gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

two。 When installing k8s, you should pay attention to the version matching, otherwise you will be prompted when initializing that the kubeadm version and the kubernets version are not correct, either high or low, so check the next version after the installation is complete. It is best to install yum with the version number when installing.

Kubeadm version

Kubectl version

The output is as follows:

[root@localhost kubernetes] # kubeadm versionkubeadm version: & version.Info {Major: "1", Minor: "13", GitVersion: "v1.13.1", GitCommit: "eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState: "clean", BuildDate: "2018-12-13T10:36:44Z", GoVersion: "go1.11.2", Compiler: "gc", Platform: "linux/amd64"}

Boot and start, initialization must be enabled.

Systemctl enable kubelet.service

At the beginning of the installation, there is not much to say about the image download online, and now it will be renamed as follows:

K8s.gcr.io/kube-proxy v1.13.1 fdb321fd30a0 7 months ago 80.2MBk8s.gcr.io/kube-scheduler v1.13.1 ab81d7360408 7 months ago 79.6MBk8s.gcr.io/kube-apiserver v1.13.1 40a63db91ef8 7 months ago 181MBk8s.gcr.io/kube-controller -manager v1.13.1 26e6f1db2a52 7 months ago 146MBk8s.gcr.io/coredns 1.2.6 f59dcacceff4 9 months ago 40MBk8s.gcr.io/etcd 3.2.24 3cab8e1b9802 10 months ago 220MBk8s.gcr.io/pause 3.1 Da86e6ba6ca1 19 months ago 742kB

Then the master node performs initialization

Kubeadm init-kubernetes-version=v1.15.0-pod-network-cidr=10.244.0.0/16

Note that the version should match your own version, and the subsequent pod network segment should match the yaml when the fannel plug-in is installed.

After initialization, the following content is displayed: the things here are very important, and what the color indicates should be copied according to your own.

Your Kubernetes control-plane 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/Then you can join any number of worker nodes by running the following On each as root:kubeadm join 172.16.32.10 6443-token x8gdiq.sbcj8g4fmoocd5tl\-discovery-token-ca-cert-hash sha256:0b48e70fa8a268f8b88cd69b02cf87d8a2bf2efe519bb88dfa558de20d4a9993

Install the network plug-in fannel

Kubectl apply-f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml

* you should also pay attention to the version. There is an image version in the kube-fannel.yaml. At the same time, make sure that the IP address range in it is consistent with the initialization. Full running status.

[root@localhost kubernetes] # kubectl get pods-n kube-systemNAME READY STATUS RESTARTS AGEcoredns-86c58d9df4-jt4pd 1 + 1 Running 0 25hcoredns-86c58d9df4-m6bzt 1 + + 1 Running 0 25hetcd-localhost.localdomain 1 + 1 Running 0 25hkube-apiserver-localhost.localdomain 1/1 Running 0 25hkube-controller-manager-localhost.localdomain 1/1 Running 0 25hkube-flannel-ds-amd64-qfqr4 1/1 Running 20 24hkube-flannel-ds-amd64-xjk6v 1/1 Running 0 25hkube-proxy-p226l 1 Running 0 24hkube-proxy-qq4j4 1 5h38m 1 Running 0 25hkube-scheduler-localhost.localdomain 1 Running 0 25hkubernetes-dashboard-7d77666777-2l68j 1 Running 0 5h38m

Join from the node:

The slave node needs to install kube-proxy pause

Use the kubeadm join of the initialization result of master to join the primary node

Kubeadm join 172.16.32.10 6443-- token x8gdiq.sbcj8g4fmoocd5tl\

-- discovery-token-ca-cert-hash sha256:0b48e70fa8a268f8b88cd69b02cf87d8a2bf2efe519bb88dfa558de20d4a9993

Remember to copy admin.yaml from the master node after the slave node is added

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: 240

*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