WIP = event + trigger + operator

This commit is contained in:
afornerot 2024-03-09 09:26:01 +01:00
parent 693023aff0
commit 1f13c7afcc
8 changed files with 186 additions and 4 deletions

View File

@ -9,5 +9,9 @@ resources:
- https://forge.cadoles.com/CadolesKube/c-kustom//base/metallb?ref=develop
- https://forge.cadoles.com/CadolesKube/c-kustom//base/nginx?ref=develop
- https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
- https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml
- https://storage.googleapis.com/tekton-releases/triggers/latest/interceptors.yaml
- https://storage.googleapis.com/tekton-releases/operator/latest/release.yaml
- https://raw.githubusercontent.com/tektoncd/operator/main/config/crs/kubernetes/config/all/operator_v1alpha1_config_cr.yaml
- https://storage.googleapis.com/tekton-releases/dashboard/latest/release.yaml

View File

@ -0,0 +1,12 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: pipeline-symfonyapp-listener
spec:
serviceAccountName: tekton-robot
triggers:
- name: pipeline-symfonyapp-trigger
bindings:
- ref: pipeline-symfonyapp-binding
template:
ref: pipeline-symfonyapp-template

View File

@ -5,8 +5,14 @@ resources:
- namespace/namespace.yaml
- secret/secret.yaml
- serviceaccount/service-account.yaml
- serviceaccount/rbac.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.9/git-clone.yaml
- https://api.hub.tekton.dev/v1/resource/tekton/task/kaniko/0.6/raw
- https://api.hub.tekton.dev/v1/resource/tekton/task/trivy-scanner/0.2/raw
- task/symfonyapp/
- pipeline/pipeline-symfonyapp.yaml
- trigger/pipeline-symfonyapp-binding.yaml
- trigger/pipeline-symfonyapp-template.yaml
- event/pipeline-symfonyapp-listener.yaml

View File

@ -1,12 +1,12 @@
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: symfonyapp
name: pipeline-symfonyapp
spec:
description: |
This pipeline clones a git repo, then echoes the README file to the stout.
params:
- name: repo-url
- name: url
type: string
description: The git repo URL to clone from.
- name: revision
@ -42,7 +42,7 @@ spec:
workspace: shared-data
params:
- name: url
value: $(params.repo-url)
value: $(params.url)
- name: revision
value: $(params.revision)
- name: submodules

View File

@ -26,7 +26,7 @@ spec:
secret:
secretName: regcred
params:
- name: repo-url
- name: url
value: https://forge.cadoles.com/CNOUS/mse.git
- name: revision
value: issue-2977

View File

@ -0,0 +1,29 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: tekton-robot
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: triggers-example-eventlistener-binding
subjects:
- kind: ServiceAccount
name: tekton-robot
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tekton-triggers-eventlistener-roles
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: triggers-example-eventlistener-clusterbinding
subjects:
- kind: ServiceAccount
name: tekton-robot
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tekton-triggers-eventlistener-clusterroles

View File

@ -0,0 +1,62 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: pipeline-symfonyapp-binding
spec:
params:
- name: secret
value: $(body.secret)
- name: ref
value: $(body.secret)
- name: before
value: $(body.before)
- name: after
value: $(body.after)
- name: compare_url
value: $(body.compare_url)
- name: repository.id
value: $(body.repository.id)
- name: repository.name
value: $(body.repository.name)
- name: repository.fullname
value: $(body.repository.full_name)
- name: repository.owner.id
value: $(body.repository.owner.id)
- name: repository_owner.username
value: $(body.repository.owner.username)
- name: repository_owner.full_name
value: $(body.repository.owner.full_name)
- name: repository.html_url
value: $(body.repository.html_url)
- name: repository.clone_url
value: $(body.repository.clone_url)
- name: repository.ssh_url
value: $(body.repository.ssh_url)
- name: repository.default_branch
value: $(body.repository.default_branch)
- name: pusher.id
value: $(body.pusher.id)
- name: pusher.username
value: $(body.pusher.username)
- name: pusher.full_name
value: $(body.pusher.full_name)
- name: sender.id
value: $(body.sender.id)
- name: sender.username
value: $(body.sender.username)
- name: sender.full_name
value: $(body.sender.full_name)
- name: commits.id
value: $(body.commits[0].id)
- name: commits.message
value: $(body.commits[0].message)
- name: commits.url
value: $(body.commits[0].url)
- name: commits.author.name
value: $(body.commits[0].author.name)
- name: commits.author.email
value: $(body.commits[0].author.email)
- name: commits.author.username
value: $(body.commits[0].author.username)
- name: commits.timestamp
value: $(body.commits[0].timestamp)

View File

@ -0,0 +1,69 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: pipeline-symfonyapp-template
spec:
params:
- name: secret
- name: ref
- name: before
- name: after
- name: compare_url
- name: repository.id
- name: repository.name
- name: repository.full_name
- name: repository.owner.id
- name: repository_owner.username
- name: repository_owner.full_name
- name: repository.html_url
- name: repository.clone_url
- name: repository.ssh_url
- name: repository.default_branch
- name: pusher.id
- name: pusher.username
- name: pusher.full_name
- name: sender.id
- name: sender.username
- name: sender.full_name
- name: commits.id
- name: commits.message
- name: commits.url
- name: commits.author.name
- name: commits.author.email
- name: commits.author.username
- name: commits.timestamp
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: symfonyapp-run-
namespace: tekton
spec:
serviceAccountName: build-bot
pipelineRef:
name: pipeline-symfonyapp
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: shared-data
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: config
configmap:
name: config-php-cs-fixer
- name: docker-credentials
secret:
secretName: regcred
params:
- name: url
value: $(tt.params.repository.html_url)
- name: revision
value: $(tt.params.ref)
- name: destination
value: sprint-8