Tình huống của mình là team order DevOps run Automation test để kết nối vào Kafka.
Yêu cầu là run 1 consumer cùng chạy với container Playwright(dùng để push message lên kafka)
2 containers cũng sử dụng chung 1 folder vì consumer lấy kết quả của kafka và sẽ ghi xuống disk và Playwright sẽ đọc kết quả và tạo report.
apiVersion: argoproj.io/v1alpha1 kind: WorkflowTemplate metadata: name: playwright-testing spec: entrypoint: script-result volumeClaimTemplates: - metadata: name: workdir-playwright spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi storageClassName: ebs-gp3-workflow-sc arguments: parameters: - name: command1 value: npx playwright test apikey --workers 4 --reporter=html - name: git-branch value: "master" templates: - name: script-result inputs: parameters: - name: command1 - name: git-branch dag: tasks: - name: git-clone template: git-clone arguments: parameters: - name: git_branch value: '{{inputs.parameters.git-branch}}' - name: trivy-image-scan template: trivy-image-scan - name: ls template: ls dependencies: - git-clone - name: playwright-template template: playwright-template arguments: parameters: - name: command_playwright value: '{{inputs.parameters.command1}}' dependencies: - ls - name: git-clone nodeSelector: kubernetes.io/os: linux inputs: parameters: - name: git_branch artifacts: - name: argo-source path: /src git: repo: https://bitbucket.org/metascan/nimtechnology-automation-test.git singleBranch: true branch: "{{inputs.parameters.git_branch}}" usernameSecret: name: git-creds key: username passwordSecret: name: git-creds key: password container: name: git-clone image: alpine:3.17 command: - sh - -c args: - | apk add --no-cache rsync rsync -av /src/ . workingDir: /workdir-playwright volumeMounts: - name: workdir-playwright mountPath: /workdir-playwright - name: ls nodeSelector: kubernetes.io/os: linux container: image: alpine:3.17 command: - sh - -c args: - ls -la /workdir-playwright workingDir: /workdir-playwright volumeMounts: - name: workdir-playwright mountPath: /workdir-playwright - name: playwright-template nodeSelector: kubernetes.io/os: linux inputs: parameters: - name: command_playwright outputs: artifacts: - name: playwright-report path: /workdir-playwright/AutomationMDCloud/playwright-report/index.html s3: key: >- {{workflow.name}}/playwright-report-{{workflow.creationTimestamp}}.tgz container: name: playwright image: mcr.microsoft.com/playwright:v1.35.1-jammy env: - name: KAFKA_SSL_ENABLED value: 'true' - name: CI value: 'true' - name: NODE_OPTIONS value: '--max-old-space-size=24576' command: - /bin/bash - -c args: - | pwd ls -la npm i {{inputs.parameters.command_playwright}} ls -la volumeMounts: - mountPath: /workdir-playwright name: workdir-playwright workingDir: /workdir-playwright/AutomationMDCloud sidecars: - name: consumer image: mcr.microsoft.com/playwright:v1.44.0-jammy # Docker already provides an image for running a Docker daemon command: - /bin/bash - -c args: - | df -h npm i node index.js -e staging -a consume -t "apiv4-results" env: - name: KAFKA_SSL_ENABLED value: 'true' volumeMounts: - mountPath: /workdir-playwright name: workdir-playwright workingDir: /workdir-playwright/AutomationMDCloud - name: trivy-image-scan nodeSelector: kubernetes.io/os: linux container: image: aquasec/trivy args: - image - mcr.microsoft.com/playwright:v1.44.0-jammy
Đây là workflow của template trên.
Có điều bạn cần để ý về pod playwright template: