使用rke快速安裝K8s集群


操作系統

centos 7.5 

yum update -y

yum install docker -y

關閉防火牆、selinux

下載rke helm 

https://github.com/helm/helm/releases

 

helm init --client-only --stable-repo-url https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/
helm repo add incubator https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
helm repo update

RKE安裝

https://github.com/rancher/rke

下載二進制包

編輯yml文件https://rancher.com/docs/rancher/v2.x/en/installation/ha/kubernetes-rke/,注意縮進

[root@rancher-m-82-106-14 home]# cat rancher-cluster.yml
nodes:
- address: 10.82.106.14
user: rancher
role: [controlplane,worker,etcd]
ssh_key_path: ~/.ssh/id_rsa
- address: 10.82.106.18
user: rancher
role: [controlplane,worker,etcd]
ssh_key_path: ~/.ssh/id_rsa
- address: 10.82.106.19
user: rancher
role: [controlplane,worker,etcd]
ssh_key_path: ~/.ssh/id_rsa

services:
etcd:
snapshot: true
creation: 6h
retention: 24h

注意,要增加一個普通用戶

 useradd rancher
 passwd rancher
 usermod -aG dockerroot rancher
 service docker restart
 chmod a+rw /var/run/docker.sock

免密登錄。
 ssh-copy-id rancher@10.82.106.14
ssh 10.82.106.18
 ssh-copy-id rancher@10.82.106.18
 ssh-copy-id rancher@10.82.106.19
 ssh rancher@10.82.106.19

注意YML文件中的用戶指建立的用戶

./rke0.2.0 up --config ./rancher-cluster.yml

運行后:

把kube_config_rancher-cluster.yml文件復制為

~/.kube/config

測試kubctl version 

增加YUM庫

[root@rancher-m-82-106-14 yum.repos.d]# cat kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

 

yum -y install kubelet kubeadm kubectl

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM