Quickly deploy kubernetes clusters using Rancher's Rke

Source: Internet
Author: User
Tags pscp etcd k8s

Brief description:

This article covers 3 Ubuntu machines, 1 Rke deployment Machines (192.168.3.161), 2 kubernetes cluster machines (3.162 and 3.163).

On the Windows machine, download the rke_linux-amd64 from GitHub, rename it to Rke, edit the cluster.yml cluster deployment file, and upload the file to the 3.161 machine using the PSCP command provided by Putty. On the 3.161 machine, execute the rke command to deploy the cluster to the 3.162 and 3.163 machines.

As long as the environment is properly configured, deployment is fast and the entire cluster is 5 minutes away.

Preparatory work:

# 1, Ubuntu 16.04.3 LTS + Docker 1.12.6 system installation, network infrastructure settings

# 2. Add a normal user 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 limits, modify/etc/default/grub profile, modify/Add two items:

grub_cmdline_linux_default= "Cgroup_enable=memory swapaccount=1"

grub_cmdline_linux= "Cgroup_enable=memory swapaccount=1"

# Update grub, take effect after rebooting system

sudo update-grub

sudo reboot

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

sudo vi/etc/fstab

# 5, modify/etc/hosts hostname file, set 127.0.0.1 localhost hostname

# 6, disable Selinux,ubuntu default is not installed, do not need to set.

# * You can install the SELinux Toolkit first and then 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.

# You can view the kernel parameter file/proc/sys/net/ipv4/ip_forword with a value of 1, which means enable.

# You can also force the net.ipv4.ip_forward=1 to be specified in the/etc/sysctl.conf configuration file, and the restart will take effect.

# 8, turn off UFW firewall, Ubuntu is not enabled by default, do not need to set. Manual shutdown UFW:

sudo ufw disable

# 9, using the deployment user in the configuration file, establish an SSH one-way channel, in the Rke machine to the Kubernetes cluster machine, establish a one-way password-free login (that is, the channel)

[Email protected]: Ssh-keygen #三次回车, generate SSH public key and private key file

[Email protected]: Ssh-copy-id [email protected] #将公钥分发给162机器

[Email protected]: Ssh-copy-id [email protected] #将公钥分发给163机器

Note: Do not use sudo ssh-copy-id, this will become the root user login.

# Verify that you can log on directly without a secret:

[Email protected]: SSH 192.168.3.162

Exit

[Email protected]: SSH 192.168.3.163

Exit

# 10, modify the Cluster.ym cluster deployment configuration file, avoid using Gcr.io image, the available files are attached

Installation deployment:

# 11, the Rke tool download down, through the Putty PSCP command, copied to the 161 machine/home/catty directory,

# Place the Rke program and the CLUSTER.YML configuration file in 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 161 of the/home/catty directory, increase the executable permissions of the Rke file,

chmod +x Rke

# Everything's ready, on 161 machines, execute deployment commands

./rke up--config cluster.yml

End

Available configuration Files Cluster.yml:

---

Auth

strategy:x509

Options

Foo:bar

# Supported plugins is:

# flannel

# calico

# Canal

# weave

#

# If you is 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:alpine:latest

nginx_proxy:rancher/rke-nginx-proxy:0.1.0

cert_downloader:rancher/rke-cert-deployer:0.1.0

kubedns_image:registry.cn-shenzhen.aliyuncs.com/rancher_cn/k8s-dns-kube-dns-amd64:1.14.5

dnsmasq_image:registry.cn-shenzhen.aliyuncs.com/rancher_cn/k8s-dns-dnsmasq-nanny-amd64:1.14.5

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

kubedns_autoscaler_image:registry.cn-shenzhen.aliyuncs.com/rancher_cn/cluster-proportional-autoscaler-amd64:1.0.0

# 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-Execute Rke Command, deploy kubernetes cluster 1

02-Execute Rke Command, deploy kubernetes cluster 2

03-Execute Rke command, deploy kubernetes cluster 3

04-Execute Rke command, deploy kubernetes cluster 4

Reference Links:

Kubernetes Essentials for Rke deployment with rancher

http://blog.csdn.net/csdn_duomaomao/article/details/79317846

Rke Quick Start Guide: Open source Lightweight k8s Installer

https://www.cnrancher.com/an-introduction-to-rke/

Free Video Training: How to install using Rke

http://www.itdks.com/liveevent/detail/8343

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

Quickly deploy kubernetes clusters using Rancher's Rke

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.