linuxpowershellkubernetesargo-workflows

Kubernetes-Argo Workflow-Powershell script error


In installed argo-workflows Kubernetes Helm Chart from https://github.com/argoproj/argo-helm
I want to create a workflow which orchestrate some Powershell scripts.
So I created a test workflow like bellow:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: powershell-002
  namespace: argo-workflows
spec:
  entrypoint: run-powershell
  templates:
    - name: run-powershell
      script:
        image: mcr.microsoft.com/powershell:latest
        command: ["pwsh", -c]
        source: |
          Write-Host "Hello, Argo! This is a PowerShell script."
          $date = Get-Date
          Write-Host "The current date and time is: $date"

But the workflow run is failing with this error:

powershell-002: ResourceUnavailable: Program 'script' failed to run: An error occurred trying to start process '/argo/staging/script' with working directory '/'. Exec format errorAt line:1 char:1
powershell-002: + /argo/staging/script
powershell-002: + ~~~~~~~~~~~~~~~~~~~~.
powershell-002: time="2024-11-21T14:16:14 UTC" level=info msg="sub-process exited" argo=true error="<nil>"
powershell-002: Error: exit status 1

I tried to search for some related issues on argo documentation and internet but no clue about this error.
Could you please guide me to fix this error?


Solution

  • Remove the "-c" in your command:

    apiVersion: argoproj.io/v1alpha1
    kind: Workflow
    metadata:
      name: powershell-002
      namespace: argo-workflows
    spec:
      entrypoint: run-powershell
      templates:
        - name: run-powershell
          script:
            image: mcr.microsoft.com/powershell:latest
            command: ["pwsh"] ### <<---- HERE
            source: |
              Write-Host "Hello, Argo! This is a PowerShell script."
              $date = Get-Date
              Write-Host "The current date and time is: $date"