Last active
April 14, 2020 19:16
-
-
Save AnthonyAmanse/08ccda87c90a8dc4485f876d103dc941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: triggers.tekton.dev/v1alpha1 | |
kind: TriggerTemplate | |
metadata: | |
name: pixel-build-and-deploy | |
spec: | |
params: | |
- name: NAMESPACE | |
description: The namespace is used by OpenShift's internal image registry to store the built image. | |
- name: DEPLOYMENT | |
description: Name of the Deployment and the container name in the Deployment. | |
- name: SERVICE_ACCOUNT | |
description: The ServiceAccount under which to run the Pipeline. | |
- name: COMMIT_SHA | |
description: Head commit sha | |
resourcetemplates: | |
- apiVersion: tekton.dev/v1alpha1 | |
kind: PipelineRun | |
metadata: | |
generateName: pixel-build-and-deploy- | |
spec: | |
serviceAccountName: $(params.SERVICE_ACCOUNT) | |
pipelineRef: | |
name: pixel-pipeline | |
resources: | |
- name: source | |
resourceRef: | |
name: pixel-git | |
- name: image | |
resourceSpec: | |
type: image | |
params: | |
- name: url | |
value: image-registry.openshift-image-registry.svc:5000/pixel/pixel-backend:$(params.COMMIT_SHA) | |
params: | |
- name: DEPLOYMENT | |
value: $(params.DEPLOYMENT) | |
workspaces: | |
- name: local-maven-repo | |
persistentVolumeClaim: | |
claimName: maven-repo-pvc2 | |
--- | |
apiVersion: triggers.tekton.dev/v1alpha1 | |
kind: TriggerBinding | |
metadata: | |
name: pixel-build-and-deploy | |
spec: | |
params: | |
- name: NAMESPACE | |
value: default | |
- name: DEPLOYMENT | |
value: pixel-backend | |
- name: SERVICE_ACCOUNT | |
value: pipeline | |
- name: COMMIT_SHA | |
value: $(body.extensions.truncated_sha) | |
--- | |
kind: Role | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: pixel | |
rules: | |
# Permissions for every EventListener deployment to function | |
- apiGroups: ["triggers.tekton.dev"] | |
resources: ["eventlisteners", "triggerbindings", "triggertemplates"] | |
verbs: ["get"] | |
- apiGroups: [""] | |
# secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization | |
resources: ["configmaps", "secrets", "serviceaccounts"] | |
verbs: ["get", "list", "watch"] | |
# Permissions to create resources in associated TriggerTemplates | |
- apiGroups: ["tekton.dev"] | |
resources: ["pipelineruns", "pipelineresources", "taskruns"] | |
verbs: ["create"] | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: RoleBinding | |
metadata: | |
name: pixel | |
namespace: pixel | |
subjects: | |
- kind: ServiceAccount | |
name: pipeline | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: Role | |
name: pixel | |
--- | |
apiVersion: triggers.tekton.dev/v1alpha1 | |
kind: EventListener | |
metadata: | |
name: pixel | |
spec: | |
serviceAccountName: pipeline | |
triggers: | |
- name: pullrequest-build-and-deploy | |
interceptors: | |
- github: | |
secretRef: | |
secretName: github-webhook-secret | |
secretKey: github-webhook-secret | |
eventTypes: | |
- push | |
- cel: | |
filter: "body.ref == 'refs/heads/master'" | |
overlays: | |
- key: extensions.truncated_sha | |
expression: "truncate(body.head_commit.id, 7)" | |
template: | |
name: pixel-build-and-deploy | |
bindings: | |
- name: pixel-build-and-deploy | |
--- | |
apiVersion: route.openshift.io/v1 | |
kind: Route | |
metadata: | |
labels: | |
eventlistener: pixel | |
name: el-pixel | |
spec: | |
port: | |
targetPort: http-listener | |
to: | |
kind: Service | |
name: el-pixel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment