EUGENIO SOUZA CARVALHO 4 tahun lalu
induk
melakukan
723fd2489b

+ 1 - 0
argoworkflow/workflow/001-workflow-acount.yaml

@@ -40,3 +40,4 @@ roleRef:
 subjects:
   - kind: ServiceAccount
     name: workflow
+    namespace: default

+ 134 - 94
argoworkflow/workflow/040-sensor-github.yaml

@@ -1,4 +1,84 @@
 apiVersion: argoproj.io/v1alpha1
+kind: WorkflowTemplate
+metadata:
+  name: ci-workflow
+spec:
+  inputs:
+    parameters:
+      - name: revision
+  steps:
+    - - name: build
+        template: build-golang-example
+        arguments:
+          parameters:
+            - name: revision
+              value: "{{inputs.parameters.revision}}"
+    # the test step expands into three parallel steps running
+    # different operating system images. each mounts the workdir
+    # and runs the compiled binary from the build step.
+    - - name: test
+        template: run-hello
+        arguments:
+          parameters:
+            - name: os-image
+              value: "{{item.image}}:{{item.tag}}"
+        withItems:
+          - { image: "debian", tag: "9.1" }
+          - { image: "alpine", tag: "3.6" }
+          - { image: "ubuntu", tag: "17.10" }
+---
+apiVersion: argoproj.io/v1alpha1
+kind: WorkflowTemplate
+metadata:
+  name: build-golang-example
+spec:
+  inputs:
+    parameters:
+      - name: revision
+    artifacts:
+      - name: code
+        path: /go/src/github.com/golang/example
+        git:
+          repo: https://github.com/golang/example.git
+          revision: "{{inputs.parameters.revision}}"
+  container:
+    image: golang:1.8
+    command: [sh, -c]
+    args: [
+        "
+        cd /go/src/github.com/golang/example/hello &&
+        git status &&
+        go build -v .
+        ",
+      ]
+    volumeMounts:
+      - name: workdir
+        mountPath: /go
+
+---
+apiVersion: argoproj.io/v1alpha1
+kind: WorkflowTemplate
+metadata:
+  name: run-hello
+spec:
+  inputs:
+    parameters:
+      - name: os-image
+  container:
+    image: "{{inputs.parameters.os-image}}"
+    command: [sh, -c]
+    args: [
+        "
+        uname -a ;
+        cat /etc/os-release ;
+        /go/src/github.com/golang/example/hello/hello
+        ",
+      ]
+    volumeMounts:
+      - name: workdir
+        mountPath: /go
+---
+apiVersion: argoproj.io/v1alpha1
 kind: Sensor
 metadata:
   name: github
@@ -25,107 +105,67 @@ spec:
               apiVersion: argoproj.io/v1alpha1
               kind: Workflow
               metadata:
-                generateName: github-
+                # generateName: github-
+                generateName: ci-workflow-
               spec:
                 serviceAccountName: workflow
-                entrypoint: whalesay
-                arguments:
-                  parameters:
-                  - name: message
-                    # value will get overridden by the event payload
-                    value: hello world
-                templates:
-                - name: whalesay
-                  inputs:
-                    parameters:
-                    - name: message
-                  container:
-                    image: docker/whalesay:latest
-                    command: [cowsay]
-                    args: ["{{inputs.parameters.message}}"]
+                # entrypoint: whalesay
+                entrypoint: ci-workflow
+                workflowTemplateRef:
+                   name: ci-workflow
+                # arguments:
+                #   parameters:
+                #   - name: message
+                #     # value will get overridden by the event payload
+                #     value: hello world
+                # templates:
+                # - name: whalesay
+                #   inputs:
+                #     parameters:
+                #     - name: message
+                #   container:
+                #     image: docker/whalesay:latest
+                #     command: [cowsay]
+                #     args: ["{{inputs.parameters.message}}"]
           parameters:
             - src:
                 dependencyName: test-dep
               dest: spec.arguments.parameters.0.value
-# apiVersion: argoproj.io/v1alpha1
-# kind: WorkflowTemplate
-# metadata:
-#   name: ci-workflow
-# spec:
-#   inputs:
-#     parameters:
-#       - name: revision
-#   steps:
-#     - - name: build
-#         template: build-golang-example
-#         arguments:
-#           parameters:
-#             - name: revision
-#               value: "{{inputs.parameters.revision}}"
-#     # the test step expands into three parallel steps running
-#     # different operating system images. each mounts the workdir
-#     # and runs the compiled binary from the build step.
-#     - - name: test
-#         template: run-hello
-#         arguments:
-#           parameters:
-#             - name: os-image
-#               value: "{{item.image}}:{{item.tag}}"
-#         withItems:
-#           - { image: "debian", tag: "9.1" }
-#           - { image: "alpine", tag: "3.6" }
-#           - { image: "ubuntu", tag: "17.10" }
-# ---
-# apiVersion: argoproj.io/v1alpha1
-# kind: WorkflowTemplate
-# metadata:
-#   name: build-golang-example
-# spec:
-#   inputs:
-#     parameters:
-#       - name: revision
-#     artifacts:
-#       - name: code
-#         path: /go/src/github.com/golang/example
-#         git:
-#           repo: https://github.com/golang/example.git
-#           revision: "{{inputs.parameters.revision}}"
-#   container:
-#     image: golang:1.8
-#     command: [sh, -c]
-#     args: [
-#         "
-#         cd /go/src/github.com/golang/example/hello &&
-#         git status &&
-#         go build -v .
-#         ",
-#       ]
-#     volumeMounts:
-#       - name: workdir
-#         mountPath: /go
+    # - template:
+    #     name: github-workflow-trigger
+    #     k8s:
+    #       group: argoproj.io
+    #       version: v1alpha1
+    #       resource: workflows
+    #       operation: create
+    #       source:
+    #         resource:
+    #           apiVersion: argoproj.io/v1alpha1
+    #           kind: Workflow
+    #           metadata:
+    #             generateName: github-
+    #           spec:
+    #             serviceAccountName: workflow
+    #             entrypoint: whalesay
+    #             arguments:
+    #               parameters:
+    #               - name: message
+    #                 # value will get overridden by the event payload
+    #                 value: hello world
+    #             templates:
+    #             - name: whalesay
+    #               inputs:
+    #                 parameters:
+    #                 - name: message
+    #               container:
+    #                 image: docker/whalesay:latest
+    #                 command: [cowsay]
+    #                 args: ["{{inputs.parameters.message}}"]
+    #       parameters:
+    #         - src:
+    #             dependencyName: test-dep
+    #           dest: spec.arguments.parameters.0.value
 
-# ---
-# apiVersion: argoproj.io/v1alpha1
-# kind: WorkflowTemplate
-# metadata:
-#   name: run-hello
-# spec:
-#   inputs:
-#     parameters:
-#       - name: os-image
-#   container:
-#     image: "{{inputs.parameters.os-image}}"
-#     command: [sh, -c]
-#     args: [
-#         "
-#         uname -a ;
-#         cat /etc/os-release ;
-#         /go/src/github.com/golang/example/hello/hello
-#         ",
-#       ]
-#     volumeMounts:
-#       - name: workdir
-#         mountPath: /go
 
 # --- daqui pra baixo
 # apiVersion: argoproj.io/v1alpha1