zoukankan      html  css  js  c++  java
  • k8s-1.18.0版本-kubeadmin部署(提供阿里云镜像)(二)master节点

    k8s-1.18.0版本-kubeadmin部署

    (提供阿里云镜像)

    个人服务器地址:http://101.201.140.7/wp-blog/

    系统开启kube-proxy的ipvs前置条件

    从k8s的1.8版本开始,kube-proxy引入了IPVS模式,IPVS模式与iptables同样基于Netfilter,但是采用的hash表,因此当service数量达到一定规模时,hash查表的速度优势就会显现出来,从而提高service的服务性能。
    开启内核参数(上篇文章环境准备已经配置不再赘述)

    安装

    yum -y install ipvsadm  ipset
    

    永久生效

    modprobe br_netfilter
    cat > /etc/sysconfig/modules/ipvs.modules <<EOF 
    #!/bin/bash
    modprobe -- ip_vs 
    modprobe -- ip_vs_rr 
    modprobe -- ip_vs_wrr 
    modprobe -- ip_vs_sh
    modprobe -- nf_conntrack_ipv4 
    EOF
    

    chmod 755 /etc/sysconfig/modules/ipvs.modules && bash 
    /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e 
    nf_conntrack_ipv4
    

    配置kubernetes.repo

    cat <<EOF > /etc/yum.repos.d/kubernetes.repo 
    [kubernetes]
    name=Kubernetes 
    baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg  
    https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
    EOF
    

    yum安装

    yum -y install kubeadm-1.18.0 kubectl-1.18.0 kubelet-1.18.0
    

    开机自启

    systemctl enable kubelet.service
    

    初始化节点

    kubeadm config print init-defaults &gt; kubeadm-config.yaml
    

    编辑

    新增内容如下:

    ---
    apiVersion: kubeproxy.config.k8s.io/v1alpha1
    kind: KubeProxyConfiguration
    featureGates:
    &nbsp; SupportIPVSProxyMode: true
    mode: ipvs
    

    下载镜像文件

    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/etcd:3.4.3-0
    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/coredns:1.6.7
    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/pause:3.2
    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/kube-controller-manager:v1.18.0
    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/kube-scheduler:v1.18.0
    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/kube-apiserver:v1.18.0
    docker pull registry.cn-beijing.aliyuncs.com/yunweijia/kube-proxy:v1.18.0
    

    重新打标签tag

    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/kube-proxy:v1.18.0               k8s.gcr.io/kube-proxy:v1.18.0
    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/kube-apiserver:v1.18.0           k8s.gcr.io/kube-apiserver:v1.18.0
    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/kube-scheduler:v1.18.0           k8s.gcr.io/kube-scheduler:v1.18.0
    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/kube-controller-manager:v1.18.0  k8s.gcr.io/kube-controller-manager:v1.18.0
    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/pause:3.2                        k8s.gcr.io/pause:3.2
    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/coredns:1.6.7                    k8s.gcr.io/coredns:1.6.7
    docker tag  registry.cn-beijing.aliyuncs.com/yunweijia/etcd:3.4.3-0                     k8s.gcr.io/etcd:3.4.3-0
    

    查看

    [root@k8s-master01 ~]# docker images|grep yunweijia|grep -v flannel
    registry.cn-beijing.aliyuncs.com/yunweijia/kube-proxy                v1.18.0             43940c34f24f        5 weeks ago         117MB
    registry.cn-beijing.aliyuncs.com/yunweijia/kube-scheduler            v1.18.0             a31f78c7c8ce        5 weeks ago         95.3MB
    registry.cn-beijing.aliyuncs.com/yunweijia/kube-apiserver            v1.18.0             74060cea7f70        5 weeks ago         173MB
    registry.cn-beijing.aliyuncs.com/yunweijia/kube-controller-manager   v1.18.0             d3e55153f52f        5 weeks ago         162MB
    registry.cn-beijing.aliyuncs.com/yunweijia/pause                     3.2                 80d28bedfe5d        2 months ago        683kB
    registry.cn-beijing.aliyuncs.com/yunweijia/coredns                   1.6.7               67da37a9a360        3 months ago        43.8MB
    registry.cn-beijing.aliyuncs.com/yunweijia/etcd                      3.4.3-0             303ce5db0e90        6 months ago        288MB
    
    [root@k8s-master01 ~]# docker images|grep -v flannel|grep -v yunweijia
    REPOSITORY                                                           TAG                 IMAGE ID            CREATED             SIZE
    k8s.gcr.io/kube-proxy                                                v1.18.0             43940c34f24f        5 weeks ago         117MB
    k8s.gcr.io/kube-controller-manager                                   v1.18.0             d3e55153f52f        5 weeks ago         162MB
    k8s.gcr.io/kube-scheduler                                            v1.18.0             a31f78c7c8ce        5 weeks ago         95.3MB
    k8s.gcr.io/kube-apiserver                                            v1.18.0             74060cea7f70        5 weeks ago         173MB
    k8s.gcr.io/pause                                                     3.2                 80d28bedfe5d        2 months ago        683kB
    k8s.gcr.io/coredns                                                   1.6.7               67da37a9a360        3 months ago        43.8MB
    k8s.gcr.io/etcd                                                      3.4.3-0             303ce5db0e90        6 months ago        288MB
    

    开始初始化

    kubeadm init --config=kubeadm-config.yaml --upload-certs | tee 
    kubeadm-init.log
    

    按照指示执行

      mkdir -p $HOME/.kube
      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
      sudo chown $(id -u):$(id -g) $HOME/.kube/config
    

    查看所有空间的pod状态

    kubectl get pod --all-namespaces
    

    下载flannel的yml文件

    wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
    

    查看yaml需要的镜像

    [root@k8s-master01 ~]# cat kube-flannel.yml |grep image|uniq
            image: quay.io/coreos/flannel:v0.12.0-amd64
            image: quay.io/coreos/flannel:v0.12.0-arm64
            image: quay.io/coreos/flannel:v0.12.0-arm
            image: quay.io/coreos/flannel:v0.12.0-ppc64le
            image: quay.io/coreos/flannel:v0.12.0-s390x
    

    登录阿里云

    阿里云镜像服务https://www.aliyun.com/product/acr



    拉取镜像

    docker  pull  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-s390x
    docker  pull  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-ppc64le
    docker  pull  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-arm64
    docker  pull  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-arm
    docker  pull  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-amd64
    

    重打标签tag或者修改yml文件--注意空格

    docker  tag  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-s390x    quay.io/coreos/flannel:v0.12.0-s390x
    docker  tag  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-ppc64le  quay.io/coreos/flannel:v0.12.0-ppc64le
    docker  tag  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-arm64    quay.io/coreos/flannel:v0.12.0-arm64
    docker  tag  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-arm      quay.io/coreos/flannel:v0.12.0-arm
    docker  tag  registry.cn-beijing.aliyuncs.com/yunweijia/flannel:v0.12.0-amd64    quay.io/coreos/flannel:v0.12.0-amd64
    

    加载flannel

    查看所以pod全部信息 ,查看kube-system空间下的pod,-w一直刷新状态

    kubectl apply -f kube-flannel.yml
    kubectl get pod --all-namespaces -o wide
    kubectl get pod -n kube-system
    kubectl get pod --all-namespaces -w
    
    [root@k8s-master01 ~]# kubectl get pod --all-namespaces -o wide
    NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE   IP               NODE           NOMINATED NODE   READINESS GATES
    kube-system   coredns-66bff467f8-g5lmj               1/1     Running   0          21h   10.244.0.3       k8s-master01   <none>           <none>
    kube-system   coredns-66bff467f8-ts7lw               1/1     Running   0          21h   10.244.0.2       k8s-master01   <none>           <none>
    kube-system   etcd-k8s-master01                      1/1     Running   0          21h   192.168.20.162   k8s-master01   <none>           <none>
    kube-system   kube-apiserver-k8s-master01            1/1     Running   0          21h   192.168.20.162   k8s-master01   <none>           <none>
    kube-system   kube-controller-manager-k8s-master01   1/1     Running   0          21h   192.168.20.162   k8s-master01   <none>           <none>
    kube-system   kube-flannel-ds-amd64-rn9vr            1/1     Running   0          20h   192.168.20.162   k8s-master01   <none>           <none>
    kube-system   kube-proxy-h44zq                       1/1     Running   0          21h   192.168.20.162   k8s-master01   <none>           <none>
    kube-system   kube-scheduler-k8s-master01            1/1     Running   0          21h   192.168.20.162   k8s-master01   <none>           <none>
    [root@k8s-master01 ~]# kubectl get pod -n kube-system
    NAME                                   READY   STATUS    RESTARTS   AGE
    coredns-66bff467f8-g5lmj               1/1     Running   0          21h
    coredns-66bff467f8-ts7lw               1/1     Running   0          21h
    etcd-k8s-master01                      1/1     Running   0          21h
    kube-apiserver-k8s-master01            1/1     Running   0          21h
    kube-controller-manager-k8s-master01   1/1     Running   0          21h
    kube-flannel-ds-amd64-rn9vr            1/1     Running   0          20h
    kube-proxy-h44zq                       1/1     Running   0          21h
    kube-scheduler-k8s-master01            1/1     Running   0          21h
    [root@k8s-master01 ~]# kubectl get pod --all-namespaces -w
    NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
    kube-system   coredns-66bff467f8-g5lmj               1/1     Running   0          21h
    kube-system   coredns-66bff467f8-ts7lw               1/1     Running   0          21h
    kube-system   etcd-k8s-master01                      1/1     Running   0          21h
    kube-system   kube-apiserver-k8s-master01            1/1     Running   0          21h
    kube-system   kube-controller-manager-k8s-master01   1/1     Running   0          21h
    kube-system   kube-flannel-ds-amd64-rn9vr            1/1     Running   0          20h
    kube-system   kube-proxy-h44zq                       1/1     Running   0          21h
    kube-system   kube-scheduler-k8s-master01            1/1     Running   0          21h
    
    

    至此完成K8S-kubeadmin部署。后续还有二进制部署,高可用部署文档。欢迎大家关注我。

    未经原作者允许不得转载本文内容

  • 相关阅读:
    MongoDB新存储引擎WiredTiger实现(事务篇)
    mongodb存储引擎WiredTiger
    WiredTiger 4.1.0 发布,MongoDB 存储引擎
    MongoDB存储引擎、索引 原
    MongoDB Wiredtiger存储引擎实现原理
    MongoDB 副本集
    MongoDB 聚合
    MongoDB 索引
    mongodb 开发规范
    MongoDB 基本操作 数据库、集合
  • 原文地址:https://www.cnblogs.com/duxingren/p/12809545.html
Copyright © 2011-2022 走看看