Skip to content

Commit

Permalink
feat: Make it possible to deploy cache chart with edp-tekton (#74)
Browse files Browse the repository at this point in the history
Change-Id: Ia606da0fe7c2b077f0469e251e5b48f21a9185bb
  • Loading branch information
Mykola Serdiuk committed Dec 8, 2023
1 parent b396903 commit 413bff2
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 13 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ test-chart: ${CURRENT_DIR}/.venv/bin/activate
( \
source $^; \
pip3 install -r ${CURRENT_DIR}/requirements.txt; \
helm repo add epamedp https://epam.github.io/edp-helm-charts/stable; \
helm dependency update ./charts/pipelines-library; \
helm dependency update ./charts/custom-pipelines; \
pytest -sv ./charts/pipelines-library/ --color=yes -n auto; \
Expand Down
7 changes: 5 additions & 2 deletions charts/pipelines-library/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dependencies:
- name: edp-tekton-common-library
repository: file://../common-library
version: 0.2.17
digest: sha256:43563c33d4997c48258f18af9a989ebfbc27aef02037513470b2a63f8673dccc
generated: "2023-11-07T21:13:20.654937+02:00"
- name: tekton-cache
repository: https://epam.github.io/edp-helm-charts/stable
version: 0.1.0
digest: sha256:efcdbf85ca23e7738998110fd51546829cf8e24ffaae0e54d1545fc36de8315d
generated: "2023-12-08T14:23:14.668788+02:00"
4 changes: 4 additions & 0 deletions charts/pipelines-library/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ dependencies:
- name: edp-tekton-common-library
version: 0.2.17
repository: "file://../common-library"
- name: tekton-cache
version: 0.1.0
repository: "@epamedp"
condition: tekton-cache.enabled
3 changes: 3 additions & 0 deletions charts/pipelines-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Follows [Tekton Interceptor](https://tekton.dev/vault/triggers-main/clusterinter

| Repository | Name | Version |
|------------|------|---------|
| @epamedp | tekton-cache | 0.1.0 |
| file://../common-library | edp-tekton-common-library | 0.2.17 |

## Values
Expand Down Expand Up @@ -125,6 +126,8 @@ Follows [Tekton Interceptor](https://tekton.dev/vault/triggers-main/clusterinter
| kaniko.image.tag | string | `"v1.12.1"` | |
| kaniko.roleArn | string | `""` | AWS IAM role to be used for kaniko pod service account (IRSA). Format: arn:aws:iam::<AWS_ACCOUNT_ID>:role/<AWS_IAM_ROLE_NAME> |
| nameOverride | string | `""` | |
| tekton-cache.enabled | bool | `true` | |
| tekton-cache.url | string | `"http://edp-tekton-tekton-cache:8080"` | |
| tekton.pruner.create | bool | `true` | Specifies whether a cronjob should be created |
| tekton.pruner.image | string | `"bitnami/kubectl:1.25"` | Docker image to run the pruner, expected to have kubectl and jq |
| tekton.pruner.recentMinutes | string | `"30"` | Resources of PipelineRuns that finished in the last N minutes are not pruned |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ if index .Values "tekton-cache" "enabled" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: tekton-cache
data:
url: {{ index .Values "tekton-cache" "url" }}
{{ end }}
10 changes: 5 additions & 5 deletions charts/pipelines-library/templates/tasks/get-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ spec:
description: >-
This Task is used to get the cache from the distribution server. It stores cache in the root of the workspace.
params:
- name: CACHE_SERVER_URL
description: "Cache server URL"
default: http://tekton-cache:8080
type: string
- name: CACHE_NAME
description: "Cache name (filename) to be downloaded from the cache server."
type: string
Expand Down Expand Up @@ -48,7 +44,11 @@ spec:
curl ${CACHE_SERVER_URL}/${CACHE_NAME}.tar.gz|tar -xz -f-
env:
- name: CACHE_SERVER_URL
value: "$(params.CACHE_SERVER_URL)"
valueFrom:
configMapKeyRef:
name: tekton-cache
key: url
optional: true
- name: CACHE_NAME
value: "$(params.CACHE_NAME)"
# TODO: We need to run this task as root because the workspace is owned by root.
Expand Down
12 changes: 6 additions & 6 deletions charts/pipelines-library/templates/tasks/save-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ spec:
description: >-
This Task is used to save the cache to the distribution server. It packs and uploads the root of workspace to the distribution server
params:
- name: CACHE_SERVER_URL
description: "Cache server URL"
default: http://tekton-cache:8080
type: string
- name: CACHE_NAME
description: "Cache name (filename) to be downloaded from the cache server."
type: string
- name: BASE_IMAGE
description: "Base image"
default: "sergk/python-slim:linux-1"
default: "epamedp/tekton-autotest:0.1.2"
type: string

workspaces:
Expand Down Expand Up @@ -55,7 +51,11 @@ spec:
tar czf - . |curl -# -L -f -F path=${CACHE_NAME}.tar.gz -X POST -F "file=@-" ${CACHE_SERVER_URL}/upload
env:
- name: CACHE_SERVER_URL
value: "$(params.CACHE_SERVER_URL)"
valueFrom:
configMapKeyRef:
name: tekton-cache
key: url
optional: true
- name: CACHE_NAME
value: "$(params.CACHE_NAME)"

Expand Down
4 changes: 4 additions & 0 deletions charts/pipelines-library/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ global:
# -- Docker Registry endpoint. In dockerhub case the URL must be specified in accordance with the Kaniko name convention (docker.io/<registry_space>)
url: "<AWS_ACCOUNT_ID>.dkr.ecr.<AWS_REGION>.amazonaws.com/<registry_space>"

tekton-cache:
enabled: true
url: http://edp-tekton-tekton-cache:8080

webhook:
# -- If true, webhook ssl verification will be skipped. Default: false
skipWebhookSSLVerification: false
Expand Down
2 changes: 2 additions & 0 deletions kuttl-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ commands:
namespaced: false
- command: kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
namespaced: false
- command: helm repo add epamedp https://epam.github.io/edp-helm-charts/stable
namespaced: true
- command: helm dependency update ./charts/pipelines-library
namespaced: true

0 comments on commit 413bff2

Please sign in to comment.