美文网首页
CentOS7 kubernetes安装

CentOS7 kubernetes安装

作者: 带马界的神秘人 | 来源:发表于2017-12-01 23:53 被阅读0次

    国内环境安装kubernetes

    利用阿里云提供的镜像

    添加repo

    添加docker的repo

    cat >>  /etc/yum.repos.d/docker.repo  <<EOF
    [dockerrepo]
    name=Docker Repository
    baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
    enabled=1
    gpgcheck=1
    gpgkey=https://yum.dockerproject.org/gpg
    EOF
    

    添加kubernetes的repo

    cat >>  /etc/yum.repos.d/kubernetes.repo  <<EOF
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=0
    EOF
    

    安装

    yum install docker-1.12.6-61.git85d7426.el7.centos.x86_64
    yum install kubeadm
    

    设置

    setenforce 0
    systemctl enable docker
    systemctl start docker
    systemctl enable kubelet
    cat <<EOF >  /etc/sysctl.d/k8s.conf
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    EOF
    sysctl --system
    

    下载镜像

    建立pullImage.sh文件

    #!/bin/bash
    KUBE_VERSION=v1.7.5
    KUBE_PAUSE_VERSION=3.0
    ETCD_VERSION=3.0.17
    DNS_VERSION=1.14.4
    
    images=(kube-proxy-amd64:${KUBE_VERSION}
    kube-scheduler-amd64:${KUBE_VERSION}
    kube-controller-manager-amd64:${KUBE_VERSION}
    kube-apiserver-amd64:${KUBE_VERSION}
    pause-amd64:${KUBE_PAUSE_VERSION}
    etcd-amd64:${ETCD_VERSION}
    k8s-dns-sidecar-amd64:${DNS_VERSION}
    k8s-dns-kube-dns-amd64:${DNS_VERSION}
    k8s-dns-dnsmasq-nanny-amd64:${DNS_VERSION})
    
    GCR_URL=gcr.io/google_containers
    ALIYUN_URL=mirrorgooglecontainers
    
    for imageName in ${images[@]} ; do
      docker pull $ALIYUN_URL/$imageName
      docker tag $ALIYUN_URL/$imageName $GCR_URL/$imageName
    done
    

    运行sh文件下载镜像

    chmod +x pullImage.sh
    ./pullImage.sh
    

    建立集群master

    kubeadm init --apiserver-advertise-address=本机ip --kubernetes-version=v1.7.5 --pod-network-cidr=10.244.0.0/12
    
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    
    kubectl --namespace kube-system apply -f https://raw.githubusercontent.com/coreos/flannel/v0.8.0/Documentation/kube-flannel-rbac.yml
    rm -rf kube-flannel.yml 
    wget https://raw.githubusercontent.com/coreos/flannel/v0.8.0/Documentation/kube-flannel.yml
    sed -i 's/quay.io\/coreos\/flannel:v0.8.0-amd64/registry.cn-hangzhou.aliyuncs.com\/szss_k8s\/flannel:v0.8.0-amd64/g' ./kube-flannel.yml
    kubectl --namespace kube-system apply -f ./kube-flannel.yml
    

    验证主节点状态

    kubectl get cs
    

    相关文章

      网友评论

          本文标题:CentOS7 kubernetes安装

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