mmmmmmmmmmmmmmmmmmmmmmm

This commit is contained in:
2020-03-23 13:11:13 +01:00
parent 998358fe5e
commit 1e021f00d7
7 changed files with 78 additions and 164 deletions

View File

@@ -78,11 +78,11 @@ spec:
- name: SHA
value: $(params.revision)
- name: STATE
value: $(tasks.build-and-push.results.state)
value: "$(tasks.build-and-push.results.state)"
- name: TARGET_URL
value: http://ingress.llocal.host/$(params.git-repo-name)
- name: DESCRIPTION
value: $(tasks.build-and-push.results.description)
value: "$(tasks.build-and-push.results.description)"
- name: deploy-app
taskRef:
@@ -125,7 +125,7 @@ spec:
- name: SHA
value: $(params.revision)
- name: STATE
value: $(tasks.deploy-app.results.state)
value: "$(tasks.deploy-app.results.state)"
- name: TARGET_URL
value: http://tekton.llocal.host/$(params.git-repo-name)
- name: DESCRIPTION

View File

@@ -0,0 +1,20 @@
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: build-and-push-run
namespace: tekton-pipeline-1
spec:
taskRef:
name: build-and-push
params:
- name: image-name
value: "voorbeeldnaam"
- name: version
value: "voorbeeldversion"
workspaces:
- name: source
persistentVolumeClaim:
claimName: workspace
serviceAccountName: service-acc

View File

@@ -1,80 +1,15 @@
# ---
# apiVersion: tekton.dev/v1alpha1
# kind: Task
# metadata:
# name: buildah
# spec:
# inputs:
# params:
# - name: BUILDER_IMAGE
# description: The location of the buildah builder image.
# default: quay.io/buildah/stable:v1.11.0
# - name: DOCKERFILE
# description: Path to the Dockerfile to build.
# default: ./Dockerfile
# - name: CONTEXT
# description: Path to the directory to use as context.
# default: .
# - name: TLSVERIFY
# description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
# default: "true"
# - name: FORMAT
# description: The format of the built container, oci or docker
# default: "oci"
# resources:
# - name: source
# type: git
# outputs:
# resources:
# - name: image
# type: image
# steps:
# - name: build
# image: $(inputs.params.BUILDER_IMAGE)
# workingDir: /workspace/source
# command: ['buildah', 'bud', '--format=$(inputs.params.FORMAT)', '--tls-verify=$(inputs.params.TLSVERIFY)', '--layers', '-f', '$(inputs.params.DOCKERFILE)', '-t', '$(outputs.resources.image.url)', '$(inputs.params.CONTEXT)']
# volumeMounts:
# - name: varlibcontainers
# mountPath: /var/lib/containers
# securityContext:
# privileged: true
# - name: push
# image: $(inputs.params.BUILDER_IMAGE)
# workingDir: /workspace/source
# command: ['buildah', 'push', '--tls-verify=$(inputs.params.TLSVERIFY)', '$(outputs.resources.image.url)', 'docker://$(outputs.resources.image.url)']
# volumeMounts:
# - name: varlibcontainers
# mountPath: /var/lib/containers
# securityContext:
# privileged: true
# volumes:
# - name: varlibcontainers
# emptyDir: {}
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: build-and-push
namespace: tekton-pipeline-1
spec:
params:
- name: context
description: location of dockerfile etc
description: The path to the build context, used by Kaniko - within the workspace
default: .
- name: DOCKERFILE
description: The name of the Dockerfile
default: "Dockerfile"
- name: BUILDKIT_IMAGE
description: The name of the BuildKit image
# The image needs to be rootful because Tekton creates /builder/home/.docker/config.json owned by root:root with 0600
# https://github.com/tektoncd/pipeline/issues/852
default: "moby/buildkit:v0.6.2"
type: string
- name: image-name
description: dockerhub url
type: string
@@ -89,71 +24,25 @@ spec:
description: state of the next github update
- name: description
description: description of the next github update
steps:
- name: build-and-push
image: $(inputs.params.BUILDKIT_IMAGE)
env:
- name: "DOCKER_CONFIG"
value: "/tekton/home/.docker/"
workingDir: /source
securityContext:
privileged: true
script: |
#!/bin/sh
cd $(params.context) && buildctl-daemonless.sh --debug build --progress=plain --frontend=dockerfile.v0 --opt filename=dockerfile --local context=.. --local dockerfile=. --output type=image,name=beppev/$(params.image-name):$(params.version)
if [ "$?" = 0 ]; then
echo "pending" > /tekton/results/state
echo "build and push successful" > /tekton/results/description
else
echo "failure" | tee /tekton/results/state
echo "build and push were not successful use kubectl or tkn or tekton dashboard to see logs" > /tekton/results/description
fi
---
# apiVersion: tekton.dev/v1alpha1
# kind: Task
# metadata:
# name: build-and-push
# namespace: tekton-pipeline-1
# spec:
# params:
# - name: context
# description: The path to the build context, used by Kaniko - within the workspace
# default: .
# type: string
# - name: image-name
# description: dockerhub url
# type: string
# - name: version
# description: image-version (for instance latest or beta)
# type: string
# workspaces:
# - name: source
# mountpath: /source
# results:
# - name: state
# description: state of the next github update
# - name: description
# description: description of the next github update
# steps:
# - name: build-and-push
# image: gcr.io/kaniko-project/executor:debug #normal kaniko doesnt have a shell, so it doesnt allow us to use scripting to update the github status
# env:
# - name: "DOCKER_CONFIG"
# value: "/tekton/home/.docker/"
# securityContext:
# runAsUser: 0
# script: |
# #!/bin/sh
# echo "test"
# /kaniko/executor --dockerfile=/source/$(params.context)/dockerfile --destination=beppev/$(params.image-name):$(params.version) --context=/source/$(params.context)/ --skip-tls-verify
# if [ "$?" = 0 ]; then
# echo "pending" | tee /tekton/results/state
# echo "build and push successful" | tee /tekton/results/description
# else
# echo "failure" | tee /tekton/results/state
# echo "build and push were not successful use kubectl or tkn or tekton dashboard to see logs" | tee /tekton/results/description
# fi
# exit 0
---
- name: build-and-push
image: gcr.io/kaniko-project/executor:debug
env:
- name: "DOCKER_CONFIG"
value: "/tekton/home/.docker/"
command:
- '/busybox/sh'
- '-c'
args:
- |-
#!/bin/sh
echo "test"
/kaniko/executor --dockerfile=/source/$(params.context)/dockerfile --destination=beppev/$(params.image-name):$(params.version) --context=/source/$(params.context)/ --skip-tls-verify --skip-tls-verify-pull
if [ "$?" = 0 ]; then
printf "pending" > /tekton/results/state
printf "build and push successful" > /tekton/results/description
else
printf "failure" > /tekton/results/state
printf "build and push were not successful use kubectl or tkn or tekton dashboard to see logs" > /tekton/results/description
fi
exit 0

