使用kubeadm安装k8s时,有一步骤时下载images操作,一般度很多使用的方法是:使用docker images下载镜像再次tag镜像的名称,然后初始化的时候在配置集群子ip信息等

如下:

        1.设置kubelet国内的pause镜像
        cat >/etc/sysconfig/kubelet< 
  

   在此给大家介绍一个简单的方法

        #在获得vip的master节点上生成创始化配置文件 

        kubeadm config print init-defaults > kubeadm-init.yaml  #必须是yaml格式的文件

            apiVersion: kubeadm.k8s.io/v1beta2
            bootstrapTokens:
            - groups:
              - system:bootstrappers:kubeadm:default-node-token
              token: abcdef.0123456789abcdef
              ttl: 24h0m0s
              usages:
              - signing
              - authentication
            kind: InitConfiguration
            localAPIEndpoint:
              advertiseAddress: 192.168.191.30     #本机ip
              bindPort: 6443
            nodeRegistration:
              criSocket: /var/run/dockershim.sock
              name: k8s-3
              taints:
              - effect: NoSchedule
                key: node-role.kubernetes.io/master
            ---
            apiServer:
              timeoutForControlPlane: 4m0s
            apiVersion: kubeadm.k8s.io/v1beta2
            certificatesDir: /etc/kubernetes/pki
            clusterName: kubernetes
            controlPlaneENDPOINT: "192.168.191.30:58443"      #此项如没有请自行添加,此处请填写你的高可用的VIP地址及端口
            controllerManager: {}
            dns:
              type: CoreDNS
            etcd:
              local:
                dataDir: /var/lib/etcd
            imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers   #国内阿里的k8s镜像元
            kind: ClusterConfiguration
            kubernetesVersion: v1.17.4                            # 镜像的版本
            networking:
              dnsDomain: cluster.local
              podSubnet: 10.244.0.0/16                          # pod的网段,没有该设置,需要添加
              serviceSubnet: 10.96.0.0/12
            scheduler: {}
            ---  
            #使用ipvs  ,需要自己安装ipvsadm
            apiVersion: kubeproxy.config.k8s.io/v1alpha1
            kind: KubeProxyConfiguration
            featureGates:
              SupportIPVSProxyMode: true
            mode: ipvs

        #查看需要的镜像   

[root@k8s-3 ~]# kubeadm config images list 
W0323 17:27:46.000689   63185 validation.go:28] Cannot validate kube-proxy config - no validator is available   # 忽略
W0323 17:27:46.001023   63185 validation.go:28] Cannot validate kubelet config - no validator is available
k8s.gcr.io/kube-apiserver:v1.17.4
k8s.gcr.io/kube-controller-manager:v1.17.4
k8s.gcr.io/kube-scheduler:v1.17.4
k8s.gcr.io/kube-proxy:v1.17.4
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.4.3-0
k8s.gcr.io/coredns:1.6.5

        #拉取需要的镜像

        kubeadm config images pull --config kubeadm-init.yaml

        #初始化

        kubeadm init  --config kubeadm-init.yaml