当前位置: 首页 > news >正文

K8S容器持续Terminating无法正常关闭(sider-car容器异常,微服务容器正常)

问题

K8S上出现大量持续terminating的Pod,无法通过常规命令删除。需要编写脚本批量强制删除持续temminating的Pod:contribution-xxxxxxx。

解决

  1. 获取terminating状态的pod名称的命令:
# 获取media命名空间下,名称带contribution,运行状态除了正常Runing的Pod信息,并只打印第一列Pod名称。
kubectl get pod -n media |grep contribution|grep -v Running|awk '{print $1}'
  1. 强制删除pod的命令:
# 强制删除media命令空间下,名为 contribution-7d57bdb6d7-krksf的Pod。
kubectl delete pods contribution-7d57bdb6d7-krksf --grace-period=0 --force -n media
  1. 编写脚本对大量terminating的同名容器强制删除:
vim 72_ForceDeleteTerminatingPods.sh

脚本具体内容如下:

#!/bin/bash
for POD in `kubectl get pod -n media |grep contribution|grep -v Running|awk '{print $1}'`
dokubectl delete pods ${POD} --grace-period=0 --force -n media
done
  1. 执行结果
[sysma@prod-k8s-0001 ~]$ chmod +x 72_ForceDeleteTerminatingPods.sh 
[sysma@prod-k8s-0001 ~]$ ./72_ForceDeleteTerminatingPods.sh 
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-56695dbc4-dq2bc" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-58c5f57b54-wkkfs" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-5f646dd579-tjcf2" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-7499fc9b64-2v8tm" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-75d5f4c94c-q42hq" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-76d45d4bcb-5wtsr" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-784b5569b7-ggdx9" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-7d57bdb6d7-krksf" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-7d57bdb6d7-qjn4w" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-7ff99c7d9d-8p6bf" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-7ff99c7d9d-vfg72" force deleted
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "contribution-b69bb846d-trwx2" force deleted

参考截图

在这里插入图片描述
在这里插入图片描述

结束

http://www.lryc.cn/news/224714.html

相关文章:

  • Spring 循环依赖
  • MySQL 8.0.13升级到8.0.35记录 .NET
  • flink udtaf 常年不能用
  • 路由汇总的四要点
  • HashMap存值、取值及哈希碰撞原理分析
  • 【SVN】
  • 编程语言,脚本语言
  • 探索双十一:从技术角度剖析电商狂欢节
  • Ubuntu LTS 坚持 10 年更新不动摇
  • Python将多个相同格式的变量存储到列表中
  • 前端字符串转数组对象实现方式-开发bug总结6
  • 99 颜色分类
  • 计算机视觉与深度学习 | 基于GPS/BDS多星座加权图因子优化的行人智能手机导航
  • 低代码平台,业务开发的“银弹”
  • 补偿 FIR 滤波器引入的延迟
  • 图数据库Neo4j详解
  • 系列一、Shiro概述
  • SpringCloudAlibaba——Sentinel
  • Java编写简易rabbitmq生产者与消费者
  • 3.0.3版vsftpd所支持的FTP命令
  • OTA包添加自定义内容
  • Luatos Air700 改变BL0942串口波特率
  • 不可忽视的国外服务器地址IP选择指南
  • C语言 预处理详解
  • c++ async 使用详解,创建异步任务的多种方法
  • 万物皆数——用matlab求解二阶微分方程
  • jmeter接口自动化部署jenkins教程
  • 前端js实现将数组对象组装成自己需要的属性,或者去掉对象中不必要的属性
  • MeterSphere 任意文件读取漏洞(CVE-2023-25814)
  • 设计模式-01-单例设计模式