Question: We have a network wifi device which is tracking vehicles and it is having some connection issues so we need to run a tcp dump and let it run for a long time, maybe 8 - 12 hours.

The network device is running a cut down version of Linux and the hard drive in it is only 64 mb

It talks to a Ubuntu server running 12.04 - which has plenty of space on the hard drive, so we would like to ship the results from the tcp dump onto it, instead of using the local drive 

The tcp dump command we are currently using is 

```
tcpdump  -n  -s 64 -i  r1_ap1  -w  filename.pcap

```

We can't map a network drive (samba is not installed). It's a closed network so I can only use the Ubuntu server for the logs

Linux is not my thing and the commands I have tried from the net don't work for me - it may be my lack of knowledge

Is it possible to either run the tcp dump command with something like 

```
tcpdump  -n  -s 64 -i  r1_ap1  -w  > [serverIP]/home/temp

```

Or can I run the tcp dump and then run another command that tails the pcap file to another file onto the Ubuntu server? I can use ssh and scp.

Answer: 
Run the following command and get things what you are thinking wrong about this cmd.

```sh
$ kubectl run --help
Create and run a particular image, possibly replicated.

 Creates a deployment or job to manage the created container(s).

Examples:
  # Start a single instance of nginx.
  kubectl run nginx --image=nginx

  # Start a single instance of hazelcast and let the container expose port 5701 .
  kubectl run hazelcast --image=hazelcast --port=5701
...

```

So, `kubectl run` cmd creates a deployment or a job

* If it is a deployment, it creates (a) first, a replicaset, (b) then Pod(s).
* If it is a job, it creates a Pod.

But you are trying to expose a Pod which name is not the correct one. You can see the name of the Pod that is/are created by the cmd `kubectl run`.

```sh
$ kubectl get pods --namespace=<namespace> | grep "nginx-resolver"
$ kubectl get pods --namespace=<namespace> | grep "test-nslookup"

```

Then use those names to expose Pod.

You can optionally expose your `Deployment`. To do so, see the help of `$ kubectl expose deployment --help`. Run:

```sh
$ kubectl expose deployment --help
Expose a resource as a new Kubernetes service.

 Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that
resource as the selector for a new service on the specified port. A deployment or replica set will be exposed as a
service only if its selector is convertible to a selector that service supports, i.e. when the selector contains only
the matchLabels component. Note that if no port is specified via --port and the exposed resource has multiple ports, all
will be re-used by the new service. Also if no labels are specified, the new service will re-use the labels from the
resource it exposes.

 Possible resources include (case insensitive):

 pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)

Examples:
...
  # Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000.
  kubectl expose deployment nginx --port=80 --target-port=8000
...

```
If you want to see the log interactively, you need to set the `--restart` option of your `test-nslookup` pod to `Never` or `OnFailure`. Otherwise, kubernetes will just restart your pod indefinitely and you won't see anything.

So your last command should be :

```
kubectl run --generator=run-pod/v1 test-nslookup --image=busybox:1.28 -it --restart=OnFailure -- nslookup nginx-resolver-service

```

### Why ?

Probably because of [this issue](https://github.com/kubernetes/kubernetes/issues/27264).  

It seems to have a delay of 5s before `kubectl run` actually print something.  

So in order to do it without changing the `restart` option, you'll need to change your command like this (**beware of the `sleep 7`, so you'll have to wait 7seconds before seeing the logs)** :

```
kubectl run --generator=run-pod/v1 test-nslookup --image=busybox:1.28 -it --rm -- sh -c 'sleep 7; nslookup nginx-resolver-service'

```