Varsayılan olarak iş akışları argo ad alanına gönderilir. İş akışlarını farklı bir ad alanına göndermek (takımlar veya projeler arasında kaynak yalıtımı ve erişim kontrolü sağlamak için) önce ilgili ad alanının ServiceAccount hesabına gerekli Rol Tabanlı Erişim Kontrolü (RBAC) izinlerini vermenizi gerektirir.
Ön koşullar
Başlamadan önce şunlara sahip olduğunuzdan emin olun:
Kümenizde çalışan bir Argo Workflows kurulumu
Ad alanları ve RBAC kaynakları oluşturmak için gerekli izinlere sahip
kubectlerişimiYüklenmiş
argoCLI aracı
İzinleri verin ve bir iş akışı gönderin
1. Adım: Hedef ad alanını oluşturun
kubectl create ns test
2. Adım: RBAC yetkilendirme dosyasını oluşturun
Aşağıdaki içeriğe sahip role-rolebinding.yaml adlı bir dosya oluşturun.
Bu örnek,defaultServiceAccount hesabına izinler verir. İş akışınız farklı bir ServiceAccount belirtiyorsa bunun yerine o ServiceAccount hesabına izinler verin. RoleBinding'ler ad alanı kapsamındadır; bu nedenle izinler yalnızca oluşturuldukları ad alanında geçerlidir. Bu sebeple bu dosyayı 3. adımdatestad alanına uygulayacaksınız.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
workflows.argoproj.io/description: |
This is the minimum recommended permissions needed if you want to use the agent, e.g. for HTTP or plugin templates.
If <= v3.2 you must replace `workflowtasksets/status` with `patch workflowtasksets`.
name: agent
rules:
- apiGroups:
- argoproj.io
resources:
- workflowtasksets
verbs:
- list
- watch
- apiGroups:
- argoproj.io
resources:
- workflowtasksets/status
verbs:
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
workflows.argoproj.io/description: |
This is the minimum recommended permissions needed if you want to use artifact GC.
name: artifactgc
rules:
- apiGroups:
- argoproj.io
resources:
- workflowartifactgctasks
verbs:
- list
- watch
- apiGroups:
- argoproj.io
resources:
- workflowartifactgctasks/status
verbs:
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
workflows.argoproj.io/description: |
Recommended minimum permissions for the `emissary` executor.
name: executor
rules:
- apiGroups:
- argoproj.io
resources:
- workflowtaskresults
verbs:
- create
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: submit-workflow-template
rules:
- apiGroups:
- argoproj.io
resources:
- workfloweventbindings
verbs:
- list
- apiGroups:
- argoproj.io
resources:
- workflowtemplates
verbs:
- get
- apiGroups:
- argoproj.io
resources:
- workflows
verbs:
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
workflows.argoproj.io/description: |
This is an example of the permissions you would need if you wanted to use a resource template to create and manage
other workflows. The same pattern would be suitable for other resurces, e.g. a service
name: workflow-manager
rules:
- apiGroups:
- argoproj.io
resources:
- workflows
verbs:
- create
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: agent-default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: agent
subjects:
- kind: ServiceAccount
name: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: artifactgc-default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: artifactgc
subjects:
- kind: ServiceAccount
name: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: executor-default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: executor
subjects:
- kind: ServiceAccount
name: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: workflow-manager-default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: workflow-manager
subjects:
- kind: ServiceAccount
name: default
Dosya beş Rol ve dört RoleBinding tanımlar. Herhangi bir iş akışının çalışması için asgari gereksinim olan executor rolü ile başlayın. Diğer rolleri yalnızca kullandığınız özellikler için ekleyin:
| Rol | Gerekli olduğu durum | Kaynaklar |
|---|---|---|
executor |
Emissary yürütücüsü için asgari gereksinim | workflowtaskresults (create, patch) |
agent |
HTTP şablonları ve eklenti şablonları | workflowtasksets (list, watch); workflowtasksets/status (patch) |
artifactgc |
Yapıt çöp toplama | workflowartifactgctasks (list, watch); workflowartifactgctasks/status (patch) |
submit-workflow-template |
WorkflowTemplates üzerinden iş akışları gönderme | workfloweventbindings (list); workflowtemplates (get); workflows (create) |
workflow-manager |
Kaynak şablonlarından iş akışları oluşturma ve yönetme | workflows (create, get) |
3. Adım: Yetkilendirme dosyasını uygulayın
Rolleri ve RoleBinding'leri oluşturmak üzere dosyayı test ad alanına uygulayın:
kubectl apply -f role-rolebinding.yaml -n test
Beklenen çıktı şöyledir:
role.rbac.authorization.k8s.io/agent created
role.rbac.authorization.k8s.io/artifactgc created
role.rbac.authorization.k8s.io/executor created
role.rbac.authorization.k8s.io/submit-workflow-template created
role.rbac.authorization.k8s.io/workflow-manager created
rolebinding.rbac.authorization.k8s.io/agent-default created
rolebinding.rbac.authorization.k8s.io/artifactgc-default created
rolebinding.rbac.authorization.k8s.io/executor-default created
rolebinding.rbac.authorization.k8s.io/workflow-manager-default created
4. Adım: Bir iş akışı tanımı oluşturun
helloworld-workflow.yaml adlı bir dosya oluşturun:
apiVersion: argoproj.io/v1alpha1
kind: Workflow # new type of k8s spec.
metadata:
generateName: hello-world- # name of the workflow spec.
spec:
entrypoint: main # invoke the main template.
templates:
- name: main # name of the template.
container:
image: mirrors-ssl.aliyuncs.com/busybox:latest
command: [ echo ]
args: [ "hello world" ]
5. Adım: İş akışını hedef ad alanına gönderin
argo submit helloworld-workflow.yaml -n test
İş akışı 3. adımda verilen izinleri kullanarak test ad alanında çalışır.