Files
cicdTest/manifests/github-event-listener.yaml
2020-03-16 10:00:52 +01:00

142 lines
3.5 KiB
YAML

# 1 trigger binding wordt geconfigureerd, en dan worden meerdere trigger templates aangemaakt
# voor de verschillende service mesh types. Op deze manier moet ik niet elke keer een aparte pipeline aanmaken per service mesh type. Het nadeel hieraan is dat dan elke keer elke pipeline gerunned wordt, maar uiteindelijk maakt dit niet veel uit zolang de deploy.yaml files leeg zijn wanneer de commits door gaan
---
apiVersion: tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: github-trigger-binding
#namespace: stage-tekton-pipeline
spec:
params:
- name: gitrevision
value: $(body.repository.default_branch)
- name: gitrepositoryurl
value: $(body.repository.clone_url)
# - name: prurl
# value: $(body.pull_request.html_url)
# - name: repo
# value: $(body.pull_request.base.repo.full_name)
# - name: source
# value: github
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: workspace-pvc-master
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: workspace-pvc-experimental
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
---
apiVersion: tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
name: github-trigger-template
#namespace: stage-tekton-pipeline
spec:
params:
- name: gitrevision
description: The git revision
default: master
- name: gitrepositoryurl
description: The git repository url
resourcetemplates:
- apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: application-pipeline-run
#namespace: stage-tekton-pipeline
spec:
serviceAccountName: service-acc
pipelineRef:
name: application-pipeline #gebruik dit om de pipeline aan te passen naar andere versies, zolang ze zich in dezelfde #namespace bevinden kunnen we deze pipeline hergebruiken om deployments op de cluster uit te voeren. service-mesh agnostisch.
workspaces:
- name: workspace-master
persistentVolumeClaim:
claimName: workspace-pvc-master
- name: workspace-experimental
persistentVolumeClaim:
claimName: workspace-pvc-experimental
params:
- name: git-url
value: $(inputs.params.gitrepositoryurl)
- name: branch
value: $(inputs.params.gitrevision)
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tekton-trigger-role
rules:
- apiGroups:
- "extensions"
- "tekton.dev"
- ""
resources:
- ingresses
- eventlisteners
- triggerbindings
- triggertemplates
- configmaps
- secrets
- pipelineruns
- pipelineresources
- taskruns
- pods
- serviceaccounts
- namespaces
- services
- deployments
- deployments.apps
verbs:
- create
- get
- list
- delete
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tekton-trigger-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tekton-trigger-role
subjects:
- kind: ServiceAccount
name: service-acc
namespace: default
---
apiVersion: tekton.dev/v1alpha1
kind: EventListener
metadata:
name: github-event-listener
spec:
serviceAccountName: service-acc
triggers:
- name: github
# interceptors:
# - github:
# eventTypes:
# - pull_request
# - push
bindings:
- name: github-trigger-binding
template:
name: github-trigger-template