Use Rancher's RKE to quickly deploy a Kubernetes Cluster

Source: Internet
Author: User
Tags pscp etcd k8s

Use Rancher's RKE to quickly deploy a Kubernetes Cluster

Brief description:

This article involves three Ubuntu machines, one RKE deployment machine (192.168.3.161), and two Kubernetes cluster machines (3.162 and 3.163 ).

First on a Windows machine, download the rke_linux-amd64 from github, rename it rke, edit the cluster. the yml cluster deployment file uses the pscp Command provided by putty to upload the file to machine 3.161. Run the rke command on machines 3.161 to deploy the cluster on machines 3.162 and 3.163.

As long as the Environment configuration is correct and the deployment is fast, the entire cluster can be completed within 5 minutes.

Preparations:

#1. Ubuntu 16.04.3 LTS + Docker 1.12.6 system installation and basic network settings

#2. Add common users to the Docker group. (Sudo reboot restarts the machine to take effect)

Sudo usermod-aG docker catty

Sudo reboot

#3. Enable cgroup memory and Swap quota, modify/etc/default/grub configuration file, and add two items:

GRUB_CMDLINE_LINUX_DEFAULT = "cgroup_enable = memory swapaccount = 1"

GRUB_CMDLINE_LINUX = "cgroup_enable = memory swapaccount = 1"

# Update grub. It takes effect after the system is restarted.

Sudo update-grub

Sudo reboot

#4. permanently disable swap partitions, directly modify the/etc/fstab file, and comment out swap items

Sudo vi/etc/fstab

#5. Modify the/etc/hosts host name file and set 127.0.0.1 localhost Host Name

#6. Disable SELinux. Ubuntu is not installed by default and does not need to be set.

# * Install The selinux toolkit and use the getenforce tool to view the SELinux status.

Sudo apt install selinux-utils

Sudo getenforce

#7. Enable ipv4 forwarding. Ubuntu is enabled by default and does not need to be set.

# Check the Kernel Parameter file/proc/sys/net/ipv4/ip_forward. The value is 1, indicating that the kernel is enabled.

# You can also forcibly specify net. ipv4.ip _ forward = 1 in the/etc/sysctl. conf configuration file. The restart takes effect.

#8. Disable the ufw firewall. Ubuntu is disabled by default and does not need to be set. Manually disable UFW:

Sudo ufw disable

#9. Use the deployment user in the configuration file to establish an ssh one-way channel. log on to the Kubernetes Cluster machine on the machine where RKE is located and create one-way password-free login (that is, the channel)

Catty@192.168.3.161: ssh-keygen # Press enter three times to generate an ssh public key and private key file

Catty@192.168.3.161: ssh-copy-id catty@192.168.3.162 # distribute public keys to 162 machines

Catty@192.168.3.161: ssh-copy-id catty@192.168.3.163 # distribute public keys to 163 machines

# Note: Do not use sudo ssh-copy-id. This will change to a root user logon.

# Verify whether password-free logon is allowed:

Catty@192.168.3.161: ssh 192.168.3.162

Exit

Catty@192.168.3.161: ssh 192.168.3.163

Exit

#10. Modify the cluster. ym cluster deployment configuration file to avoid using the gcr. io image. The available files are attached

Installation and deployment:

#11. Download The rke tool and use the pscp command of putty to copy it to the/home/catty directory of machine 161,

# Put the RKE program and cluster. yml configuration file to the putty directory on the Windows machine:

Pscp rke 192.168.3.161:/home/catty

Pscp cluster. yml 192.168.3.161:/home/catty

# To the/home/catty directory of 161, add the executable permission for the RKE file,

Chmod + x rke

# Everything is ready. Run the deployment command on machine 161.

./Rke up -- config cluster. yml

# End.

Available configuration file cluster. yml:

---

Auth:

Strategy: x509

Options:

Foo: bar

# Supported plugins are:

# Flannel

# Calico

# Canal

# Weave

#

# If you are using calico on AWS, use the network plugin config option:

# 'Cloud _ provider: aws'

Network:

Plugin: flannel

Options:

Flannel_image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/flannel

Flannel_cni_image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/flannel-cni

Nodes:

-Address: 192.168.3.162

User: catty

Role: [controlplane, etcd]

Ssh_key_path :~ /. Ssh/id_rsa

-Address: 192.168.3.163

User: catty

Role: [worker]

Ssh_key_path :~ /. Ssh/id_rsa

#-Address: 192.168.3.164

# User: catty

# Role: [worker]

# Ssh_key_path :~ /. Ssh/id_rsa

Services:

Etcd:

Image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/etcd:latest

Kube-api:

Image: rancher/k8s: v1.8.3-rancher2

Service_cluster_ip_range: 10.233.0.0/18

Pod_security_policy: false

Extra_args:

V: 4

Kube-controller:

Image: rancher/k8s: v1.8.3-rancher2

Cluster_cidr: 10.233.64.0/18

Service_cluster_ip_range: 10.233.0.0/18

Scheduler:

Image: rancher/k8s: v1.8.3-rancher2

Kubelet:

Image: rancher/k8s: v1.8.3-rancher2

Cluster_domain: cluster. local

Cluster_dns_server: 10.233.0.3

Infra_container_image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/pause-amd64:3.0

Command: -- fail-swap-on = false

Kubeproxy:

Image: rancher/k8s: v1.8.3-rancher2

System_images:

Alpine: latest

Nginx_proxy: rancher/rke-nginx-proxy: 0.1.0

Cert_downloader: rancher/rke-cert-deployer: 0.1.0

Kubedns_image: bytes

Dnsmasq_image: empty

Kubedns_sidecar_image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/k8s-dns-sidecar-amd64:1.14.5

Kubedns_autoscaler_image: resize

# All addon manifests MUST specify a namespace

Addons: |-

---

ApiVersion: v1

Kind: Pod

Metadata:

Name: my-nginx

Namespace: default

Spec:

Containers:

-Name: my-nginx

Image: nginx

Ports:

-ContainerPort: 80

Run:

01-run the rke command to deploy Kubernetes cluster 1

02-run the rke command to deploy Kubernetes Cluster 2

03-run the rke command to deploy the Kubernetes cluster 3

04-run the rke command to deploy the Kubernetes cluster 4

04-execute rkecommand and deploy kubernetescluster 4.jpg

RKE Introduction

Https://github.com/rancher/rke

RKE tool Download Page

Https://github.com/rancher/rke/releases/

RKE cluster. yml file description

Https://github.com/rancher/rke/blob/master/cluster.yml

This article permanently updates link: https://www.bkjia.com/Linux/2018-02/151014.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.