chore: pipelines, src

This commit is contained in:
Jesús Pérez Lorenzo 2022-01-13 23:09:43 +00:00
parent 3c02febe77
commit 42e3e64279
15 changed files with 930 additions and 0 deletions

View file

@ -0,0 +1,29 @@
kind: PersistentVolume
apiVersion: v1
metadata:
name: cdci-apache-php-pvc-volume
namespace: cdci-librecloud-online
labels:
type: local
spec:
storageClassName: manual
persistentVolumeReclaimPolicy: Delete
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/cdci"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: cdci-apache-php-pvc
namespace: cdci-librecloud-online
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

6
pipeline/down.sh Executable file
View file

@ -0,0 +1,6 @@
#/bin/bash
kubectl delete -f pipeline-run.yaml 2>/dev/null
kubectl delete -f pipeline.yaml 2>/dev/null
kubectl delete -f task.yaml 2>/dev/null
kubectl delete -f PersistentVolumeCDCI.yaml 2>/dev/null
kubectl delete -f pipe-resource.yaml 2>/dev/null

View file

@ -0,0 +1,24 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: librecloud-apache-php-img
namespace: cdci-librecloud-online
spec:
type: image
params:
- name: url
value: termas.librecloud.online/termas_librecloud/apache-php:7.4
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: librecloud-apache-php-git
namespace: cdci-librecloud-online
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://rlung.librecloud.online/Termas_LibreCloud/apache-php.git

View file

@ -0,0 +1,22 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: cdci-apache-php
namespace: cdci-librecloud-online
spec:
serviceAccountName: build-bot
pipelineRef:
name: cdci-apache-php
# podTemplate:
#volumes:
#- name: cdci-volume
# #emptyDir: {}
# persistentVolumeClaim:
# claimName: cdci-apache-php-pvc
resources:
- name: source-repo
resourceRef:
name: librecloud-apache-php-git
- name: target-image
resourceRef:
name: librecloud-apache-php-img

32
pipeline/pipeline.yaml Normal file
View file

@ -0,0 +1,32 @@
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: cdci-apache-php
namespace: cdci-librecloud-online
spec:
#serviceAccount: build-bot
resources:
- name: source-repo
type: git
#resourceRef:
# name: librecloud-apache-php-git
- name: target-image
type: image
#resourceRef:
# name: librecloud-apache-php-img
tasks:
- name: build-apache-php-img
taskRef:
name: apache-php-build-image-from-git-source
params:
- name: pathToDockerFile
value: /workspace/source/src
- name: pathToContext
value: /workspace/source/src #configure: may change according to your source
resources:
inputs:
- name: source
resource: source-repo
outputs:
- name: builtImage
resource: target-image

91
pipeline/task.yaml Normal file
View file

@ -0,0 +1,91 @@
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: apache-php-build-image-from-git-source
namespace: cdci-librecloud-online
spec:
#serviceAccount: build-bot
inputs:
params:
- name: pathToDockerFile
type: string
description: The path to the dockerfile to build
default: /workspace/source/src/Dockerfile
- name: pathToContext
type: string
description:
The build context used by Kaniko
(https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
default: /workspace/source/src
- name: DOCKERFILE
type: string
description: The name of the Dockerfile
default: "Dockerfile"
- name: BUILDKIT_CLIENT_IMAGE
type: string
description: The name of the BuildKit client (buildctl) image
default: "docker.io/moby/buildkit:master-rootless"
- name: BUILDKIT_DAEMON_ADDRESS
type: string
description: The address of the BuildKit daemon (buildkitd) service
default: "tcp://buildkitd:1234"
resources:
- name: source
type: git
outputs:
resources:
- name: builtImage
type: image
volumes:
- name: dckr-cfg-volume
secret:
secretName: regcred
- name: ssh-volume
secret:
secretName: ssh-key
- name: certs
secret:
secretName: buildkit-client-certs
steps:
- name: build-and-push
image: $(inputs.params.BUILDKIT_CLIENT_IMAGE)
workingDir: /workspace/source
command: [ "buildctl" ]
args:
- --tlscacert
- /certs/ca.pem
- --tlscert
- /certs/cert.pem
- --tlskey
- /certs/key.pem
- --debug
- --addr=$(inputs.params.BUILDKIT_DAEMON_ADDRESS)
- build
- --progress=plain
- --frontend=dockerfile.v0
- --opt
- filename=$(inputs.params.DOCKERFILE)
- --local
- context=$(inputs.params.pathToContext)
- --local
- dockerfile=$(inputs.params.pathToDockerFile)
- --output
- type=image,name=$(outputs.resources.builtImage.url),push=true
- --export-cache
- type=inline
- --import-cache
- type=registry,ref=$(outputs.resources.builtImage.url)
volumeMounts:
- name: certs
readOnly: true
mountPath: /certs
- name: ssh-volume
readOnly: true
mountPath: /.ssh

24
pipeline/up.sh Executable file
View file

@ -0,0 +1,24 @@
#/bin/bash
FOLLOW_UP="yes"
NS_DOMAIN="cdci-librecloud-online"
PIPELINE_NAME="cdci-apache-php"
[ "$1" == "-s" ] && FOLLOW_UP=""
is_running=`kubectl get pods -n $NS_DOMAIN | grep $PIPELINE_NAME 2>/dev/null`
if [ -n "$is_running" ] ; then
kubectl delete -f pipeline-run.yaml 2>/dev/null
kubectl delete -f pipeline.yaml 2>/dev/null
kubectl delete -f task.yaml 2>/dev/null
kubectl delete -f pipe-resource.yaml 2>/dev/null
fi
kubectl delete -f PersistentVolumeCDCI.yaml 2>/dev/null
kubectl create -f PersistentVolumeCDCI.yaml
#. lib_dply.sh
#make_host_alias task
kubectl apply -f pipe-resource.yaml
kubectl apply -f task.yaml
kubectl apply -f pipeline.yaml
kubectl apply -f pipeline-run.yaml
if [ -n "$FOLLOW_UP" ] ; then
has_tkn=`type tkn 2>/dev/null`
[ -n "$has_tkn" ] && tkn pipelinerun logs -f $PIPELINE_NAME -n $NS_DOMAIN
fi