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

k8s-临时容器学习

临时容器学习

  • 1. 什么是临时容器
  • 2. 实验

1. 什么是临时容器

在官网:https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/ephemeral-containers/ 中有介绍

临时容器是用于调试Pod中崩溃的容器或者不具备调试工具,比如在一个运行着业务的容器中,加入一个带有tcpdump抓包工具的容器,获取数据包分析。

2. 实验

创建一个Pod

kubectl run nginx --image=nginx --restart=Never

将带有tcpdump工具的容器加入到nginx

kubectl debug -it nginx --image=nicolaka/netshoot --target=nginx 
[root@k8s-master01 ~]# kubectl debug -it nginx --image=nicolaka/netshoot --target=nginx
Targeting container "nginx". If you don't see processes from this container it may be because the container runtime doesn't support this feature.
--profile=legacy is deprecated and will be removed in the future. It is recommended to explicitly specify a profile, for example "--profile=general".
Defaulting debug container name to debugger-x6qrr.
All commands and output from this session will be recorded in container logs, including credentials and sensitive information passed through the command prompt.
If you don't see a command prompt, try pressing enter.dP            dP                           dP88            88                           88
88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P
88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88
88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88
dP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dPWelcome to Netshoot! (github.com/nicolaka/netshoot)
Version: 0.14
nginx  ~ 
  • kubectl debug :添加调试容器
  • -it nginx:指向Pod名
  • --target=nginx : 指向容器名
  • --image=nicolaka/netshoot:用于调试的镜像名称

通过窗口打印可以看出,创建了一个临时容器debugger-x6qrr

在调试窗口使用tcpdump抓取本地接口的流量:

nginx  ~  tcpdump -i eth0 port 80 -n
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
01:59:38.396705 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [S], seq 3030192777, win 64860, options [mss 1410,sackOK,TS val 1255526443 ecr 0,nop,wscale 7], length 0
01:59:38.396766 IP 10.244.2.10.80 > 10.244.0.0.57200: Flags [S.], seq 3346276368, ack 3030192778, win 64308, options [mss 1410,sackOK,TS val 1694919818 ecr 1255526443,nop,wscale 7], length 0
01:59:38.397115 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [.], ack 1, win 507, options [nop,nop,TS val 1255526444 ecr 1694919818], length 0
01:59:38.397115 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [P.], seq 1:75, ack 1, win 507, options [nop,nop,TS val 1255526444 ecr 1694919818], length 74: HTTP: GET / HTTP/1.1
01:59:38.397166 IP 10.244.2.10.80 > 10.244.0.0.57200: Flags [.], ack 75, win 502, options [nop,nop,TS val 1694919819 ecr 1255526444], length 0
01:59:38.397362 IP 10.244.2.10.80 > 10.244.0.0.57200: Flags [P.], seq 1:239, ack 75, win 502, options [nop,nop,TS val 1694919819 ecr 1255526444], length 238: HTTP: HTTP/1.1 200 OK
01:59:38.397452 IP 10.244.2.10.80 > 10.244.0.0.57200: Flags [P.], seq 239:854, ack 75, win 502, options [nop,nop,TS val 1694919819 ecr 1255526444], length 615: HTTP
01:59:38.397786 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [.], ack 239, win 506, options [nop,nop,TS val 1255526445 ecr 1694919819], length 0
01:59:38.397832 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [.], ack 854, win 502, options [nop,nop,TS val 1255526445 ecr 1694919819], length 0
01:59:38.398417 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [F.], seq 75, ack 854, win 502, options [nop,nop,TS val 1255526445 ecr 1694919819], length 0
01:59:38.398507 IP 10.244.2.10.80 > 10.244.0.0.57200: Flags [F.], seq 854, ack 76, win 502, options [nop,nop,TS val 1694919820 ecr 1255526445], length 0
01:59:38.398786 IP 10.244.0.0.57200 > 10.244.2.10.80: Flags [.], ack 855, win 502, options [nop,nop,TS val 1255526446 ecr 1694919820], length 0

文章转载自:

http://5hQWFicY.qqkLk.cn
http://wx0k9z2M.qqkLk.cn
http://DEBEALot.qqkLk.cn
http://w4EQIcCG.qqkLk.cn
http://cx042ljk.qqkLk.cn
http://vYj1tcSl.qqkLk.cn
http://YUJwqKgK.qqkLk.cn
http://b6dWhtu9.qqkLk.cn
http://IRkoHzQl.qqkLk.cn
http://xCfW6mCp.qqkLk.cn
http://LW2SdcQl.qqkLk.cn
http://O5JIH6xg.qqkLk.cn
http://ZyF9YseU.qqkLk.cn
http://hFMVY0kO.qqkLk.cn
http://hJtYZoxg.qqkLk.cn
http://d9Zbm85i.qqkLk.cn
http://zyh9JDp3.qqkLk.cn
http://9sFZ4mPi.qqkLk.cn
http://23XbMXLa.qqkLk.cn
http://2lC50hiN.qqkLk.cn
http://yZrkAgml.qqkLk.cn
http://GUrms6oV.qqkLk.cn
http://1oHone0V.qqkLk.cn
http://e11hZCx1.qqkLk.cn
http://H2gyLzPm.qqkLk.cn
http://ZltvVAyy.qqkLk.cn
http://dFDjn6Eo.qqkLk.cn
http://dDaCpM7H.qqkLk.cn
http://nFycZThd.qqkLk.cn
http://6lxLkp3Q.qqkLk.cn
http://www.dtcms.com/a/379796.html

相关文章:

  • uni-app 根据用户不同身份显示不同的tabBar
  • ubuntu18.04安装PCL1.14
  • Ubuntu 系统下 Anaconda 完整安装与环境配置指南(附常见问题解决)
  • 网络链路分析笔记mtr/traceroute
  • 在 Ubuntu 系统中利用 conda 创建虚拟环境安装 sglang 大模型引擎的完整步骤、版本查看方法、启动指令及验证方式
  • 基带与射频的区别与联系
  • 《企业安全运营周报》模板 (极简实用版)​
  • opencv基于SIFT特征匹配的简单指纹识别系统实现
  • Node.js 操作 Elasticsearch (ES) 的指南
  • 使用tree命令导出文件夹/文件的目录树( Windows 和 macOS)
  • Spring缓存(二):解决缓存雪崩、击穿、穿透问题
  • LabVIEW加载 STL 模型至 3D 场景 源码见附件
  • Tessent_ijtag_ug——第 4 章 ICL 提取(2)
  • 前端WebSocket实时通信实现
  • 2025年- H133-Lc131. 反转字符串(字符串)--Java版
  • 萨顿四条原则
  • NumPy 2.x 完全指南【三十八】伪随机数生成器
  • GitHub 热榜项目 - 日榜(2025-09-12)
  • O3.3 opencv指纹识别
  • 在线会议系统是一个基于Vue3 + Spring Boot的现代化在线会议管理平台,集成了视频会议、实时聊天、AI智能助手等多项先进技术。
  • 每日一算:打家劫舍
  • MemGPT: Towards LLMs as Operating Systems
  • MySQL与PostgreSQL核心区别对比
  • Redis基础命令速查:从连接到数据操作,新手也能上手
  • 信息安全工程师考点-网络安全法律与标准
  • 阿里云OSS vs 腾讯云COS vs AWS S3:对象存储价格与性能深度对比
  • vim复制本地到linux服务器上,换行缩进过大,不对的问题
  • 【贪心算法】day9
  • HarmonyOS 5分布式数据管理初探:实现跨设备数据同步
  • 【Unity UGUI 交互组件——InputFild(TMP版本)(11)】