K8S--环境运维记录一
K8S使用
K8S使用过程中的命令与错误整理
-
常用命令
-
利用configmap创建配置信息文件
kubectl create configmap -n eureka eureka-config --from-file=application.properties
-
修改配置文件后,删除文件,重新创建
kubectl delete configmap -n eureka eureka-config
kubectl create configmap -n eureka eureka-config --from-file=application.properties
待使用命令:
kubectl create --save-config cm config1 --from-file ./config.yaml -o yaml --dry-run | kubectl apply -f -
3)查看pod信息(有命名空间限制要加上)
kubectl describe pod -n eureka eureka-0
4)重启pod--yaml文件替换
kubectl replace --force -f eureka.yaml
5)查看pod日志
kubectl logs eureka-0 -n eureka
6)查看命名空间下的pods
kubectl get pod -n <namespace>
例如:kubectl get pod -n ai-base
7)查看pod下详情
kubectl describe pod <pod_name> -n <namespace>
例如:kubectl describe pod aip-operation-service-68b9f79497-zv2qh -n ai-base
8)查看pod下某一容器的日志
kubectl logs --tail=<查看行数> <pod_name> -n <namespace> -c <container_name>
例如:kubectl logs --tail=100 aip-operation-service-68b9f79497-zv2qh -n ai-base -c aip-operation-service
9)查看pod下容器名称
kubectl get pods <pod名称> -n <命名空间> -o jsonpath={.spec.containers[*].name}
10)强制删除pod
kubectl delete pod 【aip-operation-service-85489d6c4b-wh5xt -pod name】 --force --grace-period=0 -n 【ai-base-命名空间】
-
常用操作
从制品库拉取镜像
-
登录
docker login http://172.16.39.242:8082
-
拉取
docker pull 172.16.39.242:8082/bdp-docker-release/bdp/opd/open-api-gateway:1.1.5
修改在线pod配置并滚动更新
1)修改配置
kubectl edit configmaps -n ai-base aip-operation-portal-config
2)滚动更新
kubectl rollout restart deployment -n ai-base aip-operation-portal
3)查看更新pod状态
watch kubectl get pod -n ai-base
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!