litmuschaos / litmusctl

Command-Line tool to manage Litmuschaos's agent plane
Apache License 2.0
24 stars 45 forks source link

Will the litmusctl to support create/list/delete probe? #176

Closed tongqg closed 7 months ago

tongqg commented 10 months ago

I don't find the command line support to create the probes. I have to create them via UI. It prevents to me create a bash script to automate the testing. Please suggest if there is a plan. I am happy to submit a PR if I know where to check the graphql api specs for probes.

Nageshbansal commented 10 months ago

hey @tongqg , we don't have command by using which you can directly modify probes but we do have a command for saving the your chaos-experiments ( in which you can add your probes ) : save chaos-experiment .

Nageshbansal commented 10 months ago

i think a separate commands for modifying the probes makes sense. @SarthakJain26 @Saranya-jena what do you think about this, I'm happy to work on this if it makes senses for you also

tongqg commented 10 months ago

Hi @Nageshbansal thanks for the reply. From the manifest I downloaded from my chaos center (my version is v3.0.0), there is an annotation to the ChaosEngine like this: annotations: probeRef: '[{"name":"nginx","mode":"Continuous"}]' It assumes the probe exists in the portal already.

Can you guide me how to define probes in chaos-experiments?

Nageshbansal commented 10 months ago

Sure, PTAL : https://docs.litmuschaos.io/docs/concepts/probes

tongqg commented 10 months ago

It works. Thanks for the guidance.

SarthakJain26 commented 10 months ago

Thanks @tongqg for bringing this up, and thanks @Nageshbansal for owning this, let's first check the feasibility of this and then we can proceed with the commands.

tongqg commented 10 months ago

I tried to manually add the probes in the ChaoEngine specs. It seems the center can recognize it but they are not executed during the experiment test. image My spec looks like this:

               apiVersion: litmuschaos.io/v1alpha1
                kind: ChaosEngine
                metadata:
                  namespace: "{{workflow.parameters.adminModeNamespace}}"
                  labels:
                    workflow_run_id: "{{ workflow.uid }}"
                    workflow_name: nodecpu
                  generateName: node-cpu-hog-kxt
                spec:
                  engineState: active
                  auxiliaryAppInfo: ""
                  chaosServiceAccount: litmus-cluster-scope
                  experiments:
                    - name: node-cpu-hog
                      spec:
                        components:
                          env:
                            - name: TOTAL_CHAOS_DURATION
                              value: "60"
                            - name: RAMP_TIME
                              value: ""
                            - name: NODE_CPU_CORE
                              value: ""
                            - name: CPU_LOAD
                              value: "100"
                            - name: TARGET_NODES
                              value: ""
                            - name: NODE_LABEL
                              value: ""
                            - name: LIB_IMAGE
                              value: litmuschaos/go-runner:3.0.0
                            - name: NODES_AFFECTED_PERC
                              value: ""
                            - name: DEFAULT_HEALTH_CHECK
                              value: "false"
                            - name: SEQUENCE
                              value: parallel
                        probe:
                          - name: 'check-agent-status'
                            type: 'k8sProbe'
                            k8sProbe/inputs:
                                group: ''
                                version: 'v1'
                                resource: 'Pod'
                                namespace: 'cilium-system'
                                fieldSelector: 'spec.nodeName=1000-worker,status.phase=Running'
                                labelSelector: ''
                                operation: 'present' # it can be present, absent, create, delete
                            mode: 'Continuous'
                            runProperties:
                                probeTimeout: 5
                                interval: 5
                                retry: 1
SarthakJain26 commented 10 months ago

Thanks @tongqg for pointing this out, can you please create an issue here: https://github.com/litmuschaos/litmus/issues

tongqg commented 10 months ago

Thanks for replying. I think I found the issue. The resource should be "pods" instead of "Pod". Sure, I will create new issue when I have more questions.