how to run K8S_CMD job using Powershell script
search cancel

how to run K8S_CMD job using Powershell script

book

Article ID: 445362

calendar_today

Updated On:

Products

Autosys Workload Automation

Issue/Introduction

Do you have an example of how to run K8S_CMD job using Powershell script?

Environment

Products: Workload Automation AE (AutoSys) 12.1.x, 24.x

 

Resolution

1. Script Placement
In a Kubernetes (OCP) environment, scripts are not placed on a specific "machine" as they were in legacy Data Centers. Instead, you have two primary options:

Image-based: Bake the .ps1 script directly into your container image (e.g., in /app/scripts/).
ConfigMap/Volume: Store the script in a Kubernetes ConfigMap and mount it as a volume to the pod at runtime.

2. JIL Example for K8S_CMD
When defining the job, you must ensure the k8s_command invokes the PowerShell interpreter.

jil

insert_job: my_powershell_k8s_job
job_type: K8S_CMD
machine: <your_agent_machine>
owner: <owner>
k8s_connection_profile: <your_connection_profile>
k8s_namespace: <your_namespace>
k8s_command: pwsh -File /app/scripts/my_script.ps1
k8s_label_selector: app=my-app
spool_log_level: DEBUG
k8s_security_profile: <value>

3. Key Considerations
Interpreter: Use pwsh for PowerShell Core (standard in Linux containers) or powershell depending on your image.
Execution Policy: If you encounter permission issues, you may need to add -ExecutionPolicy Bypass to the command.

 

Additional Information

Additional information / resources 

Unable to run a job which runs powershell script

Kubernetes Command Job

 

To speak with a customer representative or a Support Engineer see Contact Support. Scroll to the bottom of the page and click on the respective region.