litmuschaos / litmus-ansible

Ansible-based chaos experiments
Apache License 2.0
8 stars 17 forks source link

Use Kubernetes Ansible modules instead of embedding it into the shell #39

Open crazyglasses opened 4 years ago

crazyglasses commented 4 years ago

Is this a BUG REPORT or FEATURE REQUEST?

FEATURE REQUEST

What happened: Observed that current experiments are written with kubectl commands embedded in the shell commands. Recommend replacing it with Ansible modules for kubernetes. Eg: https://docs.ansible.com/ansible/latest/modules/k8s_module.html#synopsis What you expected to happen: If modules are embedded in the image, easier development process for new experiments as well as cleaner ansible code. How to reproduce it (as minimally and precisely as possible): Source Code analysis

Anything else we need to know?: It is a recommendation. Would be happy to take up and convert the existing scripts to include modules and bake it into the image as well.

ksatchit commented 4 years ago

Awesome @crazyglasses ! That would be great ! Moving to k8s & k8s_facts is on our roadmap - will be happy to accept contributions in that area.

ksatchit commented 4 years ago

Tagging @uditgaurav who has been working on a similar PR!

uditgaurav commented 4 years ago

Thanks, @ksatchit for tagging me here @crazyglasses that's great I've been working on it and I have converted various shell commands into k8s and k8s_facts module. I have faced some issues in few commands explained below. I'll be happy to accept the contribution for such issues. OPENSHIFT VERSION

[root@master-1554817485 deployers]# openshift version
openshift v3.10.127

ANSIBLE VERSION

[root@master-1554817485 deployers]# ansible --version
ansible 2.4.6.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Mar 26 2019, 22:13:06) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

SHELL COMMAND

            - name: Creating busybox-liveness job
              shell: kubectl create -f {{ busybox_liveness }}

USING K8S MODULE

    - name: Creating busybox-liveness job
      k8s:
        state: present
        src:  {{ busybox_liveness }}

PROBLEM STATEMENT

so what I think is k8s module is treating it as "kubectl apply -f " not "kubectl create -f" it will be great if k8s module can work as "kubectl create -f" in any way.

kmjayadeep commented 4 years ago

https://github.com/litmuschaos/litmus/pull/737

@uditgaurav Can you please share which all files you have refactored so far and which you are planning to work on?

I've started changing pod_failure_by_litmus file and planning to work on remaining yml files under chaoslib folder, if you haven't worked on those already.

uditgaurav commented 4 years ago

@kmjayadeep You can carry on for remaining yml files under chaoslib. I've changed the yml files under /utils.