码迷,mamicode.com
首页 > 其他好文 > 详细

使用RKE快速部署k8s集群

时间:2021-06-02 12:19:37      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:nts   you   --   native   内容   pull   list   emctl   require   

目标

安全
稳定
廉价
快速
容灾
扩展

服务器

基础数据

腾讯云 2核 8GB 5Mbps

安全组配置

开放80、443,允许全部ip访问
开放22、6443,开放当前ip访问

技术图片

环境

# 卸载firewalld,由安全组统一管理端口
sudo dnf remove firewalld
# 关闭交换分区
sudo swapoff -a
# 使用iptables处理ipv4桥接数据
sudo sysctl net.bridge.bridge-nf-call-iptables=1
# 添加docker阿里云源
sudo dnf config-manager --add-repo  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 查看docker版本
sudo dnf list docker-ce --showduplicates | sort -r
# 安装docker
dnf install docker-ce-20.10.6-3.el8
# 配置docker

## 使用systemd管理cgroup
## 腾讯云加速docker镜像下载
## 限制日志文件大小为100m
## 采用overlay2存储驱动
sudo mkdir /etc/docker
cat <<EOF | sudo tee /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "registry-mirrors": [
    "https://mirror.ccs.tencentyun.com"
  ],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF
## 开机运行并重启docker
sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker

用户

# 添加rke用户
sudo useradd -m rke
# 本地生成rke用户密钥对
ssh-keygen -t rsa
# 在本地将公钥传输到云服务器
# 具体可以参见参考内容中“密钥管理”一节
ssh-copy-id -i ~/.ssh/id_rsa.pub rke@yunfuwuqi
# 将rke添加到docker用户组
sudo usermod -aG docker rke

安装

下载RKE

下载地址:
https://github.com/rancher/rke/releases
支持版本:
macOS:rke_darwin-amd64
Linux (Intel/AMD):rke_linux-amd64
Linux (ARM 32-bit):rke_linux-arm
Linux (ARM 64-bit):rke_linux-arm64
Windows (32-bit):rke_windows-386.exe
Windows (64-bit):rke_windows-amd64.exe

生成集群配置

# 在当前路径下创建cluster.yml配置文件
rke config

官方配置示例:
https://docs.rancher.cn/docs/rke/example-yamls/_index

单节点配置:

# If you intened to deploy Kubernetes in an air-gapped environment,
# please consult the documentation on how to configure custom RKE images.
nodes:
- address: "140.143.250.154"
  port: "22"
  # 内网ip
  internal_address: "172.21.3.9"
  # 全角色
  role:
  - controlplane
  - worker
  - etcd
  # 不覆盖hostname
  hostname_override: ""
  # 用户名
  user: rke
# 全局ssh key
ssh_key_path: ./id_rsa_rke
ssh_cert_path: ""
ssh_agent_auth: false
services:
  etcd:
    # 集群数据备份
    backup_config:
      # 创建快照的间隔时间,单位小时,12表示每12个小时创建一个快照
      interval_hours: 1
      # 快照的存活时间,单位小时
      retention: 48
  kube-api:
    service_cluster_ip_range: 10.43.0.0/16
    service_node_port_range: "30000-32767"
    pod_security_policy: false
    always_pull_images: false
    extra_args:
      # 审计日志
      audit-log-path: "-"
  kube-controller:
    cluster_cidr: 10.42.0.0/16
    service_cluster_ip_range: 10.43.0.0/16
  scheduler:
  kubelet:
    cluster_domain: k8s.qcloud
    cluster_dns_server: 10.43.0.10
    # 如果存在交换分区则报错
    fail_swap_on: false
    generate_serving_certificate: false
    # 最大pod数
    extra_args:
      max-pods: 250
    # 挂载本地磁盘
    extra_binds:
    - "/home/rke/data:/home/rke/data"
  kubeproxy:
network:
  plugin: canal
authentication:
  strategy: x509
  sans: []
  webhook: null
