• kubeadmin安装最新版本的kubenets


    系统设置

    CentOS Linux release 7.6.1810 (Core)

    设置本地解析

    vim /etc/hosts 172.16.227.40 k8s-master

    关闭及禁用防火墙

    systemctl disable firewalld

    systemctl stop firewalld

    关闭selinux

    sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

    设置启动参数

    cat <<EOF >  /etc/sysctl.d/k8s.conf
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    EOF
    
    sysctl --system

    安装docker,kubeadm, kubelet and kubectl

    安装docker

    yum install -y yum-utils device-mapper-persistent-data lvm2

    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

    yum list docker-ce --showduplicates | sort -r

    yum install docker

    systemctl start docker systemctl enable docker

    kubeadm, kubelet and kubectl

    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
    EOF

    yum install -y kubelet kubeadm kubectl

    systemctl enable kubelet && systemctl start kubelet

    # 添加--image-repository参数,默认镜像下载会失败,

    kubernetes-version与上面安装的kubelet版本对应一样

    kubeadm init --kubernetes-version=???. --pod-network-cidr=10.244.0.0/16 --image-repository registry.aliyuncs.com/google_containers

    设置kubectl命令

    mkdir -p $HOME/.kube

    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

    sudo chown $(id -u):$(id -g) $HOME/.kube/config

    安装pod network

    wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

    kubectl apply -f  kube-flannel.yml

    执行上面命令出错时提示如下:

    The connection to the server localhost:8080 was refused - did you specify the right host or port?

    解决办法:

    配置kubenetes的flannel网络的时候,出现以下报错

    The connection to the server localhost:8080 was refused - did you specify the right host or port?

    原因:kubenetes master没有与本机绑定,集群初始化的时候没有设置

    解决办法:执行以下命令   export KUBECONFIG=/etc/kubernetes/admin.conf

    /etc/kubernetes/admin.conf这个文件主要是集群初始化的时候用来传递参数的


    这样默认安装好只有一个master节点
    要想在主节点运行pods,还需要
     
    5.0/1 nodes are available: 1 node(s) had taints that the pod didn't tolerate.

    解决方法是安装flannel

    有时候一个pod创建之后一直是pending,没有日志,也没有pull镜像,describe的时候发现里面有一句话: 1 node(s) had taints that the pod didn't tolerate.

    直译意思是节点有了污点无法容忍,执行 kubectl get no -o yaml | grep taint -A 5 之后发现该节点是不可调度的。这是因为kubernetes出于安全考虑默认情况下无法在master节点上部署pod,于是用下面方法解决:

    kubectl taint nodes --all node-role.kubernetes.io/master-


    新节点加入k8s集群
    重复以上步骤,安装docker kubelet kubeadm kubectl
    注意,node节点的kubelet这些版本要与master节点的版本相同
    不用安装kube-flannel.yml,因为node节点加入集群后,会自动拉镜像安装
    注意,k8s的master通过init初始化后,生成的token会24小时后失效,要重新生成
    https://blog.csdn.net/wo18237095579/article/details/89884369
    https://www.cnblogs.com/histyle/p/10897163.html
     
  • 相关阅读:
    Linux C 字符串函数 sprintf()、snprintf() 详解
    Linux C 字符串输入函数 gets()、fgets()、scanf() 详解
    Linux C 字符串函数 strlen()、strcat()、strncat()、strcmp()、strncmp()、strcpy()、strncpy() 详解
    Linux C 字符函数 getchar()、putchar() 与 EOF 详解
    Linux C popen()函数详解
    【重装系统】线上Linux服务器(2TB)分区参考方案
    Ubuntu 开机进入命令行模式
    oracle视图总结(创建、查询、改动、删除等)
    UVa 637
    Intent 的Flag属性(Activity在栈位置的主宰者)
  • 原文地址:https://www.cnblogs.com/allmdzz/p/12554811.html
Copyright © 2020-2023  润新知