Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLPATH 1048: Extend software template to offer the CI pipeline (Tekton option) #19

Merged
merged 39 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f1742eb
Update template.yaml
masayag Feb 23, 2024
2034060
Update workflow-resources.yaml
masayag Feb 23, 2024
bf7bb29
Update template.yaml
masayag Feb 23, 2024
99a8747
Update template.yaml
masayag Feb 23, 2024
401b2b1
Update template.yaml
masayag Feb 23, 2024
6bac407
Update template.yaml
masayag Feb 23, 2024
dbbd4c7
Update template.yaml
masayag Feb 23, 2024
2f5ae89
Update template.yaml
masayag Feb 23, 2024
1a9d59f
Update template.yaml
masayag Feb 23, 2024
b56bd54
Merge pull request #13 from masayag/tekton-demo
masayag Feb 23, 2024
c774450
Update template.yaml
dmartinol Feb 23, 2024
e061b92
Create application-dev.properties
dmartinol Feb 23, 2024
637891a
Update application.properties
dmartinol Feb 23, 2024
316ff9f
plain manifests for tekton
dmartinol Feb 28, 2024
9a5c48b
fixed kubernetes-id
dmartinol Feb 28, 2024
9522e2a
added deployment parameters
dmartinol Feb 29, 2024
819c1d4
use workflowId for reource naming
dmartinol Feb 29, 2024
a6a9b7d
adding params for trigger template
dmartinol Feb 29, 2024
acf897c
fixed gitUrl
dmartinol Feb 29, 2024
4126c95
removed extra space
dmartinol Feb 29, 2024
48155ad
catalog-info templates from parodos-dev organization, branch tekton-demo
dmartinol Feb 29, 2024
e4bfd16
passing namespace
dmartinol Feb 29, 2024
0bb6e54
added ad-hoc catalog-infos to templates
dmartinol Feb 29, 2024
9ee00b7
added -ci suffix
dmartinol Feb 29, 2024
4ba5cea
use workflowId as pipeline run label selector
dmartinol Feb 29, 2024
8697e8d
hardcode dependsOn
dmartinol Feb 29, 2024
8b5047c
adding GH workflow to deploy triggers
dmartinol Feb 29, 2024
32101c0
hardcode secret
dmartinol Feb 29, 2024
754d578
no secret
dmartinol Feb 29, 2024
df5cb3a
public repo
dmartinol Feb 29, 2024
8793686
avoid to template FH workflow
dmartinol Feb 29, 2024
9fdd9a0
hardcode namespace
dmartinol Feb 29, 2024
5b4aac2
Merge remote-tracking branch 'upstream/tekton-demo' into FLPATH-1049
dmartinol Feb 29, 2024
fcc0025
update defaults
dmartinol Feb 29, 2024
a181389
adding option to select CI (None/Tekton)
dmartinol Mar 4, 2024
fba58ca
Generating tekton and GH action only when needed
dmartinol Mar 4, 2024
b2faf04
empty values as dictionary
dmartinol Mar 4, 2024
30d5597
Specify cluster-admin role is needed
dmartinol Mar 5, 2024
6435fcd
Removed default and clarified the description of clusterDomain
dmartinol Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ This repository is a collection of software and documentation templates for the

## documentation-templates

The documentation templates provide recommended structure and integration documentation with the Orchestrator deployment.
The documentation templates provide recommended structure and integration documentation with the Orchestrator deployment.

## pre-requisites
In case of `Tekton` CI pipeline, the secrets `K8S_CLUSTER_URL` and `K8S_SECRET` are used by the GitHub action that deploys the Tekton
resources. Please provide organization-level configuration for these secrets and ensure that they can be managed by the newly created repositories according to the visibility options (currently set to `public`).

