chore: pipe and src
This commit is contained in:
parent
40b6165f00
commit
ece33f9ed8
23 changed files with 907 additions and 0 deletions
29
pipeline/PersistentVolumeCDCI.yaml
Normal file
29
pipeline/PersistentVolumeCDCI.yaml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
kind: PersistentVolume
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: cdci-nginx-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-nginx-pvc
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
storageClassName: manual
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
6
pipeline/down.sh
Executable file
6
pipeline/down.sh
Executable 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
|
||||
24
pipeline/pipe-resource.yaml
Normal file
24
pipeline/pipe-resource.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineResource
|
||||
metadata:
|
||||
name: librecloud-nginx-img
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
type: image
|
||||
params:
|
||||
- name: url
|
||||
value: termas.librecloud.online/termas_librecloud/nginx:1.21.0
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineResource
|
||||
metadata:
|
||||
name: librecloud-nginx-git
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
type: git
|
||||
params:
|
||||
- name: revision
|
||||
value: master
|
||||
- name: url
|
||||
value: https://rlung.librecloud.online/Termas_LibreCloud/nginx.git
|
||||
|
||||
22
pipeline/pipeline-run.yaml
Normal file
22
pipeline/pipeline-run.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
name: cdci-nginx
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
serviceAccountName: build-bot
|
||||
pipelineRef:
|
||||
name: cdci-nginx
|
||||
# podTemplate:
|
||||
#volumes:
|
||||
#- name: cdci-volume
|
||||
# #emptyDir: {}
|
||||
# persistentVolumeClaim:
|
||||
# claimName: cdci-nginx-pvc
|
||||
resources:
|
||||
- name: source-repo
|
||||
resourceRef:
|
||||
name: librecloud-nginx-git
|
||||
- name: target-image
|
||||
resourceRef:
|
||||
name: librecloud-nginx-img
|
||||
32
pipeline/pipeline.yaml
Normal file
32
pipeline/pipeline.yaml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: cdci-nginx
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
#serviceAccount: build-bot
|
||||
resources:
|
||||
- name: source-repo
|
||||
type: git
|
||||
#resourceRef:
|
||||
# name: librecloud-nginx-git
|
||||
- name: target-image
|
||||
type: image
|
||||
#resourceRef:
|
||||
# name: librecloud-nginx-img
|
||||
tasks:
|
||||
- name: build-nginx-img
|
||||
taskRef:
|
||||
name: nginx-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
91
pipeline/task.yaml
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: nginx-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
24
pipeline/up.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#/bin/bash
|
||||
FOLLOW_UP="yes"
|
||||
NS_DOMAIN="cdci-librecloud-online"
|
||||
PIPELINE_NAME="cdci-nginx"
|
||||
[ "$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
|
||||
Loading…
Add table
Add a link
Reference in a new issue