EUGENIO SOUZA CARVALHO 3 years ago
parent
commit
e45d26429a

+ 17 - 0
argoworkflow/01-gateway-github.yaml

@@ -0,0 +1,17 @@
+apiVersion: argoproj.io/v1alpha1
+kind: Gateway
+metadata:
+  name: github
+spec:
+  type: github
+  eventSourceRef:
+    name: github-event-source
+  template:
+    serviceAccountName: argo-events-sa
+  service:
+    ports:
+      - port: 12000
+        targetPort: 12000
+  subscribers:
+    http:
+      - "http://github-sensor.argo-events.svc:9300/"

+ 81 - 0
argoworkflow/02-event-source-github.yaml

@@ -0,0 +1,81 @@
+# Info on GitHub Webhook: https://developer.github.com/v3/repos/hooks/#create-a-hook
+apiVersion: argoproj.io/v1alpha1
+kind: EventSource
+metadata:
+  name: github-event-source
+spec:
+  type: github
+  github:
+    example:
+      # owner of the repo
+      owner: eugeniucarvalho
+      # repository name
+      repository: app
+      # Github will send events to following port and endpoint
+      webhook:
+        # endpoint to listen to events on
+        endpoint: /push
+        # port to run internal HTTP server on
+        port: "12000"
+        # HTTP request method to allow. In this case, only POST requests are accepted
+        method: POST
+        # url the gateway will use to register at Github.
+        # This url must be reachable from outside the cluster.
+        # The gateway pod is backed by the service defined in the gateway spec. So get the URL for that service Github can reach to.
+        url: https://deploy.monteasua.com.br
+      # type of events to listen to.
+      # following listens to everything, hence *
+      # You can find more info on https://developer.github.com/v3/activity/events/types/
+      events:
+        - "*"
+
+      #      # Namespace where the api token and webhook secret live.
+      #      # +Optional. Default to gateway's namespace.
+      #      namespace: "argo-events"
+
+      # apiToken refers to K8s secret that stores the github api token
+      apiToken:
+        # Name of the K8s secret that contains the access token
+        name: github-access
+        # Key within the K8s secret whose corresponding value (must be base64 encoded) is access token
+        key: token
+
+      #      # webhookSecret refers to K8s secret that stores the github hook secret
+      #      # +optional
+      #      webhookSecret:
+      #        # Name of the K8s secret that contains the hook secret
+      #        name: github-access
+      #        # Key within the K8s secret whose corresponding value (must be base64 encoded) is hook secret
+      #        key: secret
+
+      # type of the connection between gateway and Github.
+      # You should set it to false to avoid man-in-the-middle and other attacks.
+      insecure: true
+      # Determines if notifications are sent when the webhook is triggered
+      active: true
+      # The media type used to serialize the payloads
+      contentType: json
+#    example-with-secure-connection:
+#      owner: "argoproj"
+#      repository: "argo"
+#      webhook:
+#        endpoint: "/push"
+#        port: "13000"
+#        method: "POST"
+#        url: "http://myargofakeurl.fake"
+#        # path to file that is mounted in gateway pod which contains certs
+#        serverCertPath: "some path in pod"
+#        # path to file that is mounted in gateway pod which contains private key
+#        serverKeyPath: "some path in pod"
+#      events:
+#        - "push"
+#        - "delete"
+#      apiToken:
+#        name: github-access
+#        key: token
+#      webhookSecret:
+#        name: github-access
+#        key: secret
+#      insecure: true
+#      active: true
+#      contentType: "json"

+ 48 - 0
argoworkflow/03-sensor-github.yaml

@@ -0,0 +1,48 @@
+apiVersion: argoproj.io/v1alpha1
+kind: Sensor
+metadata:
+  name: github
+spec:
+  template:
+    serviceAccountName: argo-events-sa
+  dependencies:
+    - name: test-dep
+      gatewayName: github
+      eventName: example
+  subscription:
+    http:
+      port: 9300
+  triggers:
+    - 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:
+                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

+ 1 - 0
server

@@ -0,0 +1 @@
+Subproject commit e9d3e034a4bdca94f3df84f5044daebbb7876490