diff --git a/Tekton/pipeline/front-end-pipeline.yaml b/Tekton/pipeline/front-end-pipeline.yaml new file mode 100644 index 0000000..c700d7f --- /dev/null +++ b/Tekton/pipeline/front-end-pipeline.yaml @@ -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 + diff --git a/Tekton/pipeline/pipeline.yaml b/Tekton/pipeline/pipeline.yaml index 601d163..617eff5 100644 --- a/Tekton/pipeline/pipeline.yaml +++ b/Tekton/pipeline/pipeline.yaml @@ -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 \ No newline at end of file + - 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" \ No newline at end of file diff --git a/Tekton/tasks/build-gradle.yaml b/Tekton/tasks/build-gradle.yaml new file mode 100644 index 0000000..d592687 --- /dev/null +++ b/Tekton/tasks/build-gradle.yaml @@ -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: {} \ No newline at end of file diff --git a/Tekton/tasks/build-image.yaml b/Tekton/tasks/build-image.yaml index e69de29..1b6f71e 100644 --- a/Tekton/tasks/build-image.yaml +++ b/Tekton/tasks/build-image.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/tasks/create-webhook.yaml b/Tekton/tasks/create-webhook.yaml index ddef1d8..171c049 100644 --- a/Tekton/tasks/create-webhook.yaml +++ b/Tekton/tasks/create-webhook.yaml @@ -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)..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)..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 \ No newline at end of file diff --git a/Tekton/tasks/get-build-type.yaml b/Tekton/tasks/get-build-type.yaml new file mode 100644 index 0000000..c8777fa --- /dev/null +++ b/Tekton/tasks/get-build-type.yaml @@ -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 diff --git a/Tekton/tasks/github-set-status.yaml b/Tekton/tasks/github-set-status.yaml new file mode 100644 index 0000000..0dd54e1 --- /dev/null +++ b/Tekton/tasks/github-set-status.yaml @@ -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) ") \ No newline at end of file diff --git a/Tekton/triggers/back-end-trigger-template.yaml b/Tekton/triggers/back-end-trigger-template.yaml new file mode 100644 index 0000000..7214fb7 --- /dev/null +++ b/Tekton/triggers/back-end-trigger-template.yaml @@ -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) \ No newline at end of file diff --git a/Tekton/triggers/event-listener.yaml b/Tekton/triggers/event-listener.yaml index 5229fda..f0a2168 100644 --- a/Tekton/triggers/event-listener.yaml +++ b/Tekton/triggers/event-listener.yaml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/Tekton/triggers/front-end-trigger-template.yaml b/Tekton/triggers/front-end-trigger-template.yaml new file mode 100644 index 0000000..6c93292 --- /dev/null +++ b/Tekton/triggers/front-end-trigger-template.yaml @@ -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) \ No newline at end of file diff --git a/Tekton/triggers/trigger-binding-github.yaml b/Tekton/triggers/github-trigger-binding.yaml similarity index 68% rename from Tekton/triggers/trigger-binding-github.yaml rename to Tekton/triggers/github-trigger-binding.yaml index 66cd057..c86e8ce 100644 --- a/Tekton/triggers/trigger-binding-github.yaml +++ b/Tekton/triggers/github-trigger-binding.yaml @@ -13,4 +13,8 @@ spec: - name: gitreponame value: $(body.repository.name) - name: branch - value: $(body.repository.default_branch) \ No newline at end of file + value: $(body.repository.default_branch) + - name: gitrepofullname + value: $(body.repository.full_name) + - name: sha + value: $(body.head_commit.id) \ No newline at end of file diff --git a/Tekton/triggers/gitlab-trigger-binding.yaml b/Tekton/triggers/gitlab-trigger-binding.yaml index 71c29d3..27d907a 100644 --- a/Tekton/triggers/gitlab-trigger-binding.yaml +++ b/Tekton/triggers/gitlab-trigger-binding.yaml @@ -11,4 +11,8 @@ spec: - name: gitrepositoryurl value: "$(body.project.http_url)" - name: gitreponame - value: $(body.project.name) \ No newline at end of file + value: $(body.project.name) + - name: gitrepofullname + value: $(body.project.fullname) + - name: sha + value: $(body.project.sha) \ No newline at end of file diff --git a/Tekton/triggers/infra-trigger-template.yaml b/Tekton/triggers/infra-trigger-template.yaml new file mode 100644 index 0000000..aaf4ff8 --- /dev/null +++ b/Tekton/triggers/infra-trigger-template.yaml @@ -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) \ No newline at end of file diff --git a/Tekton/triggers/ingress-loadbalancer.yaml b/Tekton/triggers/ingress-loadbalancer.yaml new file mode 100644 index 0000000..af88173 --- /dev/null +++ b/Tekton/triggers/ingress-loadbalancer.yaml @@ -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 \ No newline at end of file diff --git a/Tekton/triggers/mirror-trigger-template.yaml b/Tekton/triggers/mirror-trigger-template.yaml new file mode 100644 index 0000000..e206876 --- /dev/null +++ b/Tekton/triggers/mirror-trigger-template.yaml @@ -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) \ No newline at end of file diff --git a/Utilities/event-listener-debug.yaml b/Utilities/event-listener-debug.yaml index 3b5ed7c..a43b01f 100644 --- a/Utilities/event-listener-debug.yaml +++ b/Utilities/event-listener-debug.yaml @@ -3,6 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: shell-demo + namespace: tekton-pipeline-1 spec: replicas: 1 selector: @@ -10,16 +11,38 @@ spec: app.kubernetes.io/managed-by: EventListener app.kubernetes.io/part-of: Triggers eventlistener: github-event-listener + test: "true" template: metadata: labels: app.kubernetes.io/managed-by: EventListener app.kubernetes.io/part-of: Triggers eventlistener: github-event-listener + test: "true" spec: containers: - name: network-multitool image: praqma/network-multitool imagePullPolicy: "Always" ports: - - containerPort: 8080 \ No newline at end of file + - containerPort: 8080 + - containerPort: 80 + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 5 +--- +apiVersion: v1 +kind: Service +metadata: + name: test-service + namespace: tekton-pipeline-1 +spec: + selector: + test: "true" + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 diff --git a/Utilities/tekton-dashboard-loadbalancer.yaml b/Utilities/tekton-dashboard-loadbalancer.yaml new file mode 100644 index 0000000..9186f8b --- /dev/null +++ b/Utilities/tekton-dashboard-loadbalancer.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: manual-service + namespace: tekton-pipelines +spec: + ports: + - name: http-listener + port: 9097 + protocol: TCP + targetPort: 9097 + selector: + app: tekton-dashboard + type: LoadBalancer \ No newline at end of file