rke 部署 k8s 实战

1.1) virtualbox + vagrant 生成4台虚拟机 (centos7 , public_network)

主机ip内存备注
rke(master)192.168.1.1172.5G 
node1192.168.1.1161G 
node2192.168.1.1131G 
node3192.168.1.1151G 

1.2) 设置主机名, 

     > hostnamectl set-hostname rke 

1.3)配置 hosts:

    > vi /etc/hosts 

    在尾部加入

    192.168.1.117 rke
    192.168.1.116 node1
    192.168.1.113 node2

    192.168.1.115 node3

1.4)配置ssh key
        将rke的虚拟机 private_key 上传到rke主机用户vagrant 的 .ssh 目录,并更名为: id_dsa, 更改授权:             > chmod 0600 id_dsa

     将rke主机用户vagrant 的 authorized_keys 文件覆盖其它主机用户vagrant 的authorized_keys。目录在 /home/vagrant/.ssh.


1.5) 测试ssh key 访问

        在rke 主机输入命令: >ssh node1 

       成功则可以看到:  [vagrant@node1 ~]$ 

1.6)下载rke

        rke最新版本下载: https://github.com/rancher/rke/releases/

        下载: rke_linux-amd64

          > mv rke_linux-amd64 rke 

          > chmod +x rke 

1.7) 安装 docker

    

Docker VersionInstall Script
17.03.2curl https://releases.rancher.com/install-docker/17.03.sh | sh
1.13.1curl https://releases.rancher.com/install-docker/1.13.sh | sh
1.12.6curl https://releases.rancher.com/install-docker/1.12.sh | sh

这里选择安装 17.03.2,  在所有主机执行命令:

> sudo curl https://releases.rancher.com/install-docker/17.03.sh | sh

> sudo usermod -aG docker vagrant

1.8) 安装

    在主机rke 执行: > ./rke config  , 生成配置文件: cluster.yml , 

# If you intened to deploy Kubernetes in an air-gapped environment,
# please consult the documentation on how to configure custom RKE images.
nodes:
- address: "192.168.1.117"
  port: "22"
  internal_address: ""
  role:
  - controlplane
  - etcd
  hostname_override: rke
  user: vagrant
  docker_socket: /var/run/docker.sock
  ssh_key: ""
  ssh_key_path: ~/.ssh/id_dsa
  labels: {}
- address: "192.168.1.116"
  port: "22"
  role:
  - worker
  hostname_override: node1
  user: vagrant
  docker_socket: /var/run/docker.sock
  ssh_key: ""
  ssh_key_path: ~/.ssh/id_dsa
  labels: {}
- address: "192.168.1.113"
  port: "22"
  role:
  - worker
  hostname_override: node2
  user: vagrant
  docker_socket: /var/run/docker.sock
  ssh_key: ""
  ssh_key_path: ~/.ssh/id_dsa
  labels: {}
- address: "192.168.1.115"
  port: "22"
  role:
  - worker
  hostname_override: node3
  user: vagrant
  docker_socket: /var/run/docker.sock
  ssh_key: ""
  ssh_key_path: ~/.ssh/id_dsa
  labels: {}
services:
  etcd:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
    external_urls: []
    ca_cert: ""
    cert: ""
    key: ""
    path: ""
    snapshot: false
    retention: ""
    creation: ""
  kube-api:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
    service_cluster_ip_range: 10.43.0.0/16
    service_node_port_range: ""
    pod_security_policy: false
  kube-controller:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
    cluster_cidr: 10.42.0.0/16
    service_cluster_ip_range: 10.43.0.0/16
  scheduler:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
  kubelet:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
    cluster_domain: cluster.local
    infra_container_image: ""
    cluster_dns_server: 10.43.0.10
    fail_swap_on: false
  kubeproxy:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
network:
  plugin: flannel
  options: {}
authentication:
  strategy: x509
  options: {}
  sans: []
addons: ""
addons_include: []
system_images:
  etcd: rancher/coreos-etcd:v3.1.12
  alpine: rancher/rke-tools:v0.1.10
  nginx_proxy: rancher/rke-tools:v0.1.10
  cert_downloader: rancher/rke-tools:v0.1.10
  kubernetes_services_sidecar: rancher/rke-tools:v0.1.10
  kubedns: rancher/k8s-dns-kube-dns-amd64:1.14.8
  dnsmasq: rancher/k8s-dns-dnsmasq-nanny-amd64:1.14.8
  kubedns_sidecar: rancher/k8s-dns-sidecar-amd64:1.14.8
  kubedns_autoscaler: rancher/cluster-proportional-autoscaler-amd64:1.0.0
  kubernetes: rancher/hyperkube:v1.10.5-rancher1
  flannel: rancher/coreos-flannel:v0.9.1
  flannel_cni: rancher/coreos-flannel-cni:v0.2.0
  calico_node: rancher/calico-node:v3.1.1
  calico_cni: rancher/calico-cni:v3.1.1
  calico_controllers: ""
  calico_ctl: rancher/calico-ctl:v2.0.0
  canal_node: rancher/calico-node:v3.1.1
  canal_cni: rancher/calico-cni:v3.1.1
  canal_flannel: rancher/coreos-flannel:v0.9.1
  wave_node: weaveworks/weave-kube:2.1.2
  weave_cni: weaveworks/weave-npc:2.1.2
  pod_infra_container: rancher/pause-amd64:3.1
  ingress: rancher/nginx-ingress-controller:0.10.2-rancher3
  ingress_backend: rancher/nginx-ingress-controller-defaultbackend:1.4
ssh_key_path: ~/.ssh/id_rsa
ssh_agent_auth: false
authorization:
  mode: rbac
  options: {}
ignore_docker_version: false
kubernetes_version: ""
private_registries: []
ingress:
  provider: ""
  options: {}
  node_selector: {}
  extra_args: {}
cluster_name: ""
cloud_provider:
  name: ""
prefix_path: ""
addon_job_timeout: 0
bastion_host:
  address: ""
  port: ""
  user: ""
  ssh_key: ""
  ssh_key_path: ""

安装k8s:

> ./rke up 

备注: http://staging.rancher.com/docs/rke/v0.1.x/en/installation/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值