• 单master集群构建


    1.安装容器引擎

        apt-get update
        apt-get install -y apt-transport-https ca-certificates curl software-properties-common
    
        curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
        add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
        apt-get update
     
        apt-get -y install docker-ce=17.03.2~ce-0~ubuntu-xenial

    2.安装kubeadm

    在没有加速的情况下,必须使用国内源。

        curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
    
        vi  /etc/apt/sources.list.d/kubernetes.list
            deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
        
        apt-get update
    
        apt-get install -y kubelet=1.10.2-00  kubeadm=1.10.2-00 kubectl=1.10.2-00 kubernetes-cni=0.6.0-00
    
    
        kubeadm version
        kubectl version
        cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
        systemctl status kubelet
    
    
        docker pull anjia0532/kube-apiserver-amd64:v1.10.2
        docker pull anjia0532/kube-controller-manager-amd64:v1.10.2
        docker pull anjia0532/kube-scheduler-amd64:v1.10.2
        docker pull anjia0532/kube-proxy-amd64:v1.10.2
        docker pull anjia0532/etcd-amd64:3.1.12
        docker pull anjia0532/pause-amd64:3.1
        docker pull anjia0532/k8s-dns-sidecar-amd64:1.14.8
        docker pull anjia0532/k8s-dns-kube-dns-amd64:1.14.8
        docker pull anjia0532/k8s-dns-dnsmasq-nanny-amd64:1.14.8
    
        docker tag anjia0532/kube-apiserver-amd64:v1.10.2 k8s.gcr.io/kube-apiserver-amd64:v1.10.2
        docker tag anjia0532/kube-scheduler-amd64:v1.10.2 k8s.gcr.io/kube-scheduler-amd64:v1.10.2
        docker tag anjia0532/kube-controller-manager-amd64:v1.10.2 k8s.gcr.io/kube-controller-manager-amd64:v1.10.2
        docker tag anjia0532/kube-proxy-amd64:v1.10.2 k8s.gcr.io/kube-proxy-amd64:v1.10.2
        docker tag anjia0532/etcd-amd64:3.1.12 k8s.gcr.io/etcd-amd64:3.1.12
        docker tag anjia0532/pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1
        docker tag anjia0532/k8s-dns-sidecar-amd64:1.14.8 k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.8
        docker tag anjia0532/k8s-dns-kube-dns-amd64:1.14.8 k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.8
        docker tag anjia0532/k8s-dns-dnsmasq-nanny-amd64:1.14.8 k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.8

    初始化处理:

        kubeadm init --apiserver-advertise-address=148.70.251.10 --kubernetes-version=1.10.2
        (
        kubeadm join 148.70.251.10:6443 --token nh819o.pzcpohatm7p3a5cm --discovery-token-ca-cert-hash sha256:55254659ea80b335a09dd627757d6aecd10b2c6fbdaddc63dd9bae9ec353cc49
        )
    
        mkdir -p $HOME/.kube
        sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
        sudo chown $(id -u):$(id -g) $HOME/.kube/config
        export KUBECONFIG=/etc/kubernetes/admin.conf

    查看mster组件运行情况

      在执行kubeadm init失败之后,我们需要重kubeadm reset会将kubeadm恢复到初始状态。

    3.安装网络插件

    curl -L "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '
    ')" > weave.yaml

    编辑weave.yaml

    使配置失效:

    kubectl apply -f weave.yaml

    查看运行情况:

    4.加入worker节点

    worker节点也需要和master一样,安装kubeadm辅助工具

    #!/usr/bin/bash
    #安装容器引擎
    apt-get update
    apt-get install -y apt-transport-https ca-certificates curl software-properties-common
    
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    apt-get update
    
    apt-get -y install docker-ce=17.03.2~ce-0~ubuntu-xenial
    systemctl restart docker
    
    
    #镜像下载
    docker pull anjia0532/pause-amd64:3.1
    docker pull anjia0532/kube-proxy-amd64:v1.10.2
    docker tag anjia0532/pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1
    docker tag anjia0532/kube-proxy-amd64:v1.10.2 k8s.gcr.io/kube-proxy-amd64:v1.10.2
    
    
    
    #安装kubeadm、kubecet、kubectl
    curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
    cat >>  /etc/apt/sources.list.d/kubernetes.list << EOF
    deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
    EOF
    
    apt-get update
    apt-get install -y kubelet=1.10.2-00  kubeadm=1.10.2-00 kubectl=1.10.2-00 kubernetes-cni=0.6.0-00
    
    kubeadm join 148.70.251.10:6443 --token e4h0ek.9b7drehx2xlexaf5 --discovery-token-ca-cert-hash sha256:70bfd4ed05d1a1f1c12eb817d2978962131aaf0d2b796a87f4100daeb9a85070

    查看节点状态:

    需要说明的是,master节点也可以承担工作负荷,但是并不建议这样做。

    5.配置命令行交互工具

    在master节点通过kubectl工具来管理整个集群。
    如果我们希望在每个worker节点上都可以管理集群,我们可以配置命令行管理工具。
    分发admin.conf文件:

    scp /etc/kubernetes/admin.conf root@148.70.122.28:/etc/kubernetes/

    添加环境变量(/etc/profile):

    export KUBECONFIG='/etc/kubernetes/admin.conf'

    然后在当前节点上就可以通过kubectl来进行管理:

  • 相关阅读:
    Autofac小例子
    Spring自带mock测试Controller
    [转载]转Java 几个memcached 连接客户端对比 选择
    danga的MemcachedClient的几个缺陷
    linux查看memcached状态
    Linux下配置安装PHP环境(Apache2)
    使用memcache.php监控memcached
    memcached运行情况监测
    memcached监控的几种方法(nagios等)
    xmemcached使用的几点优化建议
  • 原文地址:https://www.cnblogs.com/yangmingxianshen/p/12549009.html
Copyright © 2020-2023  润新知