zoukankan      html  css  js  c++  java
  • kubernetes节点安装配置

    #环境安装,要与控制节点一致
    Centos 7 Linux release 7.3.1611
    网络: 互通
    配置主机名
    设置各个服务器的主机名hosts
    #查找kubernetes支持的docker版本
    Kubernetes v1.7.5 == Docker 1.12.6
    #然后到https://yum.dockerproject.org/repo/main/centos/7/Packages/下载安装
    ############################################################################################################################
    #DOCKER 安装
    #安装后启动并设置为开机自启
    rpm –ivh https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-1.12.6-1.el7.centos.x86_64.rpm
    sudo systemctl start docker
    sudo systemctl enable docker

    ############################################
    #安装Kubernetes
    #下载地址: https://github.com/kubernetes/kubernetes/releases/tag/v1.7.5
    tar zxf kubernetes-server-linux-amd64.tar.gz
    sh cluster/get-kube-binaries.sh
    cd server
    tar xf kubernetes-server-linux-amd64.tar.gz
    cd server/bin
    #准备证书
    mkdir /etc/kubernetes/crt
    cd /etc/kubernetes/crt
    #将master的ca.crt和ca.key复制到节点上192.168.1.2替换为本机IP
    openssl genrsa -out kubelet_client.key 2048
    openssl req -new -key kubelet_client.key -subj "/CN=192.168.1.2" -out kubelet_client.csr
    openssl x509 -req -in kubelet_client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out kubelet_client.crt -days 5000
    cd -
    #创建kubeconfig文件
    cat << EOF > /etc/kubernetes/kubeconfig
    apiVersion: v1
    kind: Config
    users:
    - name: kubelet
      user:
        client-certificate: /etc/kubernetes/crt/kubelet_client.crt
        client-key: /etc/kubernetes/crt/kubelet_client.key
    clusters:
    - name: local
      cluster:
        certificate-authority: /etc/kubernetes/crt/ca.crt
    contexts:
    - context:
        cluster: local
        user: kubelet
      name: my-context
    current-context: my-context
    EOF

    ################################
    #安装kubelet
    cp kubelet /usr/bin/
    cat << EOF > /usr/lib/systemd/system/kubelet.service
    [Unit]
    Description=Kubernetes Kubelet Server
    Documentation=https://github.com/GoogleCloudPlatform/kubernetes
    After=docker.service
    Requires=docker.service

    [Service]
    WorkingDirectory=/var/lib/kubelet
    EnvironmentFile=/etc/kubernetes/kubelet
    ExecStart=/usr/bin/kubelet $KUBELET_ARGS
    Restart=on-failure

    [Install]
    WantedBy=multi-user.target
    EOF
    #192.168.1.1替换为控制节点IP,minion-2替换为本机主机名,169.169.0.10替换为要设置的kubeDNS IP
    cat << EOF >/etc/kubernetes/kubelet
    KUBELET_ARGS="--api-servers=https://192.168.1.1:8080 --hostname-override=minion-2 --logtostderr=false
    --log-dir=/var/log/kubernetes --v=2
    --kubeconfig=/etc/kubernetes/kubeconfig
    --root-dir=/data/kubelet
    --cluster-dns=169.169.0.10"
    EOF

    #安装kube-proxy
    cp ../kube-proxy /usr/bin
    cat << EOF >/usr/lib/systemd/system/kube-proxy.service
    [Unit]
    Description=Kubernetes Kube Proxy Server
    Documentation=https://github.com/GoogleCloudPlatform/kubernetes
    After=network.target
    Requires=network.service

    [Service]
    EnvironmentFile=/etc/kubernetes/proxy
    ExecStart=/usr/bin/kube-proxy $KUBE_PROXY_ARGS
    Restart=on-failure
    LimitNOFILE=65536

    [Install]
    WantedBy=multi-user.target
    EOF
    #192.168.1.1替换为控制节点IP,169.169.0.0/16替换为之前设置的集群IP段
    cat << EOF >/etc/kubernetes/proxy
    KUBE_PROXY_ARGS="--master=https://192.168.1.1:8080
    --logtostderr=false --log-dir=/var/log/kubernetes --v=2
    --kubeconfig=/etc/kubernetes/kubeconfig
    --cluster-cidr=169.169.0.0/16"
    EOF
    #启动
    systemctl daemon-reload
    for i in kubelet.service kube-proxy.service
    do
    systemctl enable $i
    systemctl restart $i
    systemctl status $i
    done


  • 相关阅读:
    Kotlin 实现类似 C# 的 Event 事件代码
    nim 语言实现迭代器
    nim 语言使用 concept 实现 c# 的interface
    如何在 asp.net core mvc 项目中管理前端插件的引用
    遇到一个在 WPF 中使用 MessageBox 弹出但在打开后却立即自动关闭的问题
    如何在项目生成成功后,自动构建 nuget 包并复制或发布到指定位置
    在类库开发中,如何设定多个 .net 框架目标
    如何在 IIS 中重定向 http 请求至 https
    在 docker 中部署 phpmyadmin 使用 nginx 代理 https 时出现错误无法登录
    禅道中配置电子邮件发信遇到 SMTP 错误:无法连接到 SMTP 主机,点击重试可以成功
  • 原文地址:https://www.cnblogs.com/cainiaoit/p/8580745.html
Copyright © 2011-2022 走看看