# 前提 安装 docker
# 配置K8s安装源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
# 临时关闭 selinux
setenforce 0
# 安装
yum install -y kubelet kubeadm kubectl
# 由于官网未开放同步方式, 可能会有索引gpg检查失败的情况, 这时请用以下安装命令
yum install -y --nogpgcheck kubelet kubeadm kubectl
#配置开机自启
systemctl enable kubelet && systemctl start kubelet
# 初始化时错误
[ERROR CRI]: container runtime is not running: output: E0910 18:37:12.496739 2884 remote_runtime.go:925]
"Status from runtime service failed" err="rpc error: code = Unimplemented desc =unknown service runtime.v1alpha2.RuntimeService"
# 解决# 1)查看容器配置:CRI、是否被禁用
cat /etc/containerd/config.toml
# 2)移除
rm -fr /etc/containerd/config.toml
# 3)重启容器
systemctl restart containerd
# 4)查看容器状态
systemctl status containerd.service
# 初始化时错误:
Unfortunately, an error has occurred:
timed out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- 'systemctl status kubelet'
- 'journalctl -xeu kubelet'
Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.
Here is one example how you may list all running Kubernetes containers by using crictl:
- 'crictl --runtime-endpoint unix:///var/run/containerd/containerd.sock ps -a | grep kube | grep -v pause'
Once you have found the failing container, you can inspect its logs with:
- 'crictl --runtime-endpoint unix:///var/run/containerd/containerd.sock logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
To see the stack trace of this error execute with --v=5 or higher
# 解决方案# 1) 配置docker
cat <<EOF > /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors":["https://ud6340vz.mirror.aliyuncs.com"]
}
EOF
# 2) 重启生效 : docker
systemctl daemon-reload
systemctl restart docker
# 3) 重置配置 : kubeadm
kubeadm reset
kubeadm init \
--image-repository=registry.aliyuncs.com/google_containers \
--config /etc/kubernetes/kubeadm-config.yaml
kubeadm init phase preflight --config /etc/kubernetes/kubeadm-config.yaml
hostnamectl set-hostname node1
Kubenetes 组件
kubelet
运行在cluster所有节点上,负责启动POD和容器。
kubeadm
用于初始化cluster
kubectl
Kubenetes命令行工具,部署和应用,查看各种资源、创建、删除和更新组件。
Ingress
统一路由
常用命令
# Master --》 Servcie --》 deployment --》 pod --》 容器(Docker)
# 命令空间
kubectl create namespace bpg-dev
kubectl delete namespace bpg-dev
# 查看节点
kubectl get nodes
kubectl get cm -n bpg-uat
kubectl get cm -owide -n bpg-uat -owide
kubectl get svc,pod -owide -n bpg-uat
# 容器
kubectl create
kubectl get service #查看
kubectl delete service soul-nginx # 删除
# 控制器
kubectl create deployment soul-nginx # 创建
kubectl apply -f deployment.yml
kubectl get deployment/deploy # 查看
kubectl delete deployment/deploy soul-nginx # 删除
# pod
kubectl apply -f ./auth-frontend/deployment.yml # 创建pod
kubectl get pods # 查看所有的pod
kubectl get pods -n bpg-dev # 命令空间筛选
kubectl describe pod soul-nginx-d4b56f745-vljz9 -n bpg-uat # 查看pod详细信息
kubectl delete pod soul-nginx-d4b56f745-vljz9 # 删除pod
# 配置
kubectl get configmaps -n uat-bpg
kubectl describe configmaps bpg-config
kubectl create -f tpi-web-config.yml
# 日志# 以文件方式输出
kubectl logs --since=3h ip-emr-web-deployment-b55944f98-848w9 -n bpg > ip-emr-20221128.log
kubectl logs --since-time="2022-12-09T22:00:00+00:00" ip-emr-web-deployment-854c8686dc-vb5k6 -n bpg > ip-emr-20221128.log
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南