Deploy an empty pod that sits idle in k8's NameSpace

3/20/2019

Can anyone help in making me understand if it's possible to deploy an empty pod inside a node in k8's for basic network debugging.PS : I should be able to exec this pod after its deployed.

-- DirectedSoul
containers
kubernetes
linux

2 Answers

3/21/2019

You can just use kubectl with generator.

# 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
$
-- Vikram Hosakote
Source: StackOverflow

3/20/2019

Just deploy a pod with a container you need and command which do nothing.

Save that spec to a yaml file:

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

And then apply that yaml by kubectl apply -f $filename

-- Anton Kostenko
Source: StackOverflow