robusta icon indicating copy to clipboard operation
robusta copied to clipboard

Add action to show files in Volume

Open aantn opened this issue 3 years ago • 11 comments

Motivation It can be hard to understand exactly what data is contained inside a Kubernetes volume. We can provide visibility with Robusta actions

Suggested Implementation Add a Robusta action which:

  1. Takes a Kubernetes volume as input
  2. Runs a "reader" job/pod which mounts that volume
  3. The reader pod should run ls -R on the volume to show all files.
  4. The Robusta action should gather the reader pod's output and send it to Slack/other sinks by creating a finding

Bonus Add support for VolumeSnapshots too. For VolumeSnapshots you will first need to create a temporary Volume based on the snapshot, then do the above, and finally delete the temporary volume.

Caveats The above sometims wont work if the Volume is in use - depending on the mount's AccessMode. This can be fixed various ways. For example, for ReadWriteOnce it can be bypassed by running the reader pod on the same node as the pod that is currrently using the volume. Alternatively, it could be fixed for all AccessModes by always creating a VolumeSnapshot and reading the snapshot not the original.

In any event, a first version doesn't need to support any of this.

aantn avatar Feb 18 '22 19:02 aantn

I am looking forward this issue, doing a dive to get my hands dirty is there anything I should be aware about the issue or descriptions says all

AvineshTripathi avatar Apr 14 '22 07:04 AvineshTripathi

Everything is in the description. Feel free to ask any questions in the #beginners channel on Slack

aantn avatar Apr 14 '22 15:04 aantn

Hey @aantn when you say volume is it a object that the function would receive or just the name of the volume p.s I was busy with my exam so took a time for this

AvineshTripathi avatar May 04 '22 09:05 AvineshTripathi

@AvineshTripathi hope your exams went well!

The playbook action should take a PersistentVolumeEvent as input:

@action
def volume_analysis(event: PersistentVolumeEvent):
    volume = event.get_persistentvolume()
    print(f"got volume named {volume.metadata.name} as input with current status: {volume.status.reason}")
    # create a reader pod (using the builtin hikaru library) that does stuff with the volume
    reader_pod = Pod(
        ...
    )

To trigger it you can just provide the volume's name though. Something like the cli command:

robusta playbooks trigger volume_analysis name=some-volume namespace=some-ns

aantn avatar May 04 '22 10:05 aantn

@AvineshTripathi we have a new tutorial on writing playbooks actions that @Sheeproid wrote, so make sure you read that first:

https://docs.robusta.dev/master/tutorials/my-first-custom-action.html

aantn avatar May 04 '22 10:05 aantn

When I am trying to upgrade helm after enabling PlaybooksPersistentVolume

controlplane $ helm upgrade robusta robusta/helm/robusta  --values=values.yaml
Error: open values.yaml: no such file or directory

p.s. In the docs it is mentioned generated_values.yaml but in repo I see values.yaml I think both are same but names are different

AvineshTripathi avatar May 07 '22 06:05 AvineshTripathi

Hey @AvineshTripathi , the values.yaml is the defaults, and the generated_values.yaml is the overrides that you created when you ran "robusta gen-config" and used in helm install

You should use generated_values.yaml with helm upgrade as well.

Sheeproid avatar May 07 '22 07:05 Sheeproid

so to upgrade the helm I need to do gen-config first and then upgrade helm with flag value=generated_values.yaml

AvineshTripathi avatar May 07 '22 07:05 AvineshTripathi

Hi @AvineshTripathi After running gen-config for the first time, your generated_values.yaml is created. That file contains your UI account id, and some configuration parameters. You should save this file, and use it later on when you need to upgrade Robusta.

You need to run gen-config only once, on the first time you install Robusta.

arikalon1 avatar May 07 '22 08:05 arikalon1

I am trying to upgrade helm but it throws an error Error: UPGRADE FAILED: "robusta" has no deployed releases" when am running helm upgrade robusta helm/robusta --values=generated_values.yaml is there anything I am missing.

p.s. sorry for bugging again

AvineshTripathi avatar May 11 '22 05:05 AvineshTripathi

@AvineshTripathi , I reached you in the Slack community channel. Lets solve it there?

RoiGlinik avatar May 11 '22 06:05 RoiGlinik

sinksConfig:

  • file_sink: name: file_sink file_name: file.json i added above sinks gettting below error devops@ip-192-168-242-253:~/robusta$ helm upgrade robusta robusta/robusta --values=generated_values.yaml Error: UPGRADE FAILED: "robusta" has no deployed releases anyone plz guide me where I am missing it

linuxredhatsumit avatar Sep 28 '23 14:09 linuxredhatsumit