部署一个空的Pod,它闲置在k8的NameSpace中

时间:2019-03-20 16:01:45

标签: linux kubernetes containers

任何人都可以帮助我了解是否有可能在k8的节点内部署一个空的Pod,以进行基本的网络调试。PS:部署此Pod后,我应该能够exec

2 个答案:

答案 0 :(得分:1)

只需部署一个包含所需容器的Pod,并执行任何操作即可。

将该规范保存到Yaml文件中:

apiVersion: v1
kind: Pod
metadata:
  name: empty
spec:
  containers:
  - name: empty
    image: alpine
    command: ["cat"]

然后通过kubectl apply -f $filename

应用该Yaml

答案 1 :(得分:0)

您可以将kubectlgenerator一起使用。

# Create an idle pod
$ kubectl run --generator=run-pod/v1 idle-pod -i --tty --image ubuntu -- bash
root@idle-pod:/# # Debug whatever you want inside the idle container
root@idle-pod:/# exit
$

# Exec into idle pod
$ kubectl exec -i --tty idle-pod bash
root@idle-pod:/# # Debug whatever you want inside the idle container
root@idle-pod:/# exit
$

# Delete the idle pod
$ kubectl delete pod idle-pod
pod "idle-pod" deleted
$