美文网首页
deepin debian ubuntu 安装kubernete

deepin debian ubuntu 安装kubernete

作者: 冰封飞飞 | 来源:发表于2019-04-10 20:37 被阅读0次

    首先安装docker

    sudo apt-get update && apt-get install -y apt-transport-https
    sudo apt install docker.io
    sudo systemctl start docker
    sudo systemctl enable docker
    

    普通用户添加到docker用户组

    这样可以非root用户使用docker命令

    sudo groupadd docker
    sudo gpasswd -a ${USER} docker
    sudo systemctl restart docker
    

    然后重新打开终端

    添加k8s官方源

    sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    sudo cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
    deb http://apt.kubernetes.io/ kubernetes-xenial main
    EOF
    sudo apt-get update
    sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni
    

    这一步需要科学上网,否则会出现下载失败。

    使用kubeadm部署k8s

    swapoff -a
    kubeadm init \
        --image-repository registry.aliyuncs.com/google_containers \
        --kubernetes-version v1.14.0 \
        --pod-network-cidr=10.244.0.0/16
    

    设置k8s的网络插件

    如果不安装网络插件的话,kubectl get pods -n kube-system会有pod是polling状态。
    我们使用weave作为网络插件,执行下面命令安装

    kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    

    设置k8s的存储插件

    我们使用rook作为k8s的存储插件,执行下面的命令

    kubectl apply -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/common.yaml
    kubectl apply -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/cluster.yaml
    kubectl apply -f https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/operator.yaml
    
    

    如果你是单节点的k8s,还需要删除Master节点的taint

    kubectl taint node <nodename> node-role.kubernetes.io/master:NoSchedule-
    

    nodename根据你的node名称填写,使用下面命令查看

    kubectl get nodes
    

    设置kubectl的自动补全

    bash

    执行

    echo 'source <(kubectl completion bash)' >>~/.bashrc
    kubectl completion bash >/etc/bash_completion.d/kubectl
    

    zsh

    编辑~/.zshrc文件,添加下面内容

    autoload -Uz compinit
    compinit
    source <(kubectl completion zsh
    

    相关文章

      网友评论

          本文标题:deepin debian ubuntu 安装kubernete

          本文链接:https://www.haomeiwen.com/subject/nvxaiqtx.html