mirror of
https://github.com/bvanroll/stage-infra.git
synced 2025-12-12 11:36:10 +00:00
mmmmmmmmmmmmm, denk dak het heb deze keer
This commit is contained in:
@@ -25,10 +25,17 @@ spec:
|
||||
env:
|
||||
- name: "DOCKER_CONFIG"
|
||||
value: "/tekton/home/.docker/"
|
||||
command:
|
||||
- /kaniko/executor
|
||||
args:
|
||||
- "--dockerfile=/source/$(params.context)/dockerfile"
|
||||
- "--destination=beppev/$(params.image-name):$(params.version)"
|
||||
- "--context=/source/$(params.context)/"
|
||||
- "--skip-tls-verify" #for speed reasons
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
/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
|
||||
|
||||
@@ -1,39 +1,35 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: jib-gradle
|
||||
name: build-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:
|
||||
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"
|
||||
- name: image-name
|
||||
description: name of the image after push
|
||||
- name: image-tag
|
||||
description: tag of the image after push
|
||||
workspaces:
|
||||
- name: source
|
||||
type: git
|
||||
outputs:
|
||||
resources:
|
||||
- name: image
|
||||
type: image
|
||||
mountPath: /source
|
||||
steps:
|
||||
- name: build-and-push
|
||||
image: gcr.io/cloud-builders/gradle
|
||||
script: |
|
||||
#!/bin/sh
|
||||
if [ $(inputs.params.build-type) != gradle]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
cd /source
|
||||
set -o errexit
|
||||
# Adds Gradle init script that applies the Jib Gradle plugin.
|
||||
echo "initscript {
|
||||
@@ -53,21 +49,25 @@ spec:
|
||||
--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)
|
||||
-Djib.allowInsecureRegistries=$(params.INSECUREREGISTRY) \
|
||||
-Djib.to.image=docker.io/beppev/$(params.image-name):$(params.image-tag) \
|
||||
-Djib.from.auth.username=beppev
|
||||
-Djib.from.auth.password=Azerty123
|
||||
-Djib.to.auth.username=beppev
|
||||
-Djib.to.auth.password=Azerty123
|
||||
exit 0
|
||||
workingDir: /workspace/source/$(inputs.params.DIRECTORY)
|
||||
workingDir: /workspace/source/$(params.DIRECTORY)
|
||||
volumeMounts:
|
||||
- name: $(inputs.params.CACHE)
|
||||
- name: $(params.CACHE)
|
||||
mountPath: /tekton/home/.gradle/caches
|
||||
subPath: gradle-caches
|
||||
- name: $(inputs.params.CACHE)
|
||||
- name: $(params.CACHE)
|
||||
mountPath: /tekton/home/.gradle/wrapper
|
||||
subPath: gradle-wrapper
|
||||
- name: $(inputs.params.CACHE)
|
||||
- name: $(params.CACHE)
|
||||
mountPath: /tekton/home/.m2
|
||||
subPath: m2-cache
|
||||
- name: $(inputs.params.CACHE)
|
||||
- name: $(params.CACHE)
|
||||
mountPath: /tekton/home/.cache
|
||||
subPath: jib-cache
|
||||
securityContext:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: deploy-app
|
||||
name: deploy-yaml-file
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
@@ -19,15 +19,27 @@ spec:
|
||||
- name: source
|
||||
mountpath: /source
|
||||
steps:
|
||||
- name: update-yaml
|
||||
image: alpine
|
||||
script: |
|
||||
sed -i -e 's;DEPLOY_NAME;$(params.deploy-name);g' /source/$(params.yaml-location)
|
||||
sed -i -e 's;DEPLOY_VERSION;$(params.deploy-version);g' /source/$(params.yaml-location)
|
||||
- name: deploy-new-app
|
||||
image: lachlanevenson/k8s-kubectl
|
||||
command: ["kubectl"]
|
||||
args:
|
||||
- "$(params.command)"
|
||||
- "-f"
|
||||
- "/source/$(params.yaml-location)"
|
||||
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
|
||||
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
|
||||
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
|
||||
else
|
||||
echo "success" | tee /tekton/results/state
|
||||
echo "deployed the yaml files to the cluster"
|
||||
fi
|
||||
exit 0
|
||||
28
Tekton/tasks/deploy-to-cluster.yaml
Normal file
28
Tekton/tasks/deploy-to-cluster.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task #this can be used to deploy a folder aswell as a file, but no replacing the names or versions
|
||||
metadata:
|
||||
name: deploy-to-cluster
|
||||
namespace: tekton-pipeline-1
|
||||
spec:
|
||||
params:
|
||||
- name: yaml-location
|
||||
default: infra/
|
||||
- name: command
|
||||
default: apply
|
||||
workspaces:
|
||||
- name: source
|
||||
mountpath: /source
|
||||
steps:
|
||||
- name: deploy-new-app
|
||||
image: lachlanevenson/k8s-kubectl
|
||||
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
|
||||
else
|
||||
echo "success" | tee /tekton/results/state
|
||||
echo "deployed the yaml files to the cluster"
|
||||
fi
|
||||
exit 0
|
||||
Reference in New Issue
Block a user