清理

初始化部署环境,清除历史数据

sudo rm -rf /etc/kubenetes/*
sudo rm -rf /var/lib/kubelet/*
sudo rm -rf /var/lib/cni/*
sudo rm -rf /var/lib/calico/*

示例

生成配置文件: rke config

启动集群: rke up

集群成功启动后,会生成一个对应的kubectl配置文件

# 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.201
  port: "22"
  internal_address: ""
  role:
  - controlplane
  - worker
  - etcd
  hostname_override: ""
  user: vagrant
  # docker_socket: /var/run/docker.sock
  # ssh_key: ""
  # ssh_key_path: ~/.ssh/id_rsa
  labels: {}
- address: 192.168.1.202
  port: "22"
  internal_address: ""
  role:
  - controlplane
  - worker
  - etcd
  hostname_override: ""
  user: vagrant
  # docker_socket: /var/run/docker.sock
  # ssh_key: ""
  # ssh_key_path: ~/.ssh/id_rsa
  labels: {}
- address: 192.168.1.203
  port: "22"
  internal_address: ""
  role:
  - controlplane
  - worker
  - etcd
  hostname_override: ""
  user: vagrant
  # docker_socket: /var/run/docker.sock
  # ssh_key: ""
  # ssh_key_path: ~/.ssh/id_rsa
  labels: {}
services:
  etcd:
    image: ""
    extra_args: {}
    extra_binds: []
    extra_env: []
    external_urls: []
    ca_cert: ""
    cert: ""
    key: ""
    path: ""
    snapshot: null
    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: canal
  options: {}
authentication:
  strategy: x509
  options: {}
  sans: []
addons: ""
addons_include: []
system_images:
  etcd: rancher/coreos-etcd:v3.2.24
  alpine: rancher/rke-tools:v0.1.16
  nginx_proxy: rancher/rke-tools:v0.1.16
  cert_downloader: rancher/rke-tools:v0.1.16
  kubernetes_services_sidecar: rancher/rke-tools:v0.1.16
  kubedns: rancher/k8s-dns-kube-dns-amd64:1.15.0
  dnsmasq: rancher/k8s-dns-dnsmasq-nanny-amd64:1.15.0
  kubedns_sidecar: rancher/k8s-dns-sidecar-amd64:1.15.0
  kubedns_autoscaler: rancher/cluster-proportional-autoscaler-amd64:1.0.0
  kubernetes: rancher/hyperkube:v1.13.4-rancher1
  flannel: rancher/coreos-flannel:v0.10.0
  flannel_cni: rancher/coreos-flannel-cni:v0.3.0
  calico_node: rancher/calico-node:v3.4.0
  calico_cni: rancher/calico-cni:v3.4.0
  calico_controllers: ""
  calico_ctl: rancher/calico-ctl:v2.0.0
  canal_node: rancher/calico-node:v3.4.0
  canal_cni: rancher/calico-cni:v3.4.0
  canal_flannel: rancher/coreos-flannel:v0.10.0
  wave_node: weaveworks/weave-kube:2.5.0
  weave_cni: weaveworks/weave-npc:2.5.0
  pod_infra_container: rancher/pause-amd64:3.1
  ingress: rancher/nginx-ingress-controller:0.21.0-rancher1
  ingress_backend: rancher/nginx-ingress-controller-defaultbackend:1.4
  metrics_server: rancher/metrics-server-amd64:v0.3.1
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: ""
monitoring:
  provider: ""
  options: {}

安装rancher

helm添加源

  1. kubectl初始化
  2. helm初始化
    helm repo add rancher-latest https://releases.rancher.com/server-charts/latest

    安装cert-manager

    helm install stable/cert-manager \
    --name cert-manager \
    --namespace kube-system \
    --version v0.5.2

    安装rancher

    helm install rancher-latest/rancher \
    --name rancher \
    --namespace cattle-system \
    --set hostname=rancher.my.org

    FAQ

ubuntu18.04 helm issue

Client: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}
E0320 10:35:39.112701   16569 portforward.go:331] an error occurred forwarding 56150 -> 44134: error forwarding port 44134 to pod f86eff10241836bdc8d139c995c739ac1c696dd6c77411aaf9581b20cbfa7dd1, uid : exit status 1: 2019/03/20 02:35:39 socat[28844] E getaddrinfo("localhost", "NULL", {1,2,1,6}, {}): Temporary failure in name resolution
Error: cannot connect to Tiller

解决方案:

# https://github.com/kubernetes/kubeadm/issues/787

sudo rm /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

rke启动提示无法连接到目标主机(ubuntu14.04)

WARN[0002] Failed to set up SSH tunneling for host [172.16.25.38]: Can't retrieve Docker Info: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: Unable to access the Docker socket (/var/run/docker.sock). Please check if the configured user can execute `docker ps` on the node, and if the SSH server version is at least version 6.7 or higher. If you are using RedHat/CentOS, you can't use the user `root`. Please refer to the documentation for more instructions. Error: ssh: rejected: administratively prohibited (open failed)

解决方案:

升级openssh-server版本

  1. apt升级

    echo "deb http://old-releases.ubuntu.com/ubuntu yakkety main universe multiverse" >> /etc/apt/sources.list
    sudo apt-get update
    sudo apt-get install openssh-server
  2. 源码编译升级

    sudo apt install -y build-essential libssl-dev zlib1g-dev
    wget "https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.4p1.tar.gz"
    tar xfz openssh-7.4p1.tar.gz
    cd openssh-7.4p1
    ./configure
    make
    sudo make install && sudo service ssh restart && ssh -V

发表评论

电子邮件地址不会被公开。 必填项已用*标注