API Permissions needed for /api/v1/workflows/{namespace}/submit
#11680
-
I worked through this doc: https://argoproj.github.io/argo-workflows/access-token/ and got an access token. I'm able to: curl -X GET https://{endpoint}/api/v1/workflow-templates/{namespace}/{template} -H "Authorization: Bearer $ARGO_TOKEN" just fine. However, if I run: curl -X POST \
--url https://workflows-dev-main.shippodev.com/api/v1/workflows/argo-workflows/submit \
--header 'Authorization: Bearer $ARGO_TOKEN' \
--data '{ "resourceKind": "WorkflowTemplate", "namespace": "{namespace}", "resourceName": "{template}", "submitOptions": { "parameters": [ "{param1}={param1_value}", "{param2}={param2_value}" ], "submitOptions": { "labels": "workflows.argoproj.io/workflow-template={template}", "name": "{arbitrary name}" } } }' I get the following error:
for the life of me I cannot figure out what permissions I might need to do this. I can't seem to find any discussion or docs anywhere on the matter. What might I be doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 21 replies
-
NOTE: I have tried the following permissions on the role that the service account i'm using is using: {
api_groups = ["argoproj.io"]
resources = ["*"]
verbs = ["list", "get", "watch"]
},
{
api_groups = ["argoproj.io"]
resources = ["workflows", "workflowtaskresults"]
verbs = ["create", "patch"]
} I even tried it with resources |
Beta Was this translation helpful? Give feedback.
-
So people don't have to read through the chain, because I know more people are going to run across this, and save yourself days worth of debugging. Here is how to get this to work.
export ARGO_TOKEN=$(kg secret <secret_name> -o=jsonpath='{.data.token}' -n <namespace> | base64 --decode)
curl -X 'POST' \
'https://{endpoint}/api/v1/workflows/{namespace}/submit' \
-H 'accept: application/json' \
-H "Authorization: Bearer ${ARGO_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{
"resourceKind": "WorkflowTemplate",
"namespace": "{namespace}",
"resourceName": "{workflow_template_name}",
"submitOptions": {
"dryrun": true,
"entryPoint": "{template_name}",
"parameters": [
...
],
"labels": "workflows.argoproj.io/workflow-template={workflow_template_name}",
"name": "{Whatever_you_want_Here}"
}
}'
Some caveats. If the workflow has already been run with the provided
To fix it, just change the
|
Beta Was this translation helpful? Give feedback.
-
We have a slack bot (say bot) that we plan to use to trigger some WorkflowTemplates. For this we decided to use HTTP API calls to Argo Workflows. We are facing a challenge in the implementation when it comes to token.
We store our secrets in AWS Secret Manager and plan to store the token value there. Get it via External Secret and mount this value. apiVersion: v1
kind: ServiceAccount
metadata:
name: external-secrets-bot
namespace: argo-workflows
annotations:
"eks.amazonaws.com/role-arn": "arn:aws:iam::123456789:role/external-secrets-bot"
automountServiceAccountToken: true bot-role.yaml apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: bot-role
rules:
- apiGroups:
- argoproj.io
resources:
- workflows
- workflowtemplates
- cronworkflows
verbs:
- create
- get
- list
- watch bot-rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: bot-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: bot-role
subjects:
- kind: ServiceAccount
name: external-secrets-bot
namespace: argo-workflows First question is: How we can pass (or generate) a custom JWT token (stored and managed by us in AWS SecretManager)? That further can be used by SA for HTTP API calls. apiVersion: v1
kind: Secret
metadata:
name: bot
namespace: argo-workflows
annotations:
kubernetes.io/service-account.name: external-secrets-bot
type: kubernetes.io/service-account-token It does create the secret with name as Now if we try to create an ExternalSecret, SecretStore that would try to get the secret value from AWS it fails. apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: bot
namespace: argo-workflows
spec:
provider:
aws:
service: SecretsManager
region: eu-west-1
auth:
jwt:
serviceAccountRef:
name: external-secrets-bot bot-es.yaml apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: bot-external-secret
namespace: argo-workflows
spec:
secretStoreRef:
name: bot
kind: SecretStore
refreshInterval: "1h"
target:
name: bot
creationPolicy: "Owner"
deletionPolicy: "Delete"
template:
engineVersion: v2
type: Opaque
metadata:
labels:
app.kubernetes.io/part-of: argo-workflows
data:
- secretKey: token
remoteRef:
key: "arn:aws:secretsmanager:eu-west-1:123456789:secret:argo-workflows/bot-http-token-123ABC" IAM roles and permissions are in-place. {
"alg": "RS256",
"kid": "61iSk-G-4NkR7smu7CN0bXK_VFQnVKr1CoTDBD5yCiM"
}
---
{
"iss": "kubernetes/serviceaccount",
"kubernetes.io/serviceaccount/namespace": "argo-workflows",
"kubernetes.io/serviceaccount/secret.name": "bot",
"kubernetes.io/serviceaccount/service-account.name": "external-secrets-bot",
"kubernetes.io/serviceaccount/service-account.uid": "78bf5b20-e65a-4f09-9d34-e9c73c9e2fcf",
"sub": "system:serviceaccount:argo-workflows:external-secrets-bot"
} When we try to generate a custom JWT token with a python script we used Algo as HS256. Script is: import jwt
import datetime
# Define your secret key
secret_key = "<our-secret-key>"
# Load your RSA private key
#with open('/jwt-key', 'r') as f:
# private_key = f.read()
# Define the payload
payload = {
"iss": "kubernetes/serviceaccount",
"kubernetes.io/serviceaccount/namespace": "argo-workflows",
"kubernetes.io/serviceaccount/secret.name": "bot",
"kubernetes.io/serviceaccount/service-account.name": "external-secrets-bot",
"kubernetes.io/serviceaccount/service-account.uid": "78bf5b20-e65a-4f09-9d34-e9c73c9e2fcf",
"sub": "system:serviceaccount:argo-workflows:external-secrets-max"
}
# Generate the JWT token
token = jwt.encode(payload, secret_key, algorithm="HS256")
print(f"Generated JWT token: {token}") As the SA has already been created I copied the UUID from it and passed it in my code. If we generate a JWT token this way it does not work. I am aware that we need to pass this secret_key to ARGO server so that it can validate the token sent in API request. How to do this I am not aware. |
Beta Was this translation helpful? Give feedback.
So people don't have to read through the chain, because I know more people are going to run across this, and save yourself days worth of debugging. Here is how to get this to work.