From d9faa1043fbd3f34e6553f42c68c6368de369e32 Mon Sep 17 00:00:00 2001 From: beppe Date: Mon, 16 Mar 2020 16:18:59 +0100 Subject: [PATCH] run dees pipeline --- Tekton/pipeline/pipeline.yaml | 5 ++++ Tekton/tasks/deploy-app.yaml | 10 +++++++- deploy-example.yaml | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 deploy-example.yaml diff --git a/Tekton/pipeline/pipeline.yaml b/Tekton/pipeline/pipeline.yaml index 8770388..0219420 100644 --- a/Tekton/pipeline/pipeline.yaml +++ b/Tekton/pipeline/pipeline.yaml @@ -54,5 +54,10 @@ spec: workspaces: - name: source workspace: workspace + params: + - name: deploy-name + value: "$(params.git-repo-name)" + - name: deploy-version + value: "$(params.branch)" runAfter: - build-and-push \ No newline at end of file diff --git a/Tekton/tasks/deploy-app.yaml b/Tekton/tasks/deploy-app.yaml index 5a1cc1d..dcd65df 100644 --- a/Tekton/tasks/deploy-app.yaml +++ b/Tekton/tasks/deploy-app.yaml @@ -8,13 +8,21 @@ metadata: spec: params: - name: yaml-location - default: deploy.yaml + default: infra/deploy.yaml - name: command default: apply + - name: deploy-name + - name: deploy-version workspaces: - name: source mountpath: /source steps: + - name: update-yaml + image: alpine + script: | + #!/usr/bin/env bash + sed -i -e s;DEPLOY_NAME;$(params.deploy-name);g $(params.yaml-location) + sed -i -e s;DEPLOY_VERSION;$(params.deploy-version);g $(params.yaml-location) - name: deploy-new-app image: lachlanevenson/k8s-kubectl command: ["kubectl"] diff --git a/deploy-example.yaml b/deploy-example.yaml new file mode 100644 index 0000000..3249e36 --- /dev/null +++ b/deploy-example.yaml @@ -0,0 +1,43 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: DEPLOY_NAME-DEPLOY_VERSION + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: DEPLOY_NAME + version: DEPLOY_VERSION + template: + metadata: + labels: + app: DEPLOY_NAME + version: DEPLOY_VERSION + spec: + containers: + - name: main + image: beppev/DEPLOY_NAME:DEPLOY_VERSION + imagePullPolicy: "Always" + ports: + - containerPort: 80 + - containerPort: 443 +--- +apiVersion: v1 +kind: Service +metadata: + name: DEPLOY_NAME-service + namespace: default +spec: + selector: + app: DEPLOY_NAME + ports: + - name: http + protocol: TCP + port: 80 + targetPort: 80 + - name: https + protocol: TCP + port: 443 + targetPort: 443 \ No newline at end of file