Eventing Setup - acmeair-svt/acmeair-mainservice-java GitHub Wiki

https://www-03preprod.ibm.com/support/knowledgecenter/en/SSCSJL_4.2.x/guides/integrating-events-operator/integrating-events-operator.html

  • Login to the cluster: oc login
  • Create new project acmeair: oc new-project acmeair
  • Switch to project Kabanero for the remainder of the setup: oc project kabanero
  • Run oc edit kabanero -o yaml and add acmeair to target namespace
    • Once done, there should be two target namespaces: kabanero and acmeair Screen Shot 2020-07-27 at 4 20 37 PM
  • Run oc edit kabanero and go through the following steps to enable the eventing pipeline
    • Make sure the url and the sha256 value match the values of the pipeline
    • ex:
stacks:
    pipelines:
    - https:
        url: https://github.com/kabanero-io/kabanero-pipelines/releases/download/0.9.1/kabanero-events-pipelines.tar.gz
      id: default
      sha256: caf603b69095ec3d128f1c2fa964a2964509854e306fb3c5add8addc8f7f7b71
    repositories:
  • Create my-githubsecret.yaml and replace <my-organization>, <user name>, and <API token> with the relevant values
apiVersion: v1
kind: Secret
metadata:
  name: my-github-secret
  namespace: kabanero
  annotations:
    tekton.dev/git-0: https://github.ibm.com/<my-organization>
type: kubernetes.io/basic-auth
stringData:
  username: <user name>
  password:  <API token>
  • Run oc apply -f my-githubsecret.yaml
  • Link the secret with oc secrets link kabanero-pipeline my-github-secret
  • Create my-webhooksecret.yaml and replace <my-webhook-secret> with a string of your choice (this will later be needed when setting up the webhook on Github)
apiVersion: v1
kind: Secret
metadata:
  name: my-webhook-secret
stringData:
  secretToken: <my-webhook-secret>
  • Run oc apply -f my-webhooksecret.yaml
  • Create webhook listener webhook.yaml and replace <my-docker-registry> and <tekton-dashboard> with the relevant values
    • In our testing for <my-docker-registry> we used: image-registry.openshift-image-registry.svc:5000/acmeair
    • Here we have body.webhooks-tekton-local-deploy set to true so that the default is to deploy the application after build
apiVersion: events.kabanero.io/v1alpha1
kind: EventMediator
metadata:
  name: webhook
spec:
  createListener: true
  createRoute: true
  repositories:
    - github:
        secret: my-github-secret
        webhookSecret: my-webhook-secret
  mediations:
    - name: webhook
      selector:
        repositoryType:
          newVariable: body.webhooks-appsody-config
          file: .appsody-config.yaml
      variables:
        - name: body.webhooks-tekton-target-namespace
          value: kabanero
        - name: body.webhooks-tekton-service-account
          value: kabanero-pipeline
        - name: body.webhooks-tekton-docker-registry
          value: <my-docker-registry>
        - name: body.webhooks-tekton-ssl-verify
          value: "false"
        - name: body.webhooks-tekton-insecure-skip-tls-verify
          value: "true"
        - name: body.webhooks-tekton-local-deploy
          value: "true"
        - name: body.webhooks-tekton-monitor-dashboard-url
          value: <tekton-dashboard>
      sendTo: [ "dest"  ]
      body:
        - = : "sendEvent(dest, body, header)"
  • Run oc apply -f webhook.yaml
  • Ensure that when running oc get services that webhook is a service
  • Create events connection connections.yaml
apiVersion: events.kabanero.io/v1alpha1
kind: EventConnections
metadata:
  name: connections
spec:
  connections:
    - from:
        mediator:
            name: webhook
            mediation: webhook
            destination: dest
      to:
        - https:
            - urlExpression:  body["webhooks-kabanero-tekton-listener"]
              insecure: true
  • Run oc apply -f connections.yaml
  • Go to Github organization, Settings, Hooks, Add Webhook
    • Edit the Payload URL, Content type, and Secret (created above)in <my-webhook-secret>
    • Disable SSL verification
    • Select individual events Pushes and Pull Requests
    • Set to Active Screen Shot 2020-07-27 at 5 16 31 PM
  • Ensure stack value of .appsody-config.yaml in all repos is set to relevant cluster
  • Ensure route.host value of app-deploy.yaml in all repos is set to relevant cluster
  • If everything works, we should be able to go to the pipeline runs tab of the oc console and see this in the kabanero project after a push of one of these repos to Github:
Screen Shot 2020-07-13 at 5 07 17 PM
⚠️ **GitHub.com Fallback** ⚠️