preface
The previous articles were mostly about how to use K8S, and did not talk much about k8S cluster installation. This article is arranged, and it does not use the official installation method, but Rancher.
Rancher is an open source software platform that enables organizations to run and manage Docker and Kubernetes in production. With Rancher, organizations no longer need to build container service platforms from scratch using a unique set of open source technologies. Rancher provides the entire software stack needed to manage containers in production.
The environment
The host name | ip | role |
---|---|---|
mldong01 | 192.168.0.245 | master |
mldong02 | 192.168.0.54 | node01 |
mldong03 | 192.168.0.22 | node02 |
Three hosts are HUAWEI ECS, CentOS Linux release 7.6.1810 (Core)
Install the docker
Slightly, can refer to the previous article installation.
Docker version is 19.03.11
All three nodes are installed
Run Rancher through Docker
The current version is the latest: V2.4.8
Master Node Installation
sudo docker run --privileged -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
rancher/rancher:latest
Copy the code
Browser access (public IP address) :
https://192.168.0.245
Keep going.
Set the admin password and agree to the protocol
Successful installation
Let’s set the language
Start adding a K8S cluster using Rancher
- The top right corner
Add the cluster
- Select Custom
- Enter a cluster name and select
V1.18.8 rancher1-1
, other default first, next step
- Configure the command based on the server situation, and then copy the command to the SSH terminal of the host
- Total three nodes
master
,node01
,node02
Obtain commands to execute separately.
The installation process takes a long time. You can view the installation progress by clicking the host
Installation successful!
validation
The following operations are performed on the master
-
Add kubernetes’ yum source
cat >> /etc/yum.repos.d/kubernetes.repo <<EOF [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=0 EOF Copy the code
-
Install kubectl
yum install -y kubectl
Copy the code
- Cluster ->Kubeconfig file -> Copy to clipboard
[root@mldong01 ~] vi /root/.kube/config
Copy the code
Publish a service on Rancher
-
Add a project
A project is a concept in Rancher that can be understood as a directory.
-
Add a namespace
This is the same as the k8S namespace
-
Into the project
-
Deploying a service
-
Viewing host Ports
-
Go to Huawei cloud console to open port permissions, move the mouse up, and see the corresponding server IP address in the lower left corner
-
Of course, direct access to the port is definitely not friendly, so we add a DNS resolution record, resolve to the above IP, and then configure load balancing
-
Browser access
summary
The whole article does not involve the tedious installation steps of K8S, Rancher tool has helped us to do, really save a lot of trouble. If I have free time, I will use Rancher to publish a complete service – article.
Related articles
Walk you through K8S – cluster creation and Hello World
Take you through K8S-ConfigMap and persistent storage
Take you hand in hand to play K8S – complete release of an externally accessible service
Docker-compose k8S-docker advanced Dockerfile and docker-compose
K8s – One click deployment of springboot project
Take you through k8S – One-click deployment of VUE projects
Take you hand in hand to play K8S – common object details
Walk you through k8S-Jenkins installation and assembly line
Walk you through k8S-Jenkins assembly line grammar
Take you hand in hand through the K8S-Jenkins assembly line to launch springboot project
Take you through the K8S-Jenkins assembly line to launch vUE projects
Walk you through k8S – health check survival probe and readiness probe
K8s-win10 build A K8S cluster
K8s-win10 k8S build on the development environment services