Home > front end >  How to create a k8s custom pod with a specific configuration?
How to create a k8s custom pod with a specific configuration?

Time:05-24

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 ...

CodePudding user response:

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

CodePudding user response:

...i'm trying to capture the traffic network of a container, so i started a container (nginx) and i created another container (tcpdump)

Try a minimum spec:

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: nginx
    image: nginx:alpine
    ports:
    - containerPort: 80
  - name: tcpdump
    image: itsthenetwork/alpine-tcpdump
    args: ["-i", "any", "-s", "0", "'tcp port 80'"]  # <-- tweak with your own tcpdump arguments

Containers that run in the same pod shared the network namespace. You can capture traffic by running tcpdump side-by-side (aka sidecar) with the main container (nginx). Do kubectl logs --follow <pod> --container tcpdump to see the output.

...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 ...

Containers do not start in sequence.

  • Related