View File

@@ -29,22 +29,22 @@ spec:
script: |
sed -i -e 's;DEPLOY_NAME;$(params.deploy-name);g' /source/$(params.yaml-location)
if [ "$?" != 0 ]; then
echo "failure" | tee /tekton/results/state
echo "replacing deploy name in yaml file failed, please check if the yaml file is in the correct location ($(params.yaml-location))" | tee /tekton/results/description
printf "failure" > /tekton/results/state
printf "replacing deploy name in yaml file failed, please check if the yaml file is in the correct location ($(params.yaml-location))" > /tekton/results/description
exit 0
fi
sed -i -e 's;DEPLOY_VERSION;$(params.deploy-version);g' /source/$(params.yaml-location)
if [ "$?" != 0 ]; then
echo "failure" | tee /tekton/results/state
echo "replacing deploy version in yaml file failed, please check if the yaml file is in the correct location ($(params.yaml-location))" | tee /tekton/results/description
printf "failure" > /tekton/results/state
printf "replacing deploy version in yaml file failed, please check if the yaml file is in the correct location ($(params.yaml-location))" > /tekton/results/description
exit 0
fi
kubectl $(params.command) -f /source/$(params.yaml-location)
if [ "$?" != 0 ]; then
echo "failure" | tee /tekton/results/state
echo "failure applying yaml file to cluster ($(params.yaml-location))" | tee /tekton/results/description
printf "failure" > /tekton/results/state
printf "failure applying yaml file to cluster ($(params.yaml-location))" > /tekton/results/description
else
echo "success" | tee /tekton/results/state
echo "deployed the yaml files to the cluster"
printf "success" > /tekton/results/state
printf "deployed the yaml files to the cluster"
fi
exit 0

View File

@@ -24,10 +24,10 @@ spec:
script: |
kubectl $(params.command) -f /source/$(params.yaml-location)
if [ "$?" != 0 ]; then
echo "failure" | tee /tekton/results/state
echo "failure applying yaml file to cluster ($(params.yaml-location))" | tee /tekton/results/description
printf "failure" > /tekton/results/state
printf "failure applying yaml file to cluster ($(params.yaml-location))" > /tekton/results/description
else
echo "success" | tee /tekton/results/state
echo "deployed the yaml files to the cluster"
printf "success" > /tekton/results/state
printf "deployed the yaml files to the cluster"
fi
exit 0

View File

@@ -107,20 +107,6 @@ spec:
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:

View File

@@ -41,3 +41,22 @@ spec:
protocol: TCP
port: 443
targetPort: 443
---
apiVersion: v1
kind: Service
metadata:
name: DEPLOY_NAME-DEPLOY_VERSION-service
namespace: default
spec:
selector:
app: DEPLOY_NAME
version: DEPLOY_VERSION
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
- name: https
protocol: TCP
port: 443
targetPort: 443