The value of the `K8S_SECRET` secret must comply with the specification provided in [Service account approach](https://github.com/Azure/k8s-set-context/tree/releases/v1?tab=readme-ov-file#service-account-approach) for the `azure/k8s-set-context` action.
45 changes: 45 additions & 0 deletions scaffolder-templates/basic-workflow/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Requirement: add a K8S_SECRET secret to your organization with the SA token
# Bind the SA with a cluster-admin Role
# oc get secret backstage-k8s-token-4l5xv -n backstage-system -oyaml > secret.yaml
# gh secret --repo parodos-dev/test-swf set K8S_SECRET <secret.yaml
masayag marked this conversation as resolved.
Show resolved Hide resolved
name: Deploy the Pipeline trigger manifests workflow

on:
workflow_dispatch:
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set the Kubernetes context
uses: azure/k8s-set-context@v2
with:
method: service-account
k8s-url: ${{ secrets.K8S_CLUSTER_URL }}
k8s-secret: ${{ secrets.K8S_SECRET }}
- name: Deploy to the Kubernetes cluster
uses: azure/k8s-deploy@v1
with:
namespace: sonataflow-infra
manifests: |
tekton/eventlistener.yaml
tekton/trigger.yaml
tekton/route.yaml

# To be reviewed: needs a private repo to skip the need of a PR
# - name: Commit a change to trigger the webhook
# run: |
# echo $(date) > tekton/trigger
# git config --global user.email "${{ github.actor }}@users.noreply.github.com"
# git config --global user.name "${{ github.actor }}"
# git add tekton/trigger
# git commit --no-verify -m "Webhook trigger"
# - name: Push changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}

16 changes: 16 additions & 0 deletions scaffolder-templates/basic-workflow/skeleton/catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ${{ values.workflowId }}
description: ${{ values.description }}
annotations:
backstage.io/kubernetes-namespace: ${{ values.namespace }}
backstage.io/kubernetes-id: ${{ values.workflowId }}-ci
janus-idp.io/tekton: ${{ values.workflowId }}
backstage.io/techdocs-ref: dir:.
github.com/project-slug: ${{ values.orgName }}/${{ values.repoName }}
spec:
type: ${{ values.applicationType }}
system: ${{ values.system }}
lifecycle: ${{ values.lifecycle }}
owner: ${{ values.owner }}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This is to enable debugging of HTTP request
quarkus.log.category.\"org.apache.http\".level=INFO
quarkus.log.category.\"org.apache.http\".level=INFO
23 changes: 0 additions & 23 deletions scaffolder-templates/basic-workflow/skeleton/tekton/.helmignore

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 25 additions & 0 deletions scaffolder-templates/basic-workflow/tekton/eventlistener.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# From https://github.com/parodos-dev/red-hat-developer-hub-software-templates/blob/tekton-demo/skeletons/tekton/tekton/eventlistener.yaml
---
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: ${{ values.workflowId }}-el
namespace: ${{ values.namespace }}
spec:
triggers:
- bindings:
- kind: ClusterTriggerBinding
ref: github-push
interceptors:
- params:
- name: eventTypes
value: ["push"]
ref:
name: github
- params:
- name: filter
value: body.ref == 'refs/heads/main'
ref:
name: cel
template:
ref: ${{ values.workflowId }}-run-pipeline
21 changes: 21 additions & 0 deletions scaffolder-templates/basic-workflow/tekton/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# From https://github.com/parodos-dev/red-hat-developer-hub-software-templates/blob/tekton-demo/skeletons/tekton/tekton/eventlistener.yaml
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: webhook-${{ values.workflowId }}-el
namespace: ${{ values.namespace }}
labels:
app.kubernetes.io/managed-by: EventListener
app.kubernetes.io/part-of: Triggers
eventlistener: ${{ values.repoName }}-el
spec:
to:
kind: Service
name: el-${{ values.workflowId }}-el
weight: 100
port:
targetPort: http-listener
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: ${{ values.repoName }}-run-pipeline
namespace: ${{ .Values.namespace }}
name: ${{ values.workflowId }}-run-pipeline
namespace: ${{ values.namespace }}
spec:
params:
- name: git-revision
Expand All @@ -16,14 +16,13 @@ spec:
- apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
# TODO: add workflow Id someway
name: ${{ values.repoName }}-pipeline-$(uid)
name: ${{ values.workflowId }}-pipeline-$(uid)
labels:
backstage.io/kubernetes-id: __PLACEHOLDER__
backstage.io/kubernetes-id: ${{ values.workflowId }}-ci
spec:
params:
- name: gitUrl
value: ${{ values.repoName }}
value: ${{ values.gitUrl }}
- name: gitConfigUrl
value: ${{ values.gitConfigUrl }}
- name: workflowId
Expand Down Expand Up @@ -54,48 +53,4 @@ spec:
secretName: docker-credentials
- name: ssh-creds
secret:
secretName: git-ssh-credentials
---
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: ${{ values.repoName }}-el
namespace: ${{ .Values.namespace }}
spec:
triggers:
- bindings:
- kind: ClusterTriggerBinding
ref: github-push
interceptors:
- params:
- name: eventTypes
value: ["push"]
ref:
name: github
- params:
- name: filter
value: body.ref == 'refs/heads/main'
ref:
name: cel
template:
ref: ${{ values.repoName }}-run-pipeline
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: webhook-${{ values.repoName }}-el
namespace: ${{ .Values.namespace }}
labels:
app.kubernetes.io/managed-by: EventListener
app.kubernetes.io/part-of: Triggers
eventlistener: ${{ values.repoName }}-el
spec:
to:
kind: Service
name: el-${{ values.repoName }}-el
weight: 100
port:
targetPort: http-listener
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
secretName: git-ssh-credentials
Loading