0

i have to say that my question is a little confusing but i'll try to be as clear as possible:

in docker there is a command to run a container and make it use another container's network the command is : docker run --net=container so basically, i want to make k8s execute that command to create a pod, is that possible ? or is there any other alternative command for that in k8s ?

in another words, what command does the k8s api-server execute to create containers on worker nodes?

there is a lot of questions over there lol, i hope you will understand what i want to say ...

Youva
  • 13
  • 2
  • You can create multiple containers in a Pod, and all the containers in a Pod share a single network namespace (so in essence you already have the behavior you're asking about). Depending on your kubernetes environment, Docker might not be involved at all. We may be able to provide better answers if you can be more clear about what you're trying to do. – larsks May 23 '22 at 21:10
  • Kubernetes uses an abstract container interface that can plug in several implementations (and as of recently, not Docker proper); there's no specific `docker run` command it would use. The `--net=container` option is a little unusual: do you have a specific reason you need it, or a code sample showing how you might use it in a Kubernetes environment? – David Maze May 23 '22 at 22:36
  • thank you for you response .... i'm trying to do the following: i'm trying to capture the traffic network of a container, so i started a container (nginx) and i created another container (tcpdump) and made it use the nginx's network with the command **docker run --net=container:nginx-id** so this works perfectly. now i want to reproduce the same thing in a k8s cluster but this time using pods, so actually i want to capture a pod's traffic network. i know that i can simply start my tcpdump in the same pod as nginx but i'm supposing that the nginx pod is already running ... – Youva May 23 '22 at 22:48

1 Answers1

0

I am not sure if i understand what you want but if you want to capture a pod's traffic network you can use a service mesh like Istio or Linkerd

I worked with Istio and you can have metrics for all traffic within a cluster

panas007
  • 36
  • 8