Home Operation and Maintenance Docker k8s installation and deployment steps

k8s installation and deployment steps

Jun 09, 2020 am 09:48 AM
docker

k8s installation and deployment steps

k8s installation and deployment steps

Preparation environment: three centos7 servers

192.168.6.129 k8s-master (master)

192.168.6.130 k8s-node-1 (node)

192.168.6.131 k8s-node-2 (node)

kubernetes (k8s) installation methods

Five methods:

  • kubernetes binary installation (the most tedious configuration, no less than installing openstack)

  • kubeadm installation (automated installation tool launched by Google, network requirements apply)

  • minikube installation (only used to experience k8s)

  • yum installation (the simplest, the version is relatively low====This method is recommended for learning)

  • go compile and install (the most difficult)

We use yum to install, and learning how to use k8s is the key.

1. Modify the host and host resolution

#Please perform the following operations on the three machines 129-130-131

vim /etc/ hosts:

192.168.6.129 k8s-master
192.168.6.130 k8s-node-1
192.168.6.131 k8s-node-2
Copy after login

Modify the host name:

hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node-1
hostnamectl set-hostname k8s-node-2
Copy after login

2: Install docker version 1.12. The 1.13 that comes with the system has a small bug and needs to be modified, otherwise the subsequent container network communication will be blocked

[root@k8s-master ~]# yum provides docker
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
2:docker-1.13.1-102.git7f2769b.el7.centos.x86_64 : Automates deployment of
: containerized applicat
Repo : extras
2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64 : Automates deployment of
: containerized applications
Repo : extras
[root@k8s-master ~]#
Copy after login

Go to the official website to find version 1.12 docker

http://vault.centos.org/7.4.1708/extras/x86_64/Packages/

Need to install CentOS-Base.repo source in advance

All three machines need to download these three docker packages:

##http: //vault.centos.org/7.4.1708/extras/x86_64/Packages/docker-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm

http://vault.centos.org/7.4.1708/extras/x86_64/Packages/docker-client-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm

http://vault.centos.org/7.4.1708/extras/x86_64/Packages/docker-common-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm

[root@k8s-master ~]# ls
docker-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm
docker-client-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm
docker-common-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm
[root@k8s-master ~]# scp * 192.168.6.130:~
root@192.168.6.130's password:
docker-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm 100% 15MB 30.7MB/s 00:00
docker-client-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm 100% 3451KB 29.6MB/s 00:00
docker-common-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm 100% 83KB 6.9MB/s 00:00
[root@k8s-master ~]# scp * 192.168.6.131:~
root@192.168.6.131's password:
docker-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm 100% 15MB 24.2MB/s 00:00
docker-client-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm 100% 3451KB 23.3MB/s 00:00
docker-common-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm 100% 83KB 5.8MB/s 00:00
[root@k8s-master ~]#
Copy after login

Uninstall docker that has been installed on the system

Since the author has previously installed the docker-ce version, it needs to be completely uninstalled (it is recommended that you use a new machine to install)

[root@k8s-node-1 ~]# rpm -qa |grep docker
docker-ce-19.03.3-3.el7.x86_64
docker-ce-cli-19.03.3-3.el7.x86_64
[root@k8s-node-1 ~]# rpm -e docker-ce-19.03.3-3.el7.x86_64
[root@k8s-node-1 ~]# rpm -e docker-ce-cli-19.03.3-3.el7.x86_642
[root@k8s-node-1 ~]# rm -rf /var/lib/docker/* 清空之前docker产生的所有文件。
[root@k8s-node-1 ~]# rm -rf /etc/docker/*
Copy after login

3. Install docker 1.12 on all three machines (must be installed in the following order, otherwise an error may be reported)

yum localinstall docker-common-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm -y
yum localinstall docker-client-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm -y
yum localinstall docker-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm -y
Copy after login

4. Verify whether docker is installed successfully

[root@k8s-master ~]# docker -v
Docker version 1.12.6, build 3e8e77d/1.12.6
Copy after login

5. The master node installs etcd (k8s database kv type storage) natively supports clustering

