kubernetescni

How to use commands of an image (i.e kube ovn commands) of a container inside another container or pod in a kubernets cluster?


In my kubernets cluster, I have custom python script in a pod which needs ovn-nbctl show command (this cmd will give all floating ips)and this results will be given to the py script which will give me number of floating ips pinging in the cluster.

Problem is Ovn-nbctl show works only inside the kube ovn cni pod. How to use or send the result of this command to the python script pod.

Kubectl ko nbctl(in host) and ovn-nbctl show (in ovn cni pod)gives the same output

What I'm expecting is:

  1. I need the python script to run (which requires the ovn-nbctl show command)
  2. The fix should work even after the pod restarts
  3. The ovn nbctl show command should be executed in intervals for the python script to be real-time.
  4. Should have minimum work to setup this

What I've tried so far.

Method 1: I tried to save the command o/p in a file inside the kube ovn cni pod and then volume mounted it to the python pod but if the cni pod restarts I'll lose the file and the shell script/cronjob for real-time interval for inside the cni pod

Method 2:

I tried to use the kube ovn image and created a pod with the python script so I can run the command but container itself not running and sceptical if the command will give me the floating ips.

Method 3: I tried running the python script inside the ovn cni so I can use the cmd with ease but the py script will removed once the pod restarts along with the cronjob/ updating ip data shell script

Any other approch which will help me with my expectations?


Solution

  • There are ways of doing this but it would require Kubectl in Kubectl or SSH which I strongly advise you against as it will be harder and/or less secure than the methods you suggested.

    From my understanding I'm thinking about two solutions (close to the ones you mentioned) :