mirror of
https://github.com/bvanroll/stage-infra.git
synced 2025-08-29 03:52:49 +00:00
multiple listeners. TODO create different pipelines for each listener
This commit is contained in:
38
Tekton/pipeline/front-end-pipeline.yaml
Normal file
38
Tekton/pipeline/front-end-pipeline.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
# ---
|
||||
# apiVersion: tekton.dev/v1beta1
|
||||
# kind: Pipeline
|
||||
# metadata:
|
||||
# name: stage-application-pipeline
|
||||
# namespace: tekton-pipeline-1
|
||||
# spec:
|
||||
# params:
|
||||
# - name: git-repo-full-name
|
||||
# description: full name of the github repo (used for status updates)
|
||||
# - name: sha
|
||||
# description: used for github status updates
|
||||
# - name: git-repo-name
|
||||
# description: name of the git repo (used to determine the name of the image)
|
||||
# - name: git-url
|
||||
# description: url of the git repository to clone
|
||||
# - name: revision
|
||||
# description: revision to checkout
|
||||
# - name: branch
|
||||
# description: name of the branch to checkout
|
||||
# workspaces:
|
||||
# - name: workspace
|
||||
# tasks:
|
||||
# - name: clone
|
||||
# taskRef:
|
||||
# name: git-clone
|
||||
# workspaces:
|
||||
# - name: output
|
||||
# workspace: workspace
|
||||
# params:
|
||||
# - name: url
|
||||
# value: $(params.git-url)
|
||||
# - name: revision
|
||||
# value: $(params.revision)
|
||||
# - name: build-gradle
|
||||
# taskRef:
|
||||
# name: build-image
|
||||
|
@@ -14,9 +14,14 @@ spec:
|
||||
description: revision to checkout
|
||||
- name: branch
|
||||
description: name of the master branch of the repository
|
||||
- name: git-repo-full-name
|
||||
description: full name of the github repo (used for status updates)
|
||||
- name: sha
|
||||
description: used for github status updates
|
||||
workspaces:
|
||||
- name: workspace
|
||||
tasks:
|
||||
|
||||
- name: clone
|
||||
taskRef:
|
||||
name: git-clone
|
||||
@@ -28,6 +33,24 @@ spec:
|
||||
value: $(params.git-url)
|
||||
- name: revision
|
||||
value: $(params.revision)
|
||||
|
||||
# - name: set-status-building
|
||||
# taskRef:
|
||||
# name: github-set-status
|
||||
# runAfter:
|
||||
# - clone
|
||||
# params:
|
||||
# - name: REPO_FULL_NAME
|
||||
# value: $(params.git-repo-full-name)
|
||||
# - name: SHA
|
||||
# value: $(params.sha)
|
||||
# - name: STATE
|
||||
# value: pending
|
||||
# - name: TARGET_URL
|
||||
# value: http://ingress.llocal.host/$(params.git-repo-name)
|
||||
# - name: DESCRIPTION
|
||||
# value: "Build and push has started"
|
||||
|
||||
- name: build-and-push
|
||||
taskRef:
|
||||
name: build-and-push
|
||||
@@ -51,9 +74,29 @@ spec:
|
||||
value: "$(params.git-repo-name)"
|
||||
- name: version
|
||||
value: "$(params.branch)"
|
||||
|
||||
# - name: set-status-building
|
||||
# taskRef:
|
||||
# name: github-set-status
|
||||
# runAfter:
|
||||
# - build-and-push
|
||||
# params:
|
||||
# - name: REPO_FULL_NAME
|
||||
# value: $(params.git-repo-full-name)
|
||||
# - name: SHA
|
||||
# value: $(params.sha)
|
||||
# - name: STATE
|
||||
# value: pending
|
||||
# - name: TARGET_URL
|
||||
# value: http://ingress.llocal.host/$(params.git-repo-name)
|
||||
# - name: DESCRIPTION
|
||||
# value: "Build and push has completed, starting deploy-app"
|
||||
|
||||
- name: deploy-app
|
||||
taskRef:
|
||||
name: deploy-app
|
||||
runAfter:
|
||||
- build-and-push
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: workspace
|
||||
@@ -62,5 +105,21 @@ spec:
|
||||
value: "$(params.git-repo-name)"
|
||||
- name: deploy-version
|
||||
value: "$(params.branch)"
|
||||
|
||||
|
||||
- name: set-status-building
|
||||
taskRef:
|
||||
name: github-set-status
|
||||
runAfter:
|
||||
- build-and-push
|
||||
- deploy-app
|
||||
params:
|
||||
- name: REPO_FULL_NAME
|
||||
value: $(params.git-repo-full-name)
|
||||
- name: SHA
|
||||
value: $(params.sha)
|
||||
- name: STATE
|
||||
value: success
|
||||
- name: TARGET_URL
|
||||
value: http://tekton.llocal.host/$(params.git-repo-name)
|
||||
- name: DESCRIPTION
|
||||
value: "Deploy finished"
|
78
Tekton/tasks/build-gradle.yaml
Normal file
78
Tekton/tasks/build-gradle.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: jib-gradle
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
inputs:
|
||||
params:
|
||||
- name: build-type
|
||||
description: build type used to check to actually execute this step
|
||||
default: gradle
|
||||
- name: DIRECTORY
|
||||
description: The directory containing the app, relative to the source repository root
|
||||
default: .
|
||||
- name: CACHE
|
||||
description: The name of the volume for caching Gradle artifacts, local Maven repository, and base image layers
|
||||
default: empty-dir-volume
|
||||
- name: INSECUREREGISTRY
|
||||
description: Whether to allow insecure registry
|
||||
default: "false"
|
||||
resources:
|
||||
- name: source
|
||||
type: git
|
||||
outputs:
|
||||
resources:
|
||||
- name: image
|
||||
type: image
|
||||
steps:
|
||||
- name: build-and-push
|
||||
image: gcr.io/cloud-builders/gradle
|
||||
script: |
|
||||
#!/bin/sh
|
||||
if [ $(inputs.params.build-type) != gradle]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
set -o errexit
|
||||
# Adds Gradle init script that applies the Jib Gradle plugin.
|
||||
echo "initscript {
|
||||
repositories { maven { url 'https://plugins.gradle.org/m2' } }
|
||||
dependencies { classpath 'gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:+' }
|
||||
}
|
||||
rootProject {
|
||||
afterEvaluate {
|
||||
if (!project.plugins.hasPlugin('com.google.cloud.tools.jib')) {
|
||||
project.apply plugin: com.google.cloud.tools.jib.gradle.JibPlugin
|
||||
}
|
||||
}
|
||||
}" > /tekton/home/init-script.gradle
|
||||
# Runs the Gradle Jib build.
|
||||
gradle jib \
|
||||
--stacktrace --console=plain \
|
||||
--init-script=/tekton/home/init-script.gradle \
|
||||
-Duser.home=/tekton/home \
|
||||
-Dgradle.user.home=/tekton/home/.gradle \
|
||||
-Djib.allowInsecureRegistries=$(inputs.params.INSECUREREGISTRY) \
|
||||
-Djib.to.image=$(outputs.resources.image.url)
|
||||
exit 0
|
||||
workingDir: /workspace/source/$(inputs.params.DIRECTORY)
|
||||
volumeMounts:
|
||||
- name: $(inputs.params.CACHE)
|
||||
mountPath: /tekton/home/.gradle/caches
|
||||
subPath: gradle-caches
|
||||
- name: $(inputs.params.CACHE)
|
||||
mountPath: /tekton/home/.gradle/wrapper
|
||||
subPath: gradle-wrapper
|
||||
- name: $(inputs.params.CACHE)
|
||||
mountPath: /tekton/home/.m2
|
||||
subPath: m2-cache
|
||||
- name: $(inputs.params.CACHE)
|
||||
mountPath: /tekton/home/.cache
|
||||
subPath: jib-cache
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
|
||||
volumes:
|
||||
- name: empty-dir-volume
|
||||
emptyDir: {}
|
@@ -0,0 +1,45 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: build-image
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
- name: DOCKERFILE
|
||||
description: Path to the Dockerfile to build.
|
||||
default: ./Dockerfile
|
||||
- name: CONTEXT
|
||||
description: The build context used by Kaniko.
|
||||
default: ./
|
||||
- name: EXTRA_ARGS
|
||||
default: ""
|
||||
- name: BUILDER_IMAGE
|
||||
description: The image on which builds will run
|
||||
default: gcr.io/kaniko-project/executor:v0.13.0
|
||||
- name: build-type
|
||||
description: build type used to check if this step needs to run without full pipeline failure
|
||||
default: dockerfile
|
||||
workspaces:
|
||||
- name: source
|
||||
mountpath: /source
|
||||
outputs:
|
||||
resources:
|
||||
- name: image
|
||||
type: image
|
||||
steps:
|
||||
- name: build-and-push
|
||||
workingDir: /workspace/source
|
||||
image: $(params.BUILDER_IMAGE)
|
||||
# specifying DOCKER_CONFIG is required to allow kaniko to detect docker credential
|
||||
# https://github.com/tektoncd/pipeline/pull/706
|
||||
env:
|
||||
- name: DOCKER_CONFIG
|
||||
value: /tekton/home/.docker
|
||||
command:
|
||||
- /kaniko/executor
|
||||
- $(inputs.EXTRA_ARGS)
|
||||
- --dockerfile=/source/$(params.DOCKERFILE)
|
||||
- --context=/workspace/source/$(params.CONTEXT) # The user does not need to care the workspace and the source.
|
||||
- --destination=$(outputs.resources.image.url)
|
||||
securityContext:
|
||||
runAsUser: 0
|
@@ -8,29 +8,28 @@ spec:
|
||||
volumes:
|
||||
- name: github-secret
|
||||
secret:
|
||||
secretName: $(inputs.params.GitHubSecretName)
|
||||
inputs:
|
||||
params:
|
||||
- name: ExternalDomain
|
||||
description: "The external domain for the EventListener e.g. `$(inputs.params.EventListenerName).<PROXYIP>.nip.io`"
|
||||
- name: GitHubUser
|
||||
description: "The GitHub user"
|
||||
- name: GitHubRepo
|
||||
description: "The GitHub repo where the webhook will be created"
|
||||
- name: GitHubOrg
|
||||
description: "The GitHub organization where the webhook will be created"
|
||||
- name: GitHubSecretName
|
||||
description: "The Secret name for GitHub access token. This is always mounted and must exist"
|
||||
- name: GitHubAccessTokenKey
|
||||
description: "The GitHub access token key name"
|
||||
- name: GitHubSecretStringKey
|
||||
description: "The GitHub secret string key name"
|
||||
- name: GitHubDomain
|
||||
description: "The GitHub domain. Override for GitHub Enterprise"
|
||||
default: "github.com"
|
||||
- name: WebhookEvents
|
||||
description: "List of events the webhook will send notifications for"
|
||||
default: '[\"push\",\"pull_request\"]'
|
||||
secretName: $(params.GitHubSecretName)
|
||||
params:
|
||||
- name: ExternalDomain
|
||||
description: "The external domain for the EventListener e.g. `$(params.EventListenerName).<PROXYIP>.nip.io`"
|
||||
- name: GitHubUser
|
||||
description: "The GitHub user"
|
||||
- name: GitHubRepo
|
||||
description: "The GitHub repo where the webhook will be created"
|
||||
- name: GitHubOrg
|
||||
description: "The GitHub organization where the webhook will be created"
|
||||
- name: GitHubSecretName
|
||||
description: "The Secret name for GitHub access token. This is always mounted and must exist"
|
||||
- name: GitHubAccessTokenKey
|
||||
description: "The GitHub access token key name"
|
||||
- name: GitHubSecretStringKey
|
||||
description: "The GitHub secret string key name"
|
||||
- name: GitHubDomain
|
||||
description: "The GitHub domain. Override for GitHub Enterprise"
|
||||
default: "github.com"
|
||||
- name: WebhookEvents
|
||||
description: "List of events the webhook will send notifications for"
|
||||
default: '[\"push\",\"pull_request\"]'
|
||||
steps:
|
||||
- name: create-webhook
|
||||
image: pstauffer/curl:latest
|
||||
@@ -44,8 +43,8 @@ spec:
|
||||
- |
|
||||
set -e
|
||||
echo "Create Webhook"
|
||||
if [ $(inputs.params.GitHubDomain) = "github.com" ];then
|
||||
curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)\",\"content_type\": \"json\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks
|
||||
if [ $(params.GitHubDomain) = "github.com" ];then
|
||||
curl -v -d "{\"name\": \"web\",\"active\": true,\"events\": $(params.WebhookEvents),\"config\": {\"url\": \"https://$(params.ExternalDomain)\",\"content_type\": \"json\"}}" -X POST -u $(params.GitHubUser):$(cat /var/secret/$(params.GitHubAccessTokenKey)) -L https://api.github.com/repos/$(params.GitHubOrg)/$(params.GitHubRepo)/hooks
|
||||
else
|
||||
curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(inputs.params.WebhookEvents),\"config\": {\"url\": \"https://$(inputs.params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(inputs.params.GitHubSecretStringKey))\"}}" -X POST -u $(inputs.params.GitHubUser):$(cat /var/secret/$(inputs.params.GitHubAccessTokenKey)) -L https://$(inputs.params.GitHubDomain)/api/v3/repos/$(inputs.params.GitHubOrg)/$(inputs.params.GitHubRepo)/hooks
|
||||
curl -d "{\"name\": \"web\",\"active\": true,\"events\": $(params.WebhookEvents),\"config\": {\"url\": \"https://$(params.ExternalDomain)/\",\"content_type\": \"json\",\"insecure_ssl\": \"1\" ,\"secret\": \"$(cat /var/secret/$(params.GitHubSecretStringKey))\"}}" -X POST -u $(params.GitHubUser):$(cat /var/secret/$(params.GitHubAccessTokenKey)) -L https://$(params.GitHubDomain)/api/v3/repos/$(params.GitHubOrg)/$(params.GitHubRepo)/hooks
|
||||
fi
|
19
Tekton/tasks/get-build-type.yaml
Normal file
19
Tekton/tasks/get-build-type.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: get-build-type
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
workspaces:
|
||||
- name: source
|
||||
mountpath: /source
|
||||
results:
|
||||
- name: build-type
|
||||
description: Build type that will be used for the project
|
||||
steps:
|
||||
- name: check-build-type
|
||||
image: bash:latest
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
cat /source/build-type | tr '\n' '' | tee /tekton/results/build-type
|
97
Tekton/tasks/github-set-status.yaml
Normal file
97
Tekton/tasks/github-set-status.yaml
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: github-set-status
|
||||
namespace: tekton-pipeline-1
|
||||
description: |
|
||||
This task will set the CI as running and add a link to the openshift console
|
||||
viewer url.
|
||||
spec:
|
||||
params:
|
||||
- name: GITHUB_HOST_URL
|
||||
description: |
|
||||
The GitHub host, adjust this if you run a GitHub enteprise.
|
||||
default: "api.github.com"
|
||||
type: string
|
||||
|
||||
- name: API_PATH_PREFIX
|
||||
description: |
|
||||
The API path prefix, GitHub Enterprise has a prefix e.g. /api/v3
|
||||
default: ""
|
||||
type: string
|
||||
|
||||
- name: REPO_FULL_NAME
|
||||
description: |
|
||||
The GitHub repository full name, i.e: tektoncd/catalog
|
||||
type: string
|
||||
|
||||
- name: SHA
|
||||
description: |
|
||||
Commit SHA to set the status for.
|
||||
type: string
|
||||
|
||||
- name: TARGET_URL
|
||||
description: |
|
||||
The target URL to associate with this status. This URL will be linked
|
||||
from the GitHub UI to allow users to easily see the source of the
|
||||
status.
|
||||
type: string
|
||||
|
||||
- name: DESCRIPTION
|
||||
description: |
|
||||
A short description of the status.
|
||||
type: string
|
||||
|
||||
- name: CONTEXT
|
||||
description: |
|
||||
The GitHub context, A string label to differentiate this status from
|
||||
the status of other systems. ie: "continuous-integration/tekton"
|
||||
default: "continuous-integration/tekton"
|
||||
type: string
|
||||
|
||||
- name: STATE
|
||||
description: |
|
||||
The state of the status. Can be one of the following `error`,
|
||||
`failure`, `pending`, or `success`.
|
||||
type: string
|
||||
steps:
|
||||
- name: set-status
|
||||
env:
|
||||
- name: GITHUBTOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: github
|
||||
key: token
|
||||
image: registry.access.redhat.com/ubi8/ubi:latest
|
||||
script: |
|
||||
#!/usr/libexec/platform-python
|
||||
import json
|
||||
import os
|
||||
import http.client
|
||||
status_url = "$(params.API_PATH_PREFIX)" + "/repos/$(params.REPO_FULL_NAME)/" + \
|
||||
"statuses/$(params.SHA)"
|
||||
data = {
|
||||
"state": "$(params.STATE)",
|
||||
"target_url": "$(params.TARGET_URL)",
|
||||
"description": "$(params.DESCRIPTION)",
|
||||
"context": "$(params.CONTEXT)"
|
||||
}
|
||||
print("Sending this data to GitHub: ")
|
||||
print(data)
|
||||
conn = http.client.HTTPSConnection("$(params.GITHUB_HOST_URL)")
|
||||
r = conn.request(
|
||||
"POST",
|
||||
status_url,
|
||||
body=json.dumps(data),
|
||||
headers={
|
||||
"User-Agent": "TektonCD, the peaceful cat",
|
||||
"Authorization": "Bearer " + os.environ["GITHUBTOKEN"],
|
||||
})
|
||||
resp = conn.getresponse()
|
||||
if not str(resp.status).startswith("2"):
|
||||
print("Error: %d" % (resp.status))
|
||||
print(resp.read())
|
||||
else:
|
||||
print("GitHub status '$(params.STATE)' has been set on "
|
||||
"$(params.REPO_FULL_NAME)#$(params.SHA) ")
|
48
Tekton/triggers/back-end-trigger-template.yaml
Normal file
48
Tekton/triggers/back-end-trigger-template.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: TriggerTemplate
|
||||
metadata:
|
||||
name: back-end-trigger-template
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
- name: gitrevision
|
||||
description: The git revision
|
||||
default: master
|
||||
- name: gitrepositoryurl
|
||||
description: The git repository url
|
||||
- name: gitreponame
|
||||
description: the name of the git repository
|
||||
- name: branch
|
||||
description: the name of the branch pushed to
|
||||
- name: gitrepofullname
|
||||
description: used for github status updates
|
||||
- name: sha
|
||||
description: used for github status updates
|
||||
resourcetemplates:
|
||||
- apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
generateName: back-end-pipeline-run-
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
pipelineRef:
|
||||
name: stage-application-pipeline
|
||||
Timeout: "2h30m00s"
|
||||
workspaces:
|
||||
- name: workspace
|
||||
persistentVolumeClaim:
|
||||
claimName: workspace
|
||||
params:
|
||||
- name: git-url
|
||||
value: $(params.gitrepositoryurl)
|
||||
- name: branch
|
||||
value: $(params.branch)
|
||||
- name: git-repo-name
|
||||
value: $(params.gitreponame)
|
||||
- name: revision
|
||||
value: $(params.gitrevision)
|
||||
- name: sha
|
||||
value: $(params.sha)
|
||||
- name: git-repo-full-name
|
||||
value: $(params.gitrepofullname)
|
@@ -3,7 +3,7 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: EventListener
|
||||
metadata:
|
||||
name: github-event-listener
|
||||
name: event-listener-frontend
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
@@ -16,23 +16,202 @@ spec:
|
||||
- push
|
||||
bindings:
|
||||
- name: github-trigger-binding
|
||||
#- name: gitlab-trigger-binding
|
||||
template:
|
||||
name: github-trigger-template
|
||||
name: front-end-trigger-template
|
||||
- name: gitlab
|
||||
interceptors:
|
||||
- gitlab:
|
||||
eventTypes:
|
||||
- Push Hook
|
||||
bindings:
|
||||
- name: gitlab-trigger-binding
|
||||
template:
|
||||
name: front-end-trigger-template
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: manual-service
|
||||
name: frontend-event-listener
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
ports:
|
||||
- name: http-listener
|
||||
port: 8080
|
||||
protocol: TCP
|
||||
targetPort: 8080
|
||||
type: NodePort
|
||||
selector:
|
||||
app.kubernetes.io/managed-by: EventListener
|
||||
app.kubernetes.io/part-of: Triggers
|
||||
eventlistener: github-event-listener
|
||||
type: LoadBalancer
|
||||
eventlistener: event-listener-frontend
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: EventListener
|
||||
metadata:
|
||||
name: event-listener-backend
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
triggers:
|
||||
- name: github
|
||||
interceptors:
|
||||
- github:
|
||||
eventTypes:
|
||||
- pull_request
|
||||
- push
|
||||
bindings:
|
||||
- name: github-trigger-binding
|
||||
template:
|
||||
name: back-end-trigger-template
|
||||
- name: gitlab
|
||||
interceptors:
|
||||
- gitlab:
|
||||
eventTypes:
|
||||
- Push Hook
|
||||
bindings:
|
||||
- name: gitlab-trigger-binding
|
||||
template:
|
||||
name: back-end-trigger-template
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: backend-event-listener
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
eventlistener: event-listener-backend
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: EventListener
|
||||
metadata:
|
||||
name: event-listener-mirror
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
triggers:
|
||||
- name: github
|
||||
interceptors:
|
||||
- github:
|
||||
eventTypes:
|
||||
- pull_request
|
||||
- push
|
||||
bindings:
|
||||
- name: github-trigger-binding
|
||||
template:
|
||||
name: mirror-trigger-template
|
||||
- name: gitlab
|
||||
interceptors:
|
||||
- gitlab:
|
||||
eventTypes:
|
||||
- Push Hook
|
||||
bindings:
|
||||
- name: gitlab-trigger-binding
|
||||
template:
|
||||
name: mirror-trigger-template
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mirror-event-listener
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
eventlistener: event-listener-mirror
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8080
|
||||
targetPort:
|
||||
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: EventListener
|
||||
metadata:
|
||||
name: event-listener-infra
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
triggers:
|
||||
- name: github
|
||||
interceptors:
|
||||
- github:
|
||||
eventTypes:
|
||||
- pull_request
|
||||
- push
|
||||
bindings:
|
||||
- name: github-trigger-binding
|
||||
template:
|
||||
name: infra-trigger-template
|
||||
- name: gitlab
|
||||
interceptors:
|
||||
- gitlab:
|
||||
eventTypes:
|
||||
- Push Hook
|
||||
bindings:
|
||||
- name: gitlab-trigger-binding
|
||||
template:
|
||||
name: infra-trigger-template
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: infra-event-listener
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
eventlistener: event-listener-infra
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
---
|
||||
# apiVersion: v1
|
||||
# kind: Service
|
||||
# metadata:
|
||||
# name: manual-service
|
||||
# namespace: tekton-pipeline-1
|
||||
# spec:
|
||||
# ports:
|
||||
# - name: http-listener
|
||||
# port: 8080
|
||||
# protocol: TCP
|
||||
# targetPort: 8080
|
||||
# selector:
|
||||
# type: LoadBalancer
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: event-listener-ingress
|
||||
namespace: tekton-pipeline-1
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
spec:
|
||||
rules:
|
||||
- host: pipeline.llocal.host
|
||||
http:
|
||||
paths:
|
||||
- path: /stage-frontend
|
||||
backend:
|
||||
serviceName: el-event-listener-frontend
|
||||
servicePort: 8080
|
||||
- path: /stage-backend
|
||||
backend:
|
||||
serviceName: el-event-listener-backend
|
||||
servicePort: 8080
|
||||
- path: /stage-mirror-service
|
||||
backend:
|
||||
serviceName: el-event-listener-mirror
|
||||
servicePort: 8080
|
||||
- path: /stage-infra
|
||||
backend:
|
||||
serviceName: el-event-listener-infra
|
||||
servicePort: 8080
|
||||
- path: /stage-test
|
||||
backend:
|
||||
serviceName: test-service
|
||||
servicePort: 8080
|
48
Tekton/triggers/front-end-trigger-template.yaml
Normal file
48
Tekton/triggers/front-end-trigger-template.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: TriggerTemplate
|
||||
metadata:
|
||||
name: front-end-trigger-template
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
- name: gitrevision
|
||||
description: The git revision
|
||||
default: master
|
||||
- name: gitrepositoryurl
|
||||
description: The git repository url
|
||||
- name: gitreponame
|
||||
description: the name of the git repository
|
||||
- name: branch
|
||||
description: the name of the branch pushed to
|
||||
- name: gitrepofullname
|
||||
description: used for github status updates
|
||||
- name: sha
|
||||
description: used for github status updates
|
||||
resourcetemplates:
|
||||
- apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
generateName: front-end-pipeline-run-
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
pipelineRef:
|
||||
name: stage-application-pipeline
|
||||
Timeout: "2h30m00s"
|
||||
workspaces:
|
||||
- name: workspace
|
||||
persistentVolumeClaim:
|
||||
claimName: workspace
|
||||
params:
|
||||
- name: git-url
|
||||
value: $(params.gitrepositoryurl)
|
||||
- name: branch
|
||||
value: $(params.branch)
|
||||
- name: git-repo-name
|
||||
value: $(params.gitreponame)
|
||||
- name: revision
|
||||
value: $(params.gitrevision)
|
||||
- name: sha
|
||||
value: $(params.sha)
|
||||
- name: git-repo-full-name
|
||||
value: $(params.gitrepofullname)
|
@@ -13,4 +13,8 @@ spec:
|
||||
- name: gitreponame
|
||||
value: $(body.repository.name)
|
||||
- name: branch
|
||||
value: $(body.repository.default_branch)
|
||||
value: $(body.repository.default_branch)
|
||||
- name: gitrepofullname
|
||||
value: $(body.repository.full_name)
|
||||
- name: sha
|
||||
value: $(body.head_commit.id)
|
@@ -11,4 +11,8 @@ spec:
|
||||
- name: gitrepositoryurl
|
||||
value: "$(body.project.http_url)"
|
||||
- name: gitreponame
|
||||
value: $(body.project.name)
|
||||
value: $(body.project.name)
|
||||
- name: gitrepofullname
|
||||
value: $(body.project.fullname)
|
||||
- name: sha
|
||||
value: $(body.project.sha)
|
48
Tekton/triggers/infra-trigger-template.yaml
Normal file
48
Tekton/triggers/infra-trigger-template.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: TriggerTemplate
|
||||
metadata:
|
||||
name: infra-trigger-template
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
- name: gitrevision
|
||||
description: The git revision
|
||||
default: master
|
||||
- name: gitrepositoryurl
|
||||
description: The git repository url
|
||||
- name: gitreponame
|
||||
description: the name of the git repository
|
||||
- name: branch
|
||||
description: the name of the branch pushed to
|
||||
- name: gitrepofullname
|
||||
description: used for github status updates
|
||||
- name: sha
|
||||
description: used for github status updates
|
||||
resourcetemplates:
|
||||
- apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
generateName: infra-pipeline-run-
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
pipelineRef:
|
||||
name: stage-application-pipeline
|
||||
Timeout: "2h30m00s"
|
||||
workspaces:
|
||||
- name: workspace
|
||||
persistentVolumeClaim:
|
||||
claimName: workspace
|
||||
params:
|
||||
- name: git-url
|
||||
value: $(params.gitrepositoryurl)
|
||||
- name: branch
|
||||
value: $(params.branch)
|
||||
- name: git-repo-name
|
||||
value: $(params.gitreponame)
|
||||
- name: revision
|
||||
value: $(params.gitrevision)
|
||||
- name: sha
|
||||
value: $(params.sha)
|
||||
- name: git-repo-full-name
|
||||
value: $(params.gitrepofullname)
|
23
Tekton/triggers/ingress-loadbalancer.yaml
Normal file
23
Tekton/triggers/ingress-loadbalancer.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: ingress-nginx
|
||||
namespace: ingress-nginx
|
||||
labels:
|
||||
app.kubernetes.io/name: ingress-nginx
|
||||
app.kubernetes.io/part-of: ingress-nginx
|
||||
spec:
|
||||
externalTrafficPolicy: Cluster
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app.kubernetes.io/name: ingress-nginx
|
||||
app.kubernetes.io/part-of: ingress-nginx
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: http
|
||||
- name: https
|
||||
port: 443
|
||||
protocol: TCP
|
||||
targetPort: https
|
48
Tekton/triggers/mirror-trigger-template.yaml
Normal file
48
Tekton/triggers/mirror-trigger-template.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: TriggerTemplate
|
||||
metadata:
|
||||
name: mirror-trigger-template
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
- name: gitrevision
|
||||
description: The git revision
|
||||
default: master
|
||||
- name: gitrepositoryurl
|
||||
description: The git repository url
|
||||
- name: gitreponame
|
||||
description: the name of the git repository
|
||||
- name: branch
|
||||
description: the name of the branch pushed to
|
||||
- name: gitrepofullname
|
||||
description: used for github status updates
|
||||
- name: sha
|
||||
description: used for github status updates
|
||||
resourcetemplates:
|
||||
- apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
generateName: mirror-pipeline-run-
|
||||
spec:
|
||||
serviceAccountName: service-acc
|
||||
pipelineRef:
|
||||
name: stage-application-pipeline
|
||||
Timeout: "2h30m00s"
|
||||
workspaces:
|
||||
- name: workspace
|
||||
persistentVolumeClaim:
|
||||
claimName: workspace
|
||||
params:
|
||||
- name: git-url
|
||||
value: $(params.gitrepositoryurl)
|
||||
- name: branch
|
||||
value: $(params.branch)
|
||||
- name: git-repo-name
|
||||
value: $(params.gitreponame)
|
||||
- name: revision
|
||||
value: $(params.gitrevision)
|
||||
- name: sha
|
||||
value: $(params.sha)
|
||||
- name: git-repo-full-name
|
||||
value: $(params.gitrepofullname)
|
Reference in New Issue
Block a user