eindelijk weer eens een push

This commit is contained in:
allard committed 2026-05-31 16:07:30 +02:00
1 parent 01cff8e165
commit ff21c258e0
2747 files changed
+302316 -131101

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
Voor shared data kun je het beste een pvc gebruiken die niet aan een specifieke node
gebonden is want dan moeten alle tasks op dezelfde node worden uitgevoerd.
@@ -0,0 +1,186 @@
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: openliberty-pipeline
spec:
description: |
This pipeline clones a git repo, builds a Docker image with Kaniko and
pushes it to a registry
params:
- name: repo-url
type: string
- name: git-revision
type: string
- name: maven-mirror-url
type: string
- name: sonar-organization
type: string
- name: sonar-project-key
type: string
- name: sonar-token
type: string
- name: sonar-host-url
type: string
- name: source-to-scan
type: string
- name: registry
type: string
- name: project
type: string
- name: image-name
type: string
- name: cosign-image-url
type: string
- name: deptrack-projectName
type: string
- name: deptrack-projectVersion
type: string
- name: deptrack-apiKey
type: string
- name: deptrack-url
type: string
workspaces:
- name: shared-data
- name: registry-credentials
- name: maven-settings
- name: sonar-settings
tasks:
- name: fetch-source
taskRef:
name: git-clone
workspaces:
- name: output
workspace: shared-data
params:
- name: url
value: $(params.repo-url)
- name: compile-java
runAfter: ["fetch-source"]
taskRef:
name: maven
workspaces:
- name: source
workspace: shared-data
- name: maven-settings
workspace: shared-data
params:
- name: MAVEN_IMAGE
value: maven
- name: CONTEXT_DIR
value: "."
- name: MAVEN_MIRROR_URL
value: $(params.maven-mirror-url)
- name: GOALS
value:
- clean
- package
- name: sonarqube
runAfter: ["compile-java"]
taskRef:
kind: Task
name: sonarqube-scanner
workspaces:
- name: source
workspace: shared-data
- name: sonar-settings
workspace: sonar-settings
params:
- name: SONAR_ORGANIZATION
value: $(params.sonar-organization)
- name: SONAR_PROJECT_KEY
value: $(params.sonar-project-key)
- name: SONAR_TOKEN
value: $(params.sonar-token)
- name: SOURCE_TO_SCAN
value: $(params.source-to-scan)
- name: SONAR_HOST_URL
value: $(params.sonar-host-url)
- name: SONAR_SCANNER_IMAGE
value: noenv/sonar-scanner:7.0.2
- name: build-push
runAfter: ["compile-java"]
taskRef:
name: kaniko
workspaces:
- name: source
workspace: shared-data
- name: dockerconfig
workspace: registry-credentials
params:
- name: IMAGE
value: $(params.registry)/$(params.project)/$(params.image-name):$(params.git-revision)
- name: cosign-sign
runAfter: ["build-push"]
taskRef:
name: cosign-sign
params:
- name: cosign-image-url
value: $(params.registry)/$(params.project)/$(params.image-name):$(params.git-revision)
- name: cosign-image-digest
value: $(tasks.build-push.results.IMAGE_DIGEST)
- name: syft
runAfter: ["build-push"]
taskRef:
name: syft
params:
- name: ARGS
value:
- $(params.registry)/$(params.project)/$(params.image-name):$(params.git-revision)
- --output
- cyclonedx-json=./$(params.sonar-project-key).sbom.json
workspaces:
- name: source-dir
workspace: shared-data
- name: push-sbom
runAfter: ["syft"]
taskRef:
name: push-sbom
params:
- name: deptrack-url
value: $(params.deptrack-url)
- name: deptrack-apiKey
value: $(params.deptrack-apiKey)
- name: deptrack-projectName
value: $(params.deptrack-projectName)
- name: deptrack-projectVersion
value: $(params.deptrack-projectVersion)
- name: sbom
value: $(params.deptrack-projectName).sbom.json
workspaces:
- name: source-dir
workspace: shared-data
- name: register-change
runAfter: ["build-push"]
taskRef:
name: register-change
params:
- name: project
value: $(params.sonar-project-key)
- name: git-revision
value: $(params.git-revision)
workspaces:
- name: source-dir
workspace: shared-data
- name: deploy-with-argocd
runAfter: ["build-push"]
taskRef:
name: argocd-task-sync-and-wait
params:
- name: application-name
value: $(params.sonar-project-key)
+72
View File
@@ -0,0 +1,72 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: openliberty-pipeline-run-
spec:
pipelineRef:
name: openliberty-pipeline
#gitea:
params:
- name: repo-url
value: http://gitea.gitea.svc.cluster.local:3000/allard/olproperties.git
- name: git-revision
value: 1.3
#maven:
- name: maven-mirror-url
value: 'http://nexus.nexus.svc.cluster.local:8081/repository/maven-public/'
#sonarqube:
- name: sonar-organization
value: "allarddcs"
- name: sonar-project-key
value: olproperties
- name: sonar-token
value: sqp_214ee7c92e1b82b0d43dd9b1d9462eac8f50434c
- name: sonar-host-url
value: "https://registry-dev.allarddcs.nl"
- name: source-to-scan
value: ./src
#push-to-harbor:
- name: registry
value: harbor-dev.allarddcs.nl
- name: project
value: allard
- name: image-name
value: olproperties
#cosign
- name: cosign-image-url
value: harbor-dev.allarddcs.nl/allard/olproperties
#dependency-track
- name: deptrack-apiKey
value: odt_BRpq4el8T0XqdeunYMnefniaS0n8Yxd8
- name: deptrack-projectName
value: olproperties
- name: deptrack-projectVersion
value: 1.1
- name: deptrack-url
value: https://deptracka-dev.allarddcs.nl
workspaces:
- name: shared-data
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: maven-settings
persistentVolumeClaim:
emptyDir: {}
- name: sonar-settings
configMap:
name: sonar-properties
- name: registry-credentials
secret:
secretName: registry-credentials
items:
- key: .dockerconfigjson
path: config.json
@@ -23,8 +23,10 @@ spec:
value: olproperties
- name: sonar-token
value: sqp_214ee7c92e1b82b0d43dd9b1d9462eac8f50434c
# - name: sonar-host-url
# value: "https://sonarqube-dev.allarddcs.nl"
- name: sonar-host-url
value: "https://sonarqube-dev.allarddcs.nl"
value: "http://sonarqube.sonarqube.svc.cluster.local:9000"
- name: source-to-scan
value: ./src
@@ -51,15 +53,9 @@ spec:
value: https://deptracka-dev.allarddcs.nl
workspaces:
- name: shared-data
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: maven-settings
persistentVolumeClaim:
claimName: openliberty-shared-data
- name: maven-settings
emptyDir: {}
- name: sonar-settings
configMap:
@@ -109,7 +109,7 @@ spec:
value: noenv/sonar-scanner:7.0.2
- name: build-push
runAfter: ["compile-java"]
runAfter: ["sonarqube"]
taskRef:
name: buildah
workspaces:
@@ -132,7 +132,7 @@ spec:
value: $(tasks.build-push.results.IMAGE_DIGEST)
- name: syft
runAfter: ["build-push"]
runAfter: ["cosign-sign"]
taskRef:
name: syft
params:
@@ -147,7 +147,7 @@ spec:
- name: push-sbom
runAfter: ["syft"]
taskref:
taskRef:
name: push-sbom
params:
- name: deptrack-url
@@ -165,8 +165,8 @@ spec:
workspace: shared-data
- name: register-change
runAfter: ["build-push"]
taskref:
runAfter: ["push-sbom"]
taskRef:
name: register-change
params:
- name: project
@@ -178,9 +178,16 @@ spec:
workspace: shared-data
- name: deploy-with-argocd
runAfter: ["build-push"]
taskref:
runAfter: ["register-change"]
taskRef:
name: argocd-task-sync-and-wait
params:
- name: application-name
value: $(params.sonar-project-key)
finally:
- name: cleanup-workspace
taskRef:
name: cleanup-workspace
workspaces:
- name: source
workspace: shared-data
@@ -0,0 +1,33 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: openliberty-shared-data-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
mountOptions:
- hard
- nfsvers=4.1
nfs:
server: 192.168.2.111
path: /mnt/nfs_share/dev/tekton
readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: openliberty-shared-data
namespace: default
spec:
storageClassName: ""
accessModes:
- ReadWriteMany
volumeMode: Filesystem
resources:
requests:
storage: 5Gi
volumeName: openliberty-shared-data-pv
+131
View File
@@ -0,0 +1,131 @@
kubectl get task buildah -o yaml
apiVersion: tekton.dev/v1
kind: Task
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"tekton.dev/v1","kind":"Task","metadata":{"annotations":{"tekton.dev/categories":"Image Build","tekton.dev/displayName":"buildah","tekton.dev/pipelines.minVersion":"0.50.0","tekton.dev/platforms":"linux/amd64,linux/s390x,linux/ppc64le,linux/arm64","tekton.dev/tags":"image-build"},"labels":{"app.kubernetes.io/version":"0.9"},"name":"buildah","namespace":"default"},"spec":{"description":"Buildah task builds source into a container image and then pushes it to a container registry.\nBuildah Task builds source into a container image using Project Atomic's Buildah build tool.It uses Buildah's support for building from Dockerfiles, using its buildah bud command.This command executes the directives in the Dockerfile to assemble a container image, then pushes that image to a container registry.","params":[{"description":"Reference of the image buildah will produce.","name":"IMAGE"},{"default":"quay.io/buildah/stable:v1","description":"The location of the buildah builder image.","name":"BUILDER_IMAGE"},{"default":"overlay","description":"Set buildah storage driver","name":"STORAGE_DRIVER"},{"default":"./Dockerfile","description":"Path to the Dockerfile to build.","name":"DOCKERFILE"},{"default":".","description":"Path to the directory to use as context.","name":"CONTEXT"},{"default":"true","description":"Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)","name":"TLSVERIFY"},{"default":"oci","description":"The format of the built container, oci or docker","name":"FORMAT"},{"default":"","description":"Extra parameters passed for the build command when building images. WARNING - must be sanitized to avoid command injection","name":"BUILD_EXTRA_ARGS"},{"default":"","description":"Extra parameters passed for the push command when pushing images. WARNING - must be sanitized to avoid command injection","name":"PUSH_EXTRA_ARGS","type":"string"},{"default":"false","description":"Skip pushing the built image","name":"SKIP_PUSH"},{"default":[""],"description":"Dockerfile build arguments, array of key=value","name":"BUILD_ARGS","type":"array"}],"results":[{"description":"Digest of the image just built.","name":"IMAGE_DIGEST"},{"description":"Image repository where the built image would be pushed to","name":"IMAGE_URL"}],"steps":[{"args":["$(params.BUILD_ARGS[*])"],"env":[{"name":"PARAM_IMAGE","value":"$(params.IMAGE)"},{"name":"PARAM_STORAGE_DRIVER","value":"$(params.STORAGE_DRIVER)"},{"name":"PARAM_DOCKERFILE","value":"$(params.DOCKERFILE)"},{"name":"PARAM_CONTEXT","value":"$(params.CONTEXT)"},{"name":"PARAM_TLSVERIFY","value":"$(params.TLSVERIFY)"},{"name":"PARAM_FORMAT","value":"$(params.FORMAT)"},{"name":"PARAM_BUILD_EXTRA_ARGS","value":"$(params.BUILD_EXTRA_ARGS)"},{"name":"PARAM_PUSH_EXTRA_ARGS","value":"$(params.PUSH_EXTRA_ARGS)"},{"name":"PARAM_SKIP_PUSH","value":"$(params.SKIP_PUSH)"}],"image":"$(params.BUILDER_IMAGE)","name":"build-and-push","script":"BUILD_ARGS=()\nfor buildarg in \"$@\"\ndo\n BUILD_ARGS+=(\"--build-arg=$buildarg\")\ndone\n[ \"$(workspaces.sslcertdir.bound)\" = \"true\" ] \u0026\u0026 CERT_DIR_FLAG=\"--cert-dir=$(workspaces.sslcertdir.path)\"\n[ \"$(workspaces.dockerconfig.bound)\" = \"true\" ] \u0026\u0026 DOCKER_CONFIG=\"$(workspaces.dockerconfig.path)\" \u0026\u0026 export DOCKER_CONFIG\n# build the image (CERT_DIR_FLAG should be omitted if empty and BUILD_EXTRA_ARGS can contain multiple args)\n# shellcheck disable=SC2046,SC2086\nbuildah ${CERT_DIR_FLAG} \"--storage-driver=${PARAM_STORAGE_DRIVER}\" bud \"${BUILD_ARGS[@]}\" ${PARAM_BUILD_EXTRA_ARGS} \\\n \"--format=${PARAM_FORMAT}\" \"--tls-verify=${PARAM_TLSVERIFY}\" \\\n -f \"${PARAM_DOCKERFILE}\" -t \"${PARAM_IMAGE}\" \"${PARAM_CONTEXT}\"\n[ \"${PARAM_SKIP_PUSH}\" = \"true\" ] \u0026\u0026 echo \"Push skipped\" \u0026\u0026 exit 0\n# push the image (CERT_DIR_FLAG should be omitted if empty and PUSH_EXTRA_ARGS can contain multiple args)\n# shellcheck disable=SC2046,SC2086\nbuildah ${CERT_DIR_FLAG} \"--storage-driver=${PARAM_STORAGE_DRIVER}\" push \\\n \"--tls-verify=${PARAM_TLSVERIFY}\" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \\\n \"${PARAM_IMAGE}\" \"docker://${PARAM_IMAGE}\"\ntee \"$(results.IMAGE_DIGEST.path)\" \u003c /tmp/image-digest\nprintf '%s' \"${PARAM_IMAGE}\" | tee \"$(results.IMAGE_URL.path)\"\n","securityContext":{"privileged":true},"volumeMounts":[{"mountPath":"/var/lib/containers","name":"varlibcontainers"}],"workingDir":"$(workspaces.source.path)"}],"volumes":[{"emptyDir":{},"name":"varlibcontainers"}],"workspaces":[{"name":"source"},{"name":"sslcertdir","optional":true},{"description":"An optional workspace that allows providing a .docker/config.json file for Buildah to access the container registry. The file should be placed at the root of the Workspace with name config.json.","name":"dockerconfig","optional":true}]}}
tekton.dev/categories: Image Build
tekton.dev/displayName: buildah
tekton.dev/pipelines.minVersion: 0.50.0
tekton.dev/platforms: linux/amd64,linux/s390x,linux/ppc64le,linux/arm64
tekton.dev/tags: image-build
creationTimestamp: "2026-02-04T18:24:54Z"
generation: 1
labels:
app.kubernetes.io/version: "0.9"
name: buildah
namespace: default
resourceVersion: "482777"
uid: 534ddba1-e2d7-42b9-b2f9-01d5953e7ade
spec:
description: |-
Buildah task builds source into a container image and then pushes it to a container registry.
Buildah Task builds source into a container image using Project Atomic's Buildah build tool.It uses Buildah's support for building from Dockerfiles, using its buildah bud command.This command executes the directives in the Dockerfile to assemble a container image, then pushes that image to a container registry.
params:
- description: Reference of the image buildah will produce.
name: IMAGE
- default: quay.io/buildah/stable:v1
description: The location of the buildah builder image.
name: BUILDER_IMAGE
- default: overlay
description: Set buildah storage driver
name: STORAGE_DRIVER
- default: ./Dockerfile
description: Path to the Dockerfile to build.
name: DOCKERFILE
- default: .
description: Path to the directory to use as context.
name: CONTEXT
- default: "true"
description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS
registry)
name: TLSVERIFY
- default: oci
description: The format of the built container, oci or docker
name: FORMAT
- default: ""
description: Extra parameters passed for the build command when building images.
WARNING - must be sanitized to avoid command injection
name: BUILD_EXTRA_ARGS
- default: ""
description: Extra parameters passed for the push command when pushing images.
WARNING - must be sanitized to avoid command injection
name: PUSH_EXTRA_ARGS
type: string
- default: "false"
description: Skip pushing the built image
name: SKIP_PUSH
- default:
- ""
description: Dockerfile build arguments, array of key=value
name: BUILD_ARGS
type: array
results:
- description: Digest of the image just built.
name: IMAGE_DIGEST
- description: Image repository where the built image would be pushed to
name: IMAGE_URL
steps:
- args:
- $(params.BUILD_ARGS[*])
env:
- name: PARAM_IMAGE
value: $(params.IMAGE)
- name: PARAM_STORAGE_DRIVER
value: $(params.STORAGE_DRIVER)
- name: PARAM_DOCKERFILE
value: $(params.DOCKERFILE)
- name: PARAM_CONTEXT
value: $(params.CONTEXT)
- name: PARAM_TLSVERIFY
value: $(params.TLSVERIFY)
- name: PARAM_FORMAT
value: $(params.FORMAT)
- name: PARAM_BUILD_EXTRA_ARGS
value: $(params.BUILD_EXTRA_ARGS)
- name: PARAM_PUSH_EXTRA_ARGS
value: $(params.PUSH_EXTRA_ARGS)
- name: PARAM_SKIP_PUSH
value: $(params.SKIP_PUSH)
image: $(params.BUILDER_IMAGE)
name: build-and-push
script: |
BUILD_ARGS=()
for buildarg in "$@"
do
BUILD_ARGS+=("--build-arg=$buildarg")
done
[ "$(workspaces.sslcertdir.bound)" = "true" ] && CERT_DIR_FLAG="--cert-dir=$(workspaces.sslcertdir.path)"
[ "$(workspaces.dockerconfig.bound)" = "true" ] && DOCKER_CONFIG="$(workspaces.dockerconfig.path)" && export DOCKER_CONFIG
# build the image (CERT_DIR_FLAG should be omitted if empty and BUILD_EXTRA_ARGS can contain multiple args)
# shellcheck disable=SC2046,SC2086
buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" bud "${BUILD_ARGS[@]}" ${PARAM_BUILD_EXTRA_ARGS} \
"--format=${PARAM_FORMAT}" "--tls-verify=${PARAM_TLSVERIFY}" \
-f "${PARAM_DOCKERFILE}" -t "${PARAM_IMAGE}" "${PARAM_CONTEXT}"
[ "${PARAM_SKIP_PUSH}" = "true" ] && echo "Push skipped" && exit 0
# push the image (CERT_DIR_FLAG should be omitted if empty and PUSH_EXTRA_ARGS can contain multiple args)
# shellcheck disable=SC2046,SC2086
buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
"--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
"${PARAM_IMAGE}" "docker://${PARAM_IMAGE}"
tee "$(results.IMAGE_DIGEST.path)" < /tmp/image-digest
printf '%s' "${PARAM_IMAGE}" | tee "$(results.IMAGE_URL.path)"
securityContext:
privileged: true
volumeMounts:
- mountPath: /var/lib/containers
name: varlibcontainers
workingDir: $(workspaces.source.path)
volumes:
- emptyDir: {}
name: varlibcontainers
workspaces:
- name: source
- name: sslcertdir
optional: true
- description: An optional workspace that allows providing a .docker/config.json
file for Buildah to access the container registry. The file should be placed
at the root of the Workspace with name config.json.
name: dockerconfig
optional: true