images installation and init operation during k8s installation in kubadm mode

Keywords: Operation & Maintenance Docker Kubernetes kubelet network

When using kubeadm to install k8s, there is a step to download images. Generally, many methods are used: use docker images to download the image name and tag the image name again, and then configure the cluster sub ip information during initialization

As follows:

        1.Set up kubelet Domestic pause image
        cat >/etc/sysconfig/kubelet<<EOF
        KUBELET_EXTRA_ARGS="--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"
        EOF
        
        2.Kubeadm Initialization
        #There is no image file in the initialization error prompt. You need to download it before initialization (the following script only applies to version 1.15.3)
        name=(kube-apiserver:v1.15.3 Blank space kube-controller-manager:v1.15.3 Blank space kube-scheduler:v1.15.3 Blank space kube-proxy:v1.15.3 Blank space pause:3.1 Blank space etcd:3.3.10 coredns:1.3.1)
        #Change the name of the mirror
        for info in ${name[@]}
        do
        docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$info
        docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$info   k8s.gcr.io/$info
        docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$info
        Done
        
        #Initialize master
        #kubectl --version#View version
        #kubeadm init --kubernetes-version=v1.15.3 --pod-network-cidr=10.1.0.0/16 #--apiserver-advertise-address=192.168.191.11 --ignore-preflight-errors=Swap

Here is a simple method

Generate the creation profile on the master node that gets vip

Kubeadm config print init defaults > kubeadm init.yaml? Must be a file in yaml format

            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     #Native 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"      #If this item is not available, please add it by yourself. Please fill in your highly available VIP address and port here
            controllerManager: {}
            dns:
              type: CoreDNS
            etcd:
              local:
                dataDir: /var/lib/etcd
            imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers   #k8s image element of domestic Alibaba
            kind: ClusterConfiguration
            kubernetesVersion: v1.17.4                            #Version of the image
            networking:
              dnsDomain: cluster.local
              podSubnet: 10.244.0.0/16                          #pod network segment. There is no such setting. It needs to be added
              serviceSubnet: 10.96.0.0/12
            scheduler: {}
            ---  
            #To use ipvs, you need to install ipvsadm yourself
            apiVersion: kubeproxy.config.k8s.io/v1alpha1
            kind: KubeProxyConfiguration
            featureGates:
              SupportIPVSProxyMode: true
            mode: ipvs

View the required image

[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   #Neglect
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

Pull the required image

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

Initialization

        kubeadm init  --config kubeadm-init.yaml


Posted by porta325 on Mon, 23 Mar 2020 08:21:10 -0700