美文网首页
Ubuntu 16.04 安装 Kubernetes

Ubuntu 16.04 安装 Kubernetes

作者: SlowGO | 来源:发表于2018-12-06 16:13 被阅读4次

    安装 Docker

    apt-get update && apt-get install docker.io
    

    安装 kubelet kubeadm kubectl

    apt-get update && apt-get install -y apt-transport-https curl
    
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    
    cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
    deb https://apt.kubernetes.io/ kubernetes-xenial main
    EOF
    
    apt-get update
    
    apt-get install -y kubelet kubeadm kubectl
    
    apt-mark hold kubelet kubeadm kubectl
    
    swapoff -a
    
    sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
    
    sed -i '0,/ExecStart=/s//Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=cgroupfs"\n&/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    

    指定 kube 版本

    上面的方式会安装最新版本,也可以指定版本。

    查看 kubernetes 版本:

    curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}'
    

    安装目标版本:

    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
      echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
      sudo apt-get update -q && \
      sudo apt-get install -qy kubelet=<version> kubectl=<version> kubeadm=<version>
    

    示例:

    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
      echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
      sudo apt-get update -q && \
      sudo apt-get install -qy kubelet=1.9.6-00 kubectl=1.9.6-00 kubeadm=1.9.6-00
    

    服务自动启动

    systemctl start docker && systemctl enable docker
    
    systemctl start kubelet && systemctl enable kubelet
    

    安装命令提示

    echo "source <(kubectl completion bash)" >> ~/.bashrc
    source ~/.bashrc
    

    相关文章

      网友评论

          本文标题:Ubuntu 16.04 安装 Kubernetes

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