kubeadm 安装

作者: lodestar | 来源:发表于2020-03-10 13:52 被阅读0次

    在Centos7.0系统,加入安装源路径

    [root@web-test-01 ~]#cd /etc/yum.repos.d
    [root@web-test-01 ~]#wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    
    [root@web-test-01 ~]#vim kubenetes.repo
    [kubernetes]
    name=Kubernetes Repo
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    gpgcheck=0
    gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
    enabled=1
    

    master节点安装

    [root@web-test-01 ~]#yum install docker-ce kubelet kubeadm kubectl 
    

    node节点安装

    [root@web-test-01 ~]#yum install docker-ce kubelet kubeadm 
    

    初始化k8s

    [root@web-test-01 ~]#kubeadm init --kubernetes-version=v1.17.3 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap 
    

    会出现被墙的问题,那我们查看需要依赖的镜像

    #master
    [root@web-test-01 ~]#kubeadm config images list
    k8s.gcr.io/kube-apiserver:v1.17.3
    k8s.gcr.io/kube-controller-manager:v1.17.3
    k8s.gcr.io/kube-scheduler:v1.17.3
    k8s.gcr.io/kube-proxy:v1.17.3
    k8s.gcr.io/pause:3.1
    k8s.gcr.io/etcd:3.4.3-0
    k8s.gcr.io/coredns:1.6.5
    

    如需要镜像文件请入群QQ 1005491328下载,加载镜像如下

    docker image load -i kube-apiserver.tar.gz
    

    node节点需要pull完成的相关镜像

    #node
    k8s.gcr.io/kube-proxy  
    k8s.gcr.io/pause 
    quay.io/coreos/flannel
    

    init启动完成后会显示join命令,记得保存,按照提示操作,在节点运行命令加入k8s集群

    Your Kubernetes control-plane has initialized successfully!
    
    To start using your cluster, you need to run the following as a regular user:
    
      mkdir -p $HOME/.kube
      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
      sudo chown $(id -u):$(id -g) $HOME/.kube/config
    
    You should now deploy a pod network to the cluster.
    Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
      https://kubernetes.io/docs/concepts/cluster-administration/addons/
    
    Then you can join any number of worker nodes by running the following on each as root:
    
    kubeadm join 121.71.157.127:6443 --token v5q11k.cft1mtn1dywgws9 \
        --discovery-token-ca-cert-hash sha256:322430bb222225901111102662a6b460575adc3c61313d080375f4fa5150ad3c93
    

    coredns依赖flannel组件,未安装flannel时候查看coredns的状态为pending

    #master
    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
    或者
    docker pull quay.io/coreos/flannel:v0.11.0-amd64
    

    查看状态

    [root@web-test-01 kubetest]# kubectl get componentstatus
    NAME                 STATUS    MESSAGE             ERROR
    controller-manager   Healthy   ok
    scheduler            Healthy   ok
    etcd-0               Healthy   {"health":"true"}
    
    [root@web-test-01 kubetest]# kubectl get nodes
    NAME          STATUS   ROLES    AGE     VERSION
    web-sim-01    Ready    <none>   2m25s   v1.17.3
    web-test-01   Ready    master   40m     v1.17.3
    

    相关文章

      网友评论

        本文标题:kubeadm 安装

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