[kubernetes]-kubernetes安装kubectl debug

安装kube-debug

下载kubectl-debug的安装包

链接: https://pan.baidu.com/s/1MMzryo7H-3OK0B2tJMHpRw 密码: o39o

官网地址https://github.com/aylei/kubectl-debug

tar zxvf kubectl-debug_0.1.1_linux_amd64.tar.gz kubectl-debug
mv kubectl-debug /usr/local/bin/

kubectl debug -h

配置config文件
cat > ~/.kube/debug-config << EOF
# debug agent listening port(outside container)
# default to 10027
agentPort: 10027

# whether using agentless mode
# default to true
agentless: true
# namespace of debug-agent pod, used in agentless mode
# default to 'default'
agentPodNamespace: default
# prefix of debug-agent pod, used in agentless mode
# default to  'debug-agent-pod'
agentPodNamePrefix: debug-agent-pod
# image of debug-agent pod, used in agentless mode
# default to 'aylei/debug-agent:latest'
agentImage: aylei/debug-agent:latest

# daemonset name of the debug-agent, used in port-forward
# default to 'debug-agent'
debugAgentDaemonset: debug-agent
# daemonset namespace of the debug-agent, used in port-forwad
# default to 'default'
debugAgentNamespace: kube-system
# whether using port-forward when connecting debug-agent
# default true
portForward: true
# image of the debug container
# default as showed
image: nicolaka/netshoot:latest
# start command of the debug container
# default ['bash']
command:
- '/bin/bash'
- '-l'
# private docker registry auth kuberntes secret
# default RegistrySecretName is kubectl-debug-registry-secret
# default namspace is default
RegistrySecretName: my-debug-secret
RegistrySecretNamespace: debug
# in agentless mode, you can set the agent pod's resource limits/requests:
# default is not set
agentCpuRequests: ""
agentCpuLimits: ""
agentMemoryRequests: ""
agentMemoryLimits: ""
# in fork mode, if you want the copied pod retains the labels of the original pod, you can change this params
# format is []string
# If not set, this parameter is empty by default (Means that any labels of the original pod are not retained, and the labels of the copied pods are empty.)
forkPodRetainLabels: []
# You can disable SSL certificate check when communicating with image registry by
# setting registrySkipTLSVerify to true.
registrySkipTLSVerify: false
# You can set the log level with the verbosity setting
verbosity : 0
EOF
# 以下命令都可以
kubectl debug haozhuo-hm-dp-0 -c haozhuo-hm -n test
kubectl-debug haozhuo-hm-dp-0 -c haozhuo-hm -n test

退出kube-debug之后pod会自动删除

也可以使用自己制作事先安装好工具的镜像
kubectl-debug  haozhuo-hm-dp-0 -c haozhuo-hm -n test --agentless=false  --image  registry.cn-hangzhou.aliyuncs.com/xjm_public/centos:7.4.1708

出现的问题

装了agent_daemonset 就报错如下

error: pod ran to completion

Predicate PodFitsHostPorts failed

Error from server (BadRequest): container “debug-agent” in pod “debug-agent-pod-6462e1b9-f719-11ea-82ea-005056b7c84c” is not available

可参考文档

https://github.com/aylei/kubectl-debug/blob/master/docs/zh-cn.md

https://aleiwu.com/post/kubectl-debug-intro/

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爷来辣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值