addons: ""
addons_include: []
system_images:
  etcd: rancher/mirrored-coreos-etcd:v3.4.15-rancher1
  alpine: rancher/rke-tools:v0.1.74
  nginx_proxy: rancher/rke-tools:v0.1.74
  cert_downloader: rancher/rke-tools:v0.1.74
  kubernetes_services_sidecar: rancher/rke-tools:v0.1.74
  kubedns: rancher/mirrored-k8s-dns-kube-dns:1.15.10
  dnsmasq: rancher/mirrored-k8s-dns-dnsmasq-nanny:1.15.10
  kubedns_sidecar: rancher/mirrored-k8s-dns-sidecar:1.15.10
  kubedns_autoscaler: rancher/mirrored-cluster-proportional-autoscaler:1.8.1
  coredns: rancher/mirrored-coredns-coredns:1.8.0
  coredns_autoscaler: rancher/mirrored-cluster-proportional-autoscaler:1.8.1
  nodelocal: rancher/mirrored-k8s-dns-node-cache:1.15.13
  kubernetes: rancher/hyperkube:v1.20.6-rancher1
  flannel: rancher/coreos-flannel:v0.13.0-rancher1
  flannel_cni: rancher/flannel-cni:v0.3.0-rancher6
  calico_node: rancher/mirrored-calico-node:v3.17.2
  calico_cni: rancher/mirrored-calico-cni:v3.17.2
  calico_controllers: rancher/mirrored-calico-kube-controllers:v3.17.2
  calico_ctl: rancher/mirrored-calico-ctl:v3.17.2
  calico_flexvol: rancher/mirrored-calico-pod2daemon-flexvol:v3.17.2
  canal_node: rancher/mirrored-calico-node:v3.17.2
  canal_cni: rancher/mirrored-calico-cni:v3.17.2
  canal_controllers: rancher/mirrored-calico-kube-controllers:v3.17.2
  canal_flannel: rancher/coreos-flannel:v0.13.0-rancher1
  canal_flexvol: rancher/mirrored-calico-pod2daemon-flexvol:v3.17.2
  weave_node: weaveworks/weave-kube:2.8.1
  weave_cni: weaveworks/weave-npc:2.8.1
  pod_infra_container: rancher/mirrored-pause:3.2
  ingress: rancher/nginx-ingress-controller:nginx-0.43.0-rancher3
  ingress_backend: rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1
  metrics_server: rancher/mirrored-metrics-server:v0.4.1
  windows_pod_infra_container: rancher/kubelet-pause:v0.1.6
  aci_cni_deploy_container: noiro/cnideploy:5.1.1.0.1ae238a
  aci_host_container: noiro/aci-containers-host:5.1.1.0.1ae238a
  aci_opflex_container: noiro/opflex:5.1.1.0.1ae238a
  aci_mcast_container: noiro/opflex:5.1.1.0.1ae238a
  aci_ovs_container: noiro/openvswitch:5.1.1.0.1ae238a
  aci_controller_container: noiro/aci-containers-controller:5.1.1.0.1ae238a
  aci_gbp_server_container: noiro/gbp-server:5.1.1.0.1ae238a
  aci_opflex_server_container: noiro/opflex-server:5.1.1.0.1ae238a
authorization:
  mode: rbac
  options: {}
ignore_docker_version: null
kubernetes_version: ""
private_registries: []
# 不使用ingress
ingress:
  provider: "none"
addon_job_timeout: 0
bastion_host:
monitoring:
restore:
  restore: false
  snapshot_name: ""
rotate_encryption_key: false
dns: null

安装

rke up

查看集群状况

./kube-explorer-linux-amd64  --kubeconfig=kube_config_cluster.yml --http-listen-port=9898 --https-listen-port=0

技术图片

参考

Docekr版本选择
https://github.com/kubernetes/kubernetes/blob/master/build/dependencies.yaml
使用iptables处理ipv4桥接数据
https://www.ibm.com/docs/en/fci/1.0.2?topic=SSCKRH_1.0.2/platform/r_software_requirements_fci_kubernetes.html
密钥管理
https://upcloud.com/community/tutorials/use-ssh-keys-authentication/
集群管理工具
https://github.com/cnrancher/kube-explorer

使用RKE快速部署k8s集群

标签:nts   you   --   native   内容   pull   list   emctl   require   

原文地址:https://www.cnblogs.com/bit-zjh/p/14794600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!