kubeadm init 问题和解决问题记录

安装 kubeadm:

使用阿里云来安装kube**

cat /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64

enabled=1

gpgcheck=0

安装

yum install kubectl kubeadm kubelet

 

执行初始化操作:

[root@k8s1 ~]# kubeadm init --ignore-preflight-errors=...

[init] Using Kubernetes version: v1.13.4

[preflight] Running pre-flight checks

[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'

[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.09.3. Latest validated version: 18.06

[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'

error execution phase preflight: [preflight] Some fatal errors occurred:

[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1

[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2

[ERROR Swap]: running with swap on is not supported. Please disable swap

[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

[root@k8s1 ~]#

 

解决思路:

警告1:docker service is not enabled, please run 'systemctl enable docker.service'

警告2:this Docker version is not on the list of validated versions: 18.09.3. Latest validated version: 18.06

--ignore-preflight-errors=…  这个参数会跳过对docker-ce的版本检查

警告3:kubelet service is not enabled, please run 'systemctl enable kubelet.service'

[root@rancher ~]# systemctl enable docker.service

[root@rancher ~]# systemctl enable kubelet.service

Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /etc/systemd/system/kubelet.service.

[root@rancher ~]#

 

错误1:/proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1

[root@rancher ~]# sysctl -a | grep net.*iptables

net.bridge.bridge-nf-call-iptables = 0



[root@rancher ~]# cat /etc/sysctl.conf | grep iptables

net.bridge.bridge-nf-call-iptables = 1

错误2: the number of available CPUs 1 is less than the required 2

设置虚拟机CPU核心数>1个即可

 

错误3:running with swap on is not supported. Please disable swap

关闭swap分区,并设置开启启动也关闭

[root@rancher ~]# free -h

              total        used        free      shared  buff/cache   available

Mem:            15G        1.4G         10G         11M        3.3G         13G

Swap:          7.9G          0B        7.9G

[root@rancher ~]# swapo

swapoff  swapon

[root@rancher ~]# swapoff -a

[root@rancher ~]# free -h

              total        used        free      shared  buff/cache   available

Mem:            15G        1.4G         10G         11M        3.3G         13G

Swap:            0B          0B          0B

[root@rancher ~]# vi /etc/fstab

[root@rancher ~]# cat /etc/fstab | grep swap

#/dev/mapper/centos-swap swap                    swap    defaults        0 0

[root@rancher ~]#

 

操作过程:

[root@k8s1 ~]# docker images

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE

k8s.gcr.io/kube-proxy                v1.13.4             fadcc5d2b066        2 weeks ago         80.3MB

k8s.gcr.io/kube-apiserver            v1.13.4             fc3801f0fc54        2 weeks ago         181MB

k8s.gcr.io/kube-controller-manager   v1.13.4             40a817357014        2 weeks ago         146MB

k8s.gcr.io/kube-scheduler            v1.13.4             dd862b749309        2 weeks ago         79.6MB

k8s.gcr.io/coredns                   1.2.6               f59dcacceff4        4 months ago        40MB

k8s.gcr.io/etcd                      3.2.24              3cab8e1b9802        6 months ago        220MB

k8s.gcr.io/pause                     3.1                 da86e6ba6ca1        15 months ago       742kB

[root@k8s1 ~]# kubeadm init --ignore-preflight-errors=...

[init] Using Kubernetes version: v1.13.4

[preflight] Running pre-flight checks

[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.09.3. Latest validated version: 18.06

[preflight] Pulling images required for setting up a Kubernetes cluster

[preflight] This might take a minute or two, depending on the speed of your internet connection

[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'

[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"

[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"

[kubelet-start] Activating the kubelet service

[certs] Using certificateDir folder "/etc/kubernetes/pki"

[certs] Generating "front-proxy-ca" certificate and key

[certs] Generating "front-proxy-client" certificate and key

[certs] Generating "etcd/ca" certificate and key

[certs] Generating "etcd/healthcheck-client" certificate and key

[certs] Generating "etcd/server" certificate and key

[certs] etcd/server serving cert is signed for DNS names [k8s1 localhost] and IPs [10.99.29.46 127.0.0.1 ::1]

[certs] Generating "etcd/peer" certificate and key

[certs] etcd/peer serving cert is signed for DNS names [k8s1 localhost] and IPs [10.99.29.46 127.0.0.1 ::1]

[certs] Generating "apiserver-etcd-client" certificate and key

[certs] Generating "ca" certificate and key

[certs] Generating "apiserver-kubelet-client" certificate and key

[certs] Generating "apiserver" certificate and key

[certs] apiserver serving cert is signed for DNS names [k8s1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.99.29.46]

[certs] Generating "sa" key and public key

[kubeconfig] Using kubeconfig folder "/etc/kubernetes"

[kubeconfig] Writing "admin.conf" kubeconfig file

[kubeconfig] Writing "kubelet.conf" kubeconfig file

[kubeconfig] Writing "controller-manager.conf" kubeconfig file

[kubeconfig] Writing "scheduler.conf" kubeconfig file

[control-plane] Using manifest folder "/etc/kubernetes/manifests"

[control-plane] Creating static Pod manifest for "kube-apiserver"

[control-plane] Creating static Pod manifest for "kube-controller-manager"

[control-plane] Creating static Pod manifest for "kube-scheduler"

[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"

[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s

[apiclient] All control plane components are healthy after 21.507721 seconds

[uploadconfig] storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace

[kubelet] Creating a ConfigMap "kubelet-config-1.13" in namespace kube-system with the configuration for the kubelets in the cluster

[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "k8s1" as an annotation

[mark-control-plane] Marking the node k8s1 as control-plane by adding the label "node-role.kubernetes.io/master=''"

[mark-control-plane] Marking the node k8s1 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]

[bootstrap-token] Using token: e3kq7v.an0evu50f9m7nlxz

[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles

[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials

[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token

[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster

[bootstraptoken] creating the "cluster-info" ConfigMap in the "kube-public" namespace

[addons] Applied essential addon: CoreDNS

[addons] Applied essential addon: kube-proxy



Your Kubernetes master 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/



You can now join any number of machines by running the following on each node

as root:



  kubeadm join 10.99.29.46:6443 --token e3kq7v.an0evu50f9m7nlxz --discovery-token-ca-cert-hash sha256:9e148d691b31dd47d8e9bc507fdabef0b04f7458f203827a5bd9da7eae98495a



[root@k8s1 ~]#

 

你可能感兴趣的:(linux)