chore: config, src and pipelines
This commit is contained in:
parent
75c62e9fe0
commit
a8cc48f8f2
29
pipeline/PersistentVolumeCDCI.yaml
Normal file
29
pipeline/PersistentVolumeCDCI.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
kind: PersistentVolume
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: cdci-tasksmanager-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-tasksmanager-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-tasksmanager-img
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
type: image
|
||||
params:
|
||||
- name: url
|
||||
value: termas.librecloud.online/termas_librecloud/tasksmanager:1.1
|
||||
---
|
||||
apiVersion: tekton.dev/v1alpha1
|
||||
kind: PipelineResource
|
||||
metadata:
|
||||
name: librecloud-tasksmanager-git
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
type: git
|
||||
params:
|
||||
- name: revision
|
||||
value: master
|
||||
- name: url
|
||||
value: https://rlung.librecloud.online/Termas_LibreCloud/tasksmanager.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-tasksmanager
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
serviceAccountName: build-bot
|
||||
pipelineRef:
|
||||
name: cdci-tasksmanager
|
||||
# podTemplate:
|
||||
#volumes:
|
||||
#- name: cdci-volume
|
||||
# #emptyDir: {}
|
||||
# persistentVolumeClaim:
|
||||
# claimName: cdci-tasksmanager-pvc
|
||||
resources:
|
||||
- name: source-repo
|
||||
resourceRef:
|
||||
name: librecloud-tasksmanager-git
|
||||
- name: target-image
|
||||
resourceRef:
|
||||
name: librecloud-tasksmanager-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-tasksmanager
|
||||
namespace: cdci-librecloud-online
|
||||
spec:
|
||||
#serviceAccount: build-bot
|
||||
resources:
|
||||
- name: source-repo
|
||||
type: git
|
||||
#resourceRef:
|
||||
# name: librecloud-tasksmanager-git
|
||||
- name: target-image
|
||||
type: image
|
||||
#resourceRef:
|
||||
# name: librecloud-tasksmanager-img
|
||||
tasks:
|
||||
- name: build-tasksmanager-img
|
||||
taskRef:
|
||||
name: tasksmanager-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: tasksmanager-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-tasksmanager"
|
||||
[ "$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
|
21
repo-config.yaml
Normal file
21
repo-config.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
Active: true
|
||||
# Active: false # to not follow up webhook workflow
|
||||
|
||||
# Sources for src file
|
||||
Repo: https://github.com/nehabhardwaj01/docker-cron.git
|
||||
Source: .
|
||||
|
||||
#TargetGit: ssh://git@rlung.librecloud.online:32225/Termas.LibreCloud.online/taskmanager.git
|
||||
|
||||
Name: tasksmanager
|
||||
Version: 1.1
|
||||
|
||||
# To get latest_image
|
||||
# It is based in [Running a Cron Job in Docker Container](https://blog.knoldus.com/running-a-cron-job-in-docker-container)
|
||||
# with code in [docker-com](https://github.com/nehabhardwaj01/docker-cron).
|
||||
#
|
||||
|
||||
IMAGE_NAME: nehabhardwaj01/docker-cron
|
||||
#IMAGE_MATCH: 2.
|
||||
|
88
src/Dockerfile
Normal file
88
src/Dockerfile
Normal file
@ -0,0 +1,88 @@
|
||||
# From https://github.com/nehabhardwaj01/docker-cron
|
||||
|
||||
FROM alpine:3.14.1
|
||||
MAINTAINER Jesús Pérez
|
||||
|
||||
ENV RESTIC_VERSION=0.21.1
|
||||
ENV K8S_VERSION=1.22.0
|
||||
ENV K8S_ARCH=linux/amd64
|
||||
ENV JQ_VERSION=1.6
|
||||
ENV JQ_ARCH=linux64
|
||||
ENV YQ_VERSION=4.11.2
|
||||
ENV YQ_ARCH=linux_amd64
|
||||
ENV RESTIC_ARCH=linux_amd64
|
||||
|
||||
ENV SCW_VERSION=2.3.1
|
||||
ENV SCW_ARCH=linux-amd64
|
||||
|
||||
ENV DOCTL_VERSION=1.63.3
|
||||
ENV DOCTL_ARCH=linux-amd64
|
||||
|
||||
ENV AWS_VERSION=1.2022.
|
||||
ENV AWS_ARCH=linux-amd64
|
||||
|
||||
ENV UPCTL_VERSION="1.1.0"
|
||||
ENV UPCTL_ARCH="linux_x86_64"
|
||||
|
||||
RUN apk update \
|
||||
&& apk upgrade \
|
||||
&& apk add --no-cache \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
bash \
|
||||
curl \
|
||||
apk-cron \
|
||||
git \
|
||||
bzip2 \
|
||||
sed \
|
||||
supervisor \
|
||||
fuse \
|
||||
libressl \
|
||||
vim \
|
||||
ssmtp \
|
||||
zlib \
|
||||
python3 \
|
||||
gnupg \
|
||||
wget \
|
||||
unzip \
|
||||
libmagic \
|
||||
&& update-ca-certificates \
|
||||
&& python3 -m ensurepip \
|
||||
&& rm -r /usr/lib/python*/ensurepip \
|
||||
&& pip3 install --upgrade pip setuptools \
|
||||
&& if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi \
|
||||
&& if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& pip3 install jinja2 s3cmd awscli \
|
||||
&& curl -fSL https://storage.googleapis.com/kubernetes-release/release/v${K8S_VERSION}/bin/${K8S_ARCH}/kubectl -o /usr/local/bin/kubectl \
|
||||
&& chmod +x /usr/local/bin/kubectl \
|
||||
&& curl -fSL https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-${JQ_ARCH} -o /usr/local/bin/jq \
|
||||
&& chmod +x /usr/local/bin/jq \
|
||||
&& curl -fSL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_${YQ_ARCH} -o /usr/local/bin/yq \
|
||||
&& chmod +x /usr/local/bin/yq \
|
||||
&& curl -fSl https://github.com/scaleway/scaleway-cli/releases/download/v${SCW_VERSION}/scw-${SCW_ARCH} -o /usr/local/bin/scw \
|
||||
&& chmod +x /usr/local/bin/scw \
|
||||
&& curl -fSL https://github.com/digitalocean/doctl/releases/download/v${DOCTL_VERSION}/doctl-${DOCTL_VERSION}-${DOCTL_ARCH}.tar.gz -o /usr/local/bin/doctl \
|
||||
&& chmod +x /usr/local/bin/doctl \
|
||||
&& wget -q https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_${RESTIC_ARCH}.bz2 -O /tmp/restic-${RESTIC_VERSION}.bz2 \
|
||||
&& bunzip2 /tmp/restic-${RESTIC_VERSION}.bz2 \
|
||||
&& mv /tmp/restic-${RESTIC_VERSION} /usr/local/bin/restic \
|
||||
&& chmod +x /usr/local/bin/restic \
|
||||
&& rm -f /tmp/restic*
|
||||
&& echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
|
||||
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - \
|
||||
&& apt-get update -y \
|
||||
&& apt-get install google-cloud-sdk -y \
|
||||
&& curl -fSL https://github.com/UpCloudLtd/upcloud-cli/releases/download/v${UPCTL_VERSION}/upcloud-cli_${UPCTL_VERSION}_${UPCTL_ARCH}.tar.gz -o /tmp/upctl.tar.gz \
|
||||
&& tar xvzCf /usr/local/bin /tmp/upctl.tar.gz upctl \
|
||||
&& chmod +x /usr/local/bin/upctl \
|
||||
&& rm -f /tmp/upctl.tar.gz
|
||||
|
||||
|
||||
# Add files
|
||||
ADD run.sh /usr/local/bin/run.sh
|
||||
ADD entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
|
||||
RUN chmod +x /usr/local/bin/run.sh /usr/local/bin/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
16
src/entrypoint.sh
Executable file
16
src/entrypoint.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# from https://blog.knoldus.com/running-a-cron-job-in-docker-container
|
||||
|
||||
# Start the run once job.
|
||||
echo "Container has been started"
|
||||
|
||||
declare -p | grep -Ev 'BASHOPTS|BASH_VERSINFO|EUID|PPID|SHELLOPTS|UID' > /container.env
|
||||
|
||||
# Setup a cron schedule
|
||||
echo "SHELL=/bin/bash
|
||||
BASH_ENV=/container.env
|
||||
*/5 * * * * /usr/local/bin/run.sh >> /var/log/cron.log 2>&1
|
||||
# This extra line makes it a valid cron" > scheduler.txt
|
||||
|
||||
crontab scheduler.txt
|
||||
crond -f
|
3
src/run.sh
Executable file
3
src/run.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
timestamp=`date +%Y/%m/%d-%H:%M:%S`
|
||||
echo "System path is $PATH at $timestamp"
|
Loading…
Reference in New Issue
Block a user