From 54710dc73f31f2366086476be13952239faf0f17 Mon Sep 17 00:00:00 2001 From: beppe Date: Thu, 19 Mar 2020 11:27:28 +0100 Subject: [PATCH] infra pipeline specialised --- .../pipeline/back-end-pipeline.yaml | 0 Tekton/pipeline/infra-pipeline.yaml | 87 +++++++++++++++++++ Tekton/pipeline/mirror-service-pipeline.yaml | 0 Tekton/tasks/deploy-app.yaml | 2 + Tekton/triggers/infra-trigger-template.yaml | 6 +- infra/example-service.yaml | 11 +++ 6 files changed, 102 insertions(+), 4 deletions(-) rename infra/deploy-example.yaml => Tekton/pipeline/back-end-pipeline.yaml (100%) create mode 100644 Tekton/pipeline/infra-pipeline.yaml create mode 100644 Tekton/pipeline/mirror-service-pipeline.yaml create mode 100644 infra/example-service.yaml diff --git a/infra/deploy-example.yaml b/Tekton/pipeline/back-end-pipeline.yaml similarity index 100% rename from infra/deploy-example.yaml rename to Tekton/pipeline/back-end-pipeline.yaml diff --git a/Tekton/pipeline/infra-pipeline.yaml b/Tekton/pipeline/infra-pipeline.yaml new file mode 100644 index 0000000..043ad56 --- /dev/null +++ b/Tekton/pipeline/infra-pipeline.yaml @@ -0,0 +1,87 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: infra-pipeline + namespace: tekton-pipeline-1 +spec: + params: + - 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 check out + - 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) + workspaces: + - name: workspace + tasks: + + - name: clone-git-repo + taskRef: + name: git-clone + workspaces: + - name: output + workspace: workspace + params: + - name: url + value: $(params.git-url) + - name: revision + value: $(params.revision) + + - name: set-begun-status + taskRef: + name: github-set-status + runAfter: + - clone-git-repo + params: + - name: REPO_FULL_NAME + value: $(params.git-repo-full-name) + - name: SHA + value: $(params.revision) + - name: TARGET_URL + value: tekton.llocal.host/dashboard + - name: STATE + value: pending + - name: DESCRIPTION + value: "Deploy to cluster has started (will not complete if this is not master branch)" + + - name: deploy-infrastructure + taskRef: + name: deploy-app + runAfter: + - clone-git-repo + workspaces: + - name: source + workspace: workspace + params: + - name: yaml-location + value: infra/ + conditions: + - conditionRef: "is-not-equal" + params: + - name: "left" + value: "master" + - name: "right" + value: "$(params.branch)" + + - name: set-finished-state + taskRef: + name: github-set-status + runAfter: + - deploy-infrastructure + - set-begun-status + params: + - name: REPO_FULL_NAME + value: $(params.git-repo-full-name) + - name: SHA + value: $(params.revision) + - name: TARGET_URL + value: tekton.llocal.host/dashboard + - name: STATE + value: success + - name: DESCRIPTION + value: "deployment applied" diff --git a/Tekton/pipeline/mirror-service-pipeline.yaml b/Tekton/pipeline/mirror-service-pipeline.yaml new file mode 100644 index 0000000..e69de29 diff --git a/Tekton/tasks/deploy-app.yaml b/Tekton/tasks/deploy-app.yaml index 243353c..362a9fe 100644 --- a/Tekton/tasks/deploy-app.yaml +++ b/Tekton/tasks/deploy-app.yaml @@ -12,7 +12,9 @@ spec: - name: command default: apply - name: deploy-name + default: "" - name: deploy-version + default: "" workspaces: - name: source mountpath: /source diff --git a/Tekton/triggers/infra-trigger-template.yaml b/Tekton/triggers/infra-trigger-template.yaml index aaf4ff8..03faa44 100644 --- a/Tekton/triggers/infra-trigger-template.yaml +++ b/Tekton/triggers/infra-trigger-template.yaml @@ -27,8 +27,8 @@ spec: spec: serviceAccountName: service-acc pipelineRef: - name: stage-application-pipeline - Timeout: "2h30m00s" + name: infra-pipeline + Timeout: "30m00s" workspaces: - name: workspace persistentVolumeClaim: @@ -42,7 +42,5 @@ spec: 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/infra/example-service.yaml b/infra/example-service.yaml new file mode 100644 index 0000000..ae8bf72 --- /dev/null +++ b/infra/example-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: example-service + namespace: default +spec: + ports: + - name: test + protocol: TCP + port: 666 + targetPort: 666 \ No newline at end of file