K8S--环境运维记录一

K8S使用

K8S使用过程中的命令与错误整理

  1. 常用命令

  1. 利用configmap创建配置信息文件

kubectl create configmap -n eureka eureka-config --from-file=application.properties

  1. 修改配置文件后,删除文件,重新创建

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-命名空间】

 

  1. 常用操作

从制品库拉取镜像

  1. 登录

docker login http://172.16.39.242:8082

  1. 拉取

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

posted @   岁月如歌_九  阅读(65)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示