# Copyright 2017 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
kind:Deployment apiVersion:apps/v1 metadata: labels: k8s-app:kubernetes-dashboard name:kubernetes-dashboard namespace:kubernetes-dashboard spec: replicas:1 revisionHistoryLimit:10 selector: matchLabels: k8s-app:kubernetes-dashboard template: metadata: labels: k8s-app:kubernetes-dashboard spec: securityContext: seccompProfile: type:RuntimeDefault containers: -name:kubernetes-dashboard image:kubernetesui/dashboard:v2.7.0 imagePullPolicy:Always ports: -containerPort:8443 protocol:TCP args: ---auto-generate-certificates ---namespace=kubernetes-dashboard # Uncomment the following line to manually specify Kubernetes API server Host # If not specified, Dashboard will attempt to auto discover the API server and connect # to it. Uncomment only if the default does not work. # - --apiserver-host=http://my-address:port volumeMounts: -name:kubernetes-dashboard-certs mountPath:/certs # Create on-disk volume to store exec logs -mountPath:/tmp name:tmp-volume livenessProbe: httpGet: scheme:HTTPS path:/ port:8443 initialDelaySeconds:30 timeoutSeconds:30 securityContext: allowPrivilegeEscalation:false readOnlyRootFilesystem:true runAsUser:1001 runAsGroup:2001 volumes: -name:kubernetes-dashboard-certs secret: secretName:kubernetes-dashboard-certs -name:tmp-volume emptyDir: {} serviceAccountName:kubernetes-dashboard nodeSelector: "kubernetes.io/os":linux # Comment the following tolerations if Dashboard must not be deployed on master tolerations: -key:node-role.kubernetes.io/master effect:NoSchedule
[root@node02 ~]# crictl info WARN[0000] runtime connect using default endpoints: [unix:///var/run/dockershim.sock unix:///run/containerd/containerd.sock unix:///run/crio/crio.sock unix:///var/run/cri-dockerd.sock]. As the default settings are now deprecated, you should set the endpoint instead. E0802 21:31:57.00996412229 remote_runtime.go:616] "Status from runtime service failed" err="rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/dockershim.sock: connect: no such file or directory\"" FATA[0000] getting status of runtime: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial unix /var/run/dockershim.sock: connect: no such file or directory"
[root@node01 ~]# /opt/cni/bin/flannel CNI Plugin flannel version v1.2.0 (linux/amd64) commit 6464faac built on 2023-07-21T15:07:42Z CNI protocol versions supported: 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.4.0, 1.0.0
出现”failed to find plugin "portmap" in path [/opt/cni/bin]”错误,是未配置cni plugin
下载cni plugin并解压到/opt/cni/bin
1
[root@node01 ~]# tar -xvf cni-plugins-linux-amd64-v1.2.0.tgz -C /opt/cni/bin/
5.3 初始化超时、失败
1 2 3 4 5 6
I0802 21:34:55.0724912121waitcontrolplane.go:83] [wait-control-plane] Waiting for the API server to be healthy [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 [kubelet-check] Initial timeout of 40s passed.
Unfortunately, an error has occurred: timed out waiting for the condition
查看日志
1 2 3 4 5 6 7 8
journalctl -xeu kubelet 有如下报错 Aug 02 22:18:51 node01 kubelet[2279]: E0802 22:18:51.106004 2279 remote_runtime.go:176] "RunPodSandbox from runtime service failed" err="rpc error: code = Unknown desc = failed pulling image \"registry.k8s.io/pause:3.6\": Error response from daemon: Get \"https://asia-east1-docker.pkg.> Aug 02 22:18:51 node01 kubelet[2279]: E0802 22:18:51.106060 2279 kuberuntime_sandbox.go:72] "Failed to create sandbox for pod" err="rpc error: code = Unknown desc = failed pulling image \"registry.k8s.io/pause:3.6\": Error response from daemon: Get \"https://asia-east1-docker.pkg.dev/v> Aug 02 22:18:51 node01 kubelet[2279]: E0802 22:18:51.106091 2279 kuberuntime_manager.go:1122] "CreatePodSandbox for pod failed" err="rpc error: code = Unknown desc = failed pulling image \"registry.k8s.io/pause:3.6\": Error response from daemon: Get \"https://asia-east1-docker.pkg.dev/> Aug 02 22:18:51 node01 kubelet[2279]: E0802 22:18:51.106158 2279 pod_workers.go:1294] "Error syncing pod, skipping" err="failed to \"CreatePodSandbox\" for \"kube-scheduler-node01_kube-system(65a3cbca3914ccd9af1a70265906ca9a)\" with CreatePodSandboxError: \"Failed to create sandbox for> failed, error" error="failed to get sandbox image \"k8s.gcr.io/pause:3.6\": failed to pull image \"k8s.gcr.io/pause:3.6\": failed to pull and unpack image \"k8s.gcr.io/pause:3.6\": failed to resolve reference \"k8s.gcr.io/pause:3.6\": failed to do request: Head \"https://k8s.gcr.io/v2/pause/manifests/3.6\": dial tcp 108.177.125.82:443: i/o timeout" Jul 05 19:08:30 k8s-testing01-190 containerd[13788]: time="2022-07-05T19:08:30.696324518+08:00" level=info msg="trying next host" error="failed to do request: Head \"https://k8s.gcr.io/v2/pause/manifests/3.6\": dial tcp 108.177.125.82:443: i/o timeout" host=k8s.gcr.io
网络问题,将镜像下载到本地,重新按照上面步骤打Tag
5.4 初始化完成后出现以下问题
1 2 3 4 5 6 7 8 9 10 11 12 13
1、执行kubectl get cs,scheduler和controller-manager为Unhealthy状态! --- --- 禁用了--port 如下: $ kubectl get cs Warning: v1 ComponentStatus is deprecated in v1.19+ NAME STATUS MESSAGE ERROR scheduler Unhealthy Get"http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused controller-manager Unhealthy Get"http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused etcd-2 Healthy {"health":"true"} etcd-1 Healthy {"health":"true"} etcd-0 Healthy {"health":"true"}
2、执行kubectl get node,node是NotReady状态 --- --- 没有安装网络,参考3.4 3、执行kubectl get po,pod中coredns是Pending状态! --- --- 没有安装网络,参考3.4
[root@node01 ~]# kubectl get cs Warning: v1 ComponentStatus is deprecated in v1.19+ NAME STATUS MESSAGE ERROR controller-manager Healthy ok scheduler Healthy ok etcd-0 Healthy {"health":"true"}