[init] Using Kubernetes version: v1.15.1 [preflight] Running pre-flight checks [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.21. Latest validated version: 18.09 [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 "ca" certificate and key [certs] Generating "apiserver" certificate and key [certs] apiserver serving cert is signed for DNS names [k8s-master kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.111.201] [certs] Generating "apiserver-kubelet-client" certificate and key [certs] Generating "etcd/ca" certificate and key [certs] Generating "etcd/server" certificate and key [certs] etcd/server serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.111.201 127.0.0.1 ::1] [certs] Generating "etcd/healthcheck-client" certificate and key [certs] Generating "apiserver-etcd-client" certificate and key [certs] Generating "etcd/peer" certificate and key [certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.111.201 127.0.0.1 ::1] [certs] Generating "front-proxy-ca" certificate and key [certs] Generating "front-proxy-client" certificate and key [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 38.004014 seconds [upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace [kubelet] Creating a ConfigMap "kubelet-config-1.15" in namespace kube-system with the configuration for the kubelets in the cluster [upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace [upload-certs] Using certificate key: c7d4324264d6989efe538e2a699a415b7024a020e07a7925b37decc4cb16b92d [mark-control-plane] Marking the node k8s-master as control-plane by adding the label "node-role.kubernetes.io/master=''" [mark-control-plane] Marking the node k8s-master as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule] [bootstrap-token] Using token: abcdef.0123456789abcdef [bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles [bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials [bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token [bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster [bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace [addons] Applied essential addon: CoreDNS [kubelet-check] Initial timeout of 40s passed. [addons] Applied essential addon: kube-proxy
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
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:
namespace/kube-flannel created clusterrole.rbac.authorization.k8s.io/flannel created clusterrolebinding.rbac.authorization.k8s.io/flannel created serviceaccount/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created
[root@k8s-master flannel]# kubectl get po -n kube-system NAME READY STATUS RESTARTS AGE coredns-5c98db65d4-7ndgf 0/1 Pending 0 39m coredns-5c98db65d4-jmgkk 0/1 Pending 0 39m etcd-k8s-master 1/1 Running 0 38m kube-apiserver-k8s-master 1/1 Running 0 38m kube-controller-manager-k8s-master 1/1 Running 0 38m kube-proxy-fqjgn 1/1 Running 0 39m kube-scheduler-k8s-master 1/1 Running 0 38m
Q1: [root@k8s-master src]# kubeadm init --config=kubeadm-config.yaml --upload-certs |tee kubeadm-init.log W1127 22:06:01.251107 2430 initconfiguration.go:305] unknown configuration schema.GroupVersionKind{Group:"kubeporxy.config.k8s.io", Version:"v1alpha1", Kind:"KubeProxyConfiguration"} W1127 22:06:01.251311 2430 initconfiguration.go:331] [config] WARNING: Ignored YAML document with GroupVersionKind kubeporxy.config.k8s.io/v1alpha1, Kind=KubeProxyConfiguration [init] Using Kubernetes version: v1.25.0 [preflight] Running pre-flight checks error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR CRI]: container runtime is not running: output: E1127 22:06:01.290159 2440 remote_runtime.go:948] "Status from runtime service failed" err="rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService" time="2022-11-27T22:06:01+08:00" level=fatal msg="getting status of runtime: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService" , error: exit status 1 [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` To see the stack trace of this error execute with --v=5 or higher A1: rm -rf /etc/containerd/config.toml systemctl restart containerd
Q2: Nov 27 22:03:14 k8s-master kubelet: F1127 22:03:14.712519 41018 server.go:273] failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: "systemd" is different from docker cgroup driver: "cgroupfs" A2: kubernetes官方推荐docker等使用systemd作为cgroupdriver,保持两个文件里的配置相同 修改docker配置文件/etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" } } 修改kubnetes 配置文件/var/lib/kubelet/config.yaml cgroupDriver: systemd
Q3: Nov 27 23:32:37 k8s-master kubelet[107375]: E1127 23:32:37.687073 107375 pod_workers.go:190] Error syncing pod ecae9d12d3610192347be3d1aa5aa552 ("kube-scheduler-k8s-master_kube-system(ecae9d12d3610192347be3d1aa5aa552)"), skipping: failed to "CreatePodSandbox" for "kube-scheduler-k8s-master_kube-system(ecae9d12d3610192347be3d1aa5aa552)" with CreatePodSandboxError: "CreatePodSandbox for pod \"kube-scheduler-k8s-master_kube-system(ecae9d12d3610192347be3d1aa5aa552)\" failed: rpc error: code = Unknown desc = failed to create a sandbox for pod \"kube-scheduler-k8s-master\": Error response from daemon: Conflict. The container name \"/k8s_POD_kube-scheduler-k8s-master_kube-system_ecae9d12d3610192347be3d1aa5aa552_3\" is already in use by container \"7dcb605b10a59a09aa084a73dcf1d5ab68cc9a27ad6a89aa616ac0e6e42c540e\". You have to remove (or rename) that container to be able to reuse that name." Nov 27 23:32:37 k8s-master kubelet[107375]: E1127 23:32:37.741283 107375 kubelet.go:2248] node "k8s-master" not found Nov 27 23:32:37 k8s-master kubelet[107375]: E1127 23:32:37.841936 107375 kubelet.go:2248] node "k8s-master" not found