External Tool to use in IDE (say Pycharm) to Copy Current Test File/Folder to Kubernetes container. Also, you can run:
- pytest command on Container directly from IDE.
- Run system-test using /ansible/system_test.yml file
- Run any ansible-playbook on container (E.g. ansible-playbook se-setup.yml)
Refer Pycharm Create/Edit/Copy Tool Dialog!
- Clone this Repository in your local machine.
- In Pycharm IDE, Go to Preferences (
⌘+,) - Go to
External Toolsunder Tools Section - Click on
+icon to create a new Tool - In
Namefield give any name (Say Kubectl CP) - In
Programfield select full path of thekube_tool*.pypython file as below:- For Kubectl Copy & Run select
kube_tools.py - For Kubectl Copy Only select
kube_tools_copy.py - For Kubectl Run Only select
kube_tools_run_test.py
- For Kubectl Copy & Run select
- In
Argumentsfield enter Two Arguments$FilePath$and$ModuleName$ - In
Working Directoryfield enter$ProjectFileDir$or Kubectl_Tools Project Dir (Optional) - Click OK and Apply then you are ready to go!
- Select the file or folder you want to copy or run tests on container.
- Right Click, Go to
External Toolsand Select yourKubectl Tool - That's all! Keep an eye on the Console/Run Tab :)
ktoolrc.inifile will be auto-generated when you run the script for the first time.- When you are running the tool for the first time or when you want to change the Pod Name,
Go to
ktoolrc.inifile at$ProjectFileDir$and add/change the value forpodnamefield. - This is one time task per Pod Name change.
- Delete the
ktoolrc.inifile from your$ProjectFileDir$, if you make any code changes in this repository as all the constants are picked up by theinifile. - Add
ktoolrc.inito your projects.gitignorefile if required. - Currently, this tool supports requires Python3+ (As Python2.7 is deprecated)
-
Cannot Run Program /path/kube_tools.py; [error=2] No such file or directory- The files are basically Python scripts. i.e., we use
#!/usr/bin/python3in the beginning of these script files. - Make sure you have Python3 set to
/usr/bin/python3. - Else Replace the line
#!/usr/bin/python3inkube_tools*.pyfiles, with whichever location you have Python3 configured.- For Eg:
/user/local/bin/python3
- For Eg:
- The files are basically Python scripts. i.e., we use
-
Unable to run kubectl commands?
- Before using this tool, make sure you have kubectl package installed in your system.
- Make sure basic kubectl commands are working on your namespace.
