• 基于rancher安装部署k8s


    基础配置

    systemctl stop firewalld && systemctl disable firewalld
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    
    vi /etc/hosts
    ip1 node1
    ip2 node2
    ip3 node3
    
    
    #免密登录
    ssh-keygen
    
    ssh-copy-id -i ~/.ssh/id_rsa.pub 普通用户@ip1
    ssh-copy-id -i ~/.ssh/id_rsa.pub 普通用户@ip2
    ssh-copy-id -i ~/.ssh/id_rsa.pub 普通用户@ip3
    #验证
    ssh 普通用户@ip1
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    rancher

    kubectl

    yum install -y epel-release
    yum -y install snapd
    
    snap install kubectl --classic
    kubectl help
    
    • 1
    • 2
    • 3
    • 4
    • 5

    rke

    二进制安装文件,创建k8s集群

    wget https://github.com/rancher/rke/releases/download/v1.3.20/rke_linux-amd64
    cp rke_linux-amd64 /usr/local/bin/rke
    chmod +x /usr/local/bin/rke
    
    rke --version
    
    • 1
    • 2
    • 3
    • 4
    • 5

    helm

    k8s的包管理器,charts与helm的关系类似于rpm与yum。

    wget https://get.helm.sh/helm-v3.12.0-linux-amd64.tar.gz
    tar zxvf helm-v3.12.0-linux-amd64.tar.gz
    cp linux-amd64/helm /usr/local/bin/helm
    
    helm help
    
    • 1
    • 2
    • 3
    • 4
    • 5

    docker-ce

    yum list docker-ce --showduplicates
    yum install -y docker-ce-18.06.3.ce-3.el7
    
    • 1
    • 2

    部署k8s

    #vi rancher-cluster.yml
    nodes:
      - address: ip1
        user: 普通用户
        role: [controlplane,worker,etcd] #节点角色
      - address: ip2
        user: 普通用户
        role: [controlplane,worker,etcd]
      - address: ip3
        user: 普通用户
        role: [controlplane,worker,etcd]
    
    services:
      etcd:
        snapshot: true
        creation: 6h
        retention: 12
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    rke up --config ./rancher-cluster.yml
    #返回下面的消息则说明执行成功:Finished building Kubernetes cluster successfully.
    #kubectl get pods --all-namespaces,pod为running
    
    • 1
    • 2
    • 3

    保存以下文件:
    rancher-cluster.yml:rke孵化k8s集群的配置文件
    kube_config_rancher-cluster.yml:k8s被访问的kubeconfig文件,此文件包含完全访问群集的凭据
    rancher-cluster.rkestate:k8s群集的状态文件,此文件包含完全访问群集的凭据

    mkdir .kube
    cp kube_config_rancher-cluster.yml .kube/
    export KUBECONFIG=$(pwd)/kube_config_rancher-cluster.yml
    #查看
    kubectl get nodes
    
    • 1
    • 2
    • 3
    • 4
    • 5

    部署rancher

    #加仓库
    helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
    
    kubectl create namespace cattle-system
    
    #安装CustomResourceDefinition资源
    kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.12/deploy/manifests/00-crds.yaml
    
    kubectl create namespace cert-manager
    #添加Jetstack仓库,更新缓存
    helm repo add jetstack https://charts.jetstack.io
    helm repo update
    
    #通过helm chart安装cert-manager
    helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v0.12.0
    
    #验证
    kubectl get pods --namespace cert-manager
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 相关阅读:
    昨晚,我用python帮学妹P证件照自拍,然后发现。。。
    C. Fishingprince Plays With Array--Codeforces Global Round 21
    合并K个升序链表
    当知识管理遇上企业云盘一体机
    数字化转型风险大,企业该如何应对?
    为了面试阿里,熬夜肝完这份软件测试笔记后,Offer终于到手了
    STM32/N32G455国民科技芯片驱动DS1302时钟---笔记
    C++学习笔记(二十九)
    R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的边框颜色
    使用免费软件将数据从机械硬盘克隆到固态硬盘!
  • 原文地址:https://blog.csdn.net/hy19930118/article/details/133743118