[root@k8s-master ~]# yum install etcd.x86_64 -y
[root@k8s-master ~]# vim /etc/etcd/etcd.conf
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.6.129:2379"
#启动
[root@k8s-master ~]# systemctl start etcd.service
[root@k8s-master ~]# systemctl enable etcd.service
#测试
#set 设置一队键值 数据存储
[root@k8s-master ~]# etcdctl set testdir/testkey0 xujin
Xujin
#get获取
[root@k8s-master ~]# etcdctl get testdir/testkey0
xujin
[root@k8s-master ~]#
#检测集群状态
[root@k8s-master ~]# etcdctl -C http://192.168.6.129:2379 cluster-health
member 8e9e05c52164694d is healthy: got healthy result from http://192.168.6.129:2379
cluster is healthy
[root@k8s-master ~]#
Copy after login

6. The master node installs kubernetes

[root@k8s-master ~]# yum install kubernetes-master.x86_64 -y
#修改配置文件如下
[root@k8s-master ~]# vim /etc/kubernetes/apiserver
# The address on the local server to listen to.
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
# The port on the local server to listen on.
KUBE_API_PORT="--port=8080"
# Port minions listen on
KUBELET_PORT="--kubelet-port=10250"
# Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.6.129:2379"
# default admission control policies
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,Securi
tyContextDeny,ResourceQuota"
#修改config文件
[root@k8s-master ~]# vim /etc/kubernetes/config
KUBE_MASTER="--master=http://192.168.6.129:8080"
Copy after login

7. Start k8s

# 启动kube-apiserver
#这个服务用来:接受并响应用户的请求
[root@k8s-master ~]# systemctl enable kube-apiserver.service
[root@k8s-master ~]# systemctl start kube-apiserver.service
#启动 kube-controller-manager
#控制管理器的概念,保证容器存活
#每隔一段时间去扫描容器状态,看有没有死了。
#容器死了,会调度apiserver再起一个新的容器
#保证容器的个数,比如我们设定起三个nginx容器,多了就会杀掉,少了就会起
[root@k8s-master ~]# systemctl enable kube-controller-manager.service
[root@k8s-master ~]# systemctl start kube-controller-manager.service
#启动kube-scheduler
#调度器,选择启动容器的node节点,通俗点就是容器在哪一个节点服务器上面创建
[root@k8s-master ~]# systemctl enable kube-scheduler.service
[root@k8s-master ~]# systemctl start kube-scheduler.service
Copy after login
Now the master 129 k8s is installed.

Recommended tutorial: "

PHP"

The above is the detailed content of k8s installation and deployment steps. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to change the docker image source in China How to change the docker image source in China Apr 15, 2025 am 11:30 AM

You can switch to the domestic mirror source. The steps are as follows: 1. Edit the configuration file /etc/docker/daemon.json and add the mirror source address; 2. After saving and exiting, restart the Docker service sudo systemctl restart docker to improve the image download speed and stability.

How to use docker desktop How to use docker desktop Apr 15, 2025 am 11:45 AM

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

How to read the docker version How to read the docker version Apr 15, 2025 am 11:51 AM

To get the Docker version, you can perform the following steps: Run the Docker command "docker --version" to view the client and server versions. For Mac or Windows, you can also view version information through the Version tab of the Docker Desktop GUI or the About Docker Desktop menu.

How to create a mirror in docker How to create a mirror in docker Apr 15, 2025 am 11:27 AM

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

How to call docker lnmp How to call docker lnmp Apr 15, 2025 am 11:15 AM

Docker LNMP container call steps: Run the container: docker run -d --name lnmp-container -p 80:80 -p 443:443 lnmp-stack to get the container IP: docker inspect lnmp-container | grep IPAddress access website: http://<Container IP>/index.phpSSH access: docker exec -it lnmp-container bash access MySQL: mysql -u roo

How to save docker image How to save docker image Apr 15, 2025 am 11:54 AM

To save the image in Docker, you can use the docker commit command to create a new image, containing the current state of the specified container, syntax: docker commit [Options] Container ID Image name. To save the image to the repository, you can use the docker push command, syntax: docker push image name [: tag]. To import saved images, you can use the docker pull command, syntax: docker pull image name [: tag].

How to update the image of docker How to update the image of docker Apr 15, 2025 pm 12:03 PM

The steps to update a Docker image are as follows: Pull the latest image tag New image Delete the old image for a specific tag (optional) Restart the container (if needed)

How to build a private repository by docker How to build a private repository by docker Apr 15, 2025 am 11:06 AM

You can build Docker private repositories to securely store and manage container images, providing strict control and security. The steps include: creating a repository, granting access, deploying a repository, pushing an image, and pulling an image. Advantages include security, version control, reduced network traffic and customization.

See all articles