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

Steps for installation and configuration of K8s

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

Share

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

This article mainly explains the "steps of installation and configuration of K8s". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the steps of installation and configuration of K8s.

1. Install docker

Operating system CentOS 7.x, Linux kernel version must be 3.10 or above

Yum-y update

Curl-fsSL https://get.docker.com | bash-s docker-- mirror Aliyun

Boot and start docker

Systemctl enable docker

two。 Configure docker domestic image acceleration

Modify the / etc/docker/daemon.json file. If you don't have it, you can go to Aliyun to apply for your own acceleration address.

The contents of the document are as follows:

{

"registry-mirrors": ["https://dockerhub.azk8s.cn"],"

"log-driver": "json-file"

"log-opts": {"max-size": "10m"}

}

3. Disable the firewall

Systemctl stop firewalld

Systemctl disable firewalld

4. Disable SELINUX

# vi / etc/selinux/config

SELINUX=disabled

5. Modify network parameter configuration

# vi / etc/sysctl.conf

Net.bridge.bridge-nf-call-ip6tables = 1

Net.bridge.bridge-nf-call-iptables = 1

Net.ipv4.ip_forward=1

6. Disable swap

# k8s 1.8 requires that Swap must be disabled. If it is not disabled, kubelet will not be able to start by default. #

Vi / etc/fstab

# Delete swap switching partition #

# / swap.img none swap sw 0 0

# then run #

Sudo swapoff-a

7. Add k8s Aliyun warehouse

# vi / etc/yum.repos.d/kubernetes.repo

[kubernetes]

Name=kubernetes

Baseurl= https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/

Enabled=1

Gpgcheck=1

Repo_gpgcheck=1

Gpgkey= https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

8. Install kubelet kubeadm kubectl

Yum clean all

Yum install-y kubelet kubeadm kubectl

Systemctl enable kubelet

9. Install k8s

Kubeadm init-image-repository gcr.azk8s.cn/google_containers-kubernetes-version v1.17.4-pod-network-cidr=192.168.0.0/16

10. Install the calico network plug-in

Wget https://docs.projectcalico.org/v3.10/manifests/calico.yaml

# you can modify 192.168.0.0 pod-network-cidr=192.168.0.0/16 16 in the file, which is consistent with the-pod-network-cidr=192.168.0.0/16 in the file #

Kubectl apply-f calico.yaml

11.master also acts as a node node

By default, clusters do not deploy pods on Master nodes for security reasons, and it is generally recommended to do so. If the servers are less clustered, they can be enabled. In a development environment, there may be only one Master node, and the command removes this restriction:

Kubectl taint nodes-all node-role.kubernetes.io/master-

# output #

Node/master untainted

# initialize the root environment variable. If you find that you cannot access APIServer (port 8080), then set up #

Export KUBECONFIG=/etc/kubernetes/admin.conf

# make the environment variable effective #

Source / root/.bash_profile

twelve。 Join the node node

Install kubelet kubeadm kubectl on the node node

Yum clean all

Yum install-y kubelet kubeadm kubectl

Systemctl enable kubelet

To add a worker node to the cluster, you need to do the following on each node worker node:

Kubeadm join:-token--discovery-token-ca-cert-hash sha256:

After the master installation is complete, a similar join command is output:

Kubeadm join 10.0.8.63 6443-token upwdcc.j90bhmkkwdklpm2f-discovery-token-ca-cert-hash sha256:7e79e6d0a6cda249479baf03103ebfa71398b69084537327f1a02a1a12d94481

If you forget to join the token of the Master node, you can view it using the following command:

Kubeadm token list

# # the default token validity period is 24 hours. If the token has expired, the following command will be generated again: # #

Kubeadm token create

# generate-- value of discovery-token-ca-cert-hash: #

Openssl x509-pubkey-in / etc/kubernetes/pki/ca.crt | openssl rsa-pubin-outform der 2 > / dev/null | openssl dgst-sha256-hex | sed's / ^. * /'

Thank you for your reading, the above is the content of "the steps of K8s installation and configuration". After the study of this article, I believe you have a deeper understanding of the steps of K8s installation and configuration, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

*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