Skip to content

Commit

Permalink
feat: add updates for argo-events
Browse files Browse the repository at this point in the history
  • Loading branch information
kseniyashaydurova committed Jul 17, 2023
1 parent a656b4f commit 16a9d0c
Show file tree
Hide file tree
Showing 17 changed files with 240 additions and 14 deletions.
4 changes: 2 additions & 2 deletions charts/tekton-apps/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ type: application
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.28.2"
appVersion: "v0.29.0"

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.9
version: 0.2.10-dev-ksenia.1

maintainers:
- url: https://www.saritasa.com/
Expand Down
4 changes: 3 additions & 1 deletion charts/tekton-apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ saritasa-tekton-apps

## `chart.version`

![Version: 0.2.9](https://img.shields.io/badge/Version-0.2.9-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.28.2](https://img.shields.io/badge/AppVersion-v0.28.2-informational?style=flat-square)
![Version: 0.2.10-dev-ksenia.1](https://img.shields.io/badge/Version-0.2.10--dev--ksenia.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.29.0](https://img.shields.io/badge/AppVersion-v0.29.0-informational?style=flat-square)

## Maintainers

Expand Down Expand Up @@ -1316,3 +1316,5 @@ whitelistIP: |
| storageClassName | string | `"gp2"` | storage class for PVCs associated with the apps |
| whitelistIP | string | `""` | Comma-separated list of IP masks to bypass access limitation (if applicable, ex. for legacy projects protected with basic authentication) |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
2 changes: 1 addition & 1 deletion charts/tekton-apps/templates/general/triggerbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ metadata:
spec:
params:
- name: application
value: {{ include "tekton-apps.resourceName" $data }}
value: {{ or $argocd.appName (include "tekton-apps.resourceName" $data) }}
- name: project
value: {{ $project.project }}
- name: component
Expand Down
5 changes: 4 additions & 1 deletion charts/tekton-apps/templates/wordpress/triggerbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"component" $component
"environment" $projectEnvironment }}

# initialize `argocd` variable with either `$component.argocd` dict if it exists or with empty dict
{{ $argocd := ternary $component.argocd dict (hasKey $component "argocd") -}}

# ========================================================================
# 🌱 {{ $project.project | upper }}/{{ $component.name | upper }} COMPONENT TRIGGER BINDING
# ========================================================================
Expand All @@ -22,7 +25,7 @@ metadata:
spec:
params:
- name: application
value: {{ include "tekton-apps.resourceName" $data }}
value: {{ or $argocd.appName (include "tekton-apps.resourceName" $data) }}
- name: project
value: {{ $project.project }}
- name: component
Expand Down
2 changes: 1 addition & 1 deletion charts/tekton-pipelines/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.36
version: 0.1.37-dev-ksenia.1


maintainers:
Expand Down
22 changes: 21 additions & 1 deletion charts/tekton-pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ saritasa-tekton-pipelines

## `chart.version`

![Version: 0.1.36](https://img.shields.io/badge/Version-0.1.36-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 0.1.37-dev-ksenia.1](https://img.shields.io/badge/Version-0.1.37--dev--ksenia.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

## Maintainers

Expand Down Expand Up @@ -165,6 +165,12 @@ After configuring these values, you will have an extra `sentry-release` step aft
| buildpacks.generate.buildpackDjangoBuildPipeline.buildTaskSteps | list | see values.yaml for the default values of it | steps to run in the `buildpack-django` task prior to executing /cnb/lifecycle/creator CLI |
| buildpacks.generate.buildpackDjangoBuildPipeline.enabled | bool | `false` | should we enable the django buildpack pipeline |
| buildpacks.generate.buildpackDjangoBuildPipeline.name | string | `"buildpack-django-build-pipeline"` | the name of the generated pipeline |
| buildpacks.generate.buildpackDjangoBuildPipeline.postDeployTaskSteps[0].image | string | `"badouralix/curl-jq"` | |
| buildpacks.generate.buildpackDjangoBuildPipeline.postDeployTaskSteps[0].imagePullPolicy | string | `"IfNotPresent"` | |
| buildpacks.generate.buildpackDjangoBuildPipeline.postDeployTaskSteps[0].name | string | `"argo-events"` | |
| buildpacks.generate.buildpackDjangoBuildPipeline.postDeployTaskSteps[0].resources | object | `{}` | |
| buildpacks.generate.buildpackDjangoBuildPipeline.postDeployTaskSteps[0].script | string | `"#!/usr/bin/env bash\n\n# add extra params from env and convert them to lowercase to work with this\n# data later in argo workflow\nEXTRA=$(jq -n env | jq 'walk(if type==\"object\" then with_entries(.key|=ascii_downcase) else . end)')\nJSON_PAYLOAD='{\n \"project\": \"$(params.project)\",\n \"environment\": \"$(params.environment)\",\n \"application\": \"$(params.application)\",\n \"sha\": \"$(params.sha)\",\n \"extra\": ${EXTRA}\n}'\n\necho \"Payload: $JSON_PAYLOAD\"\n\nOUTPUT=$(curl -s -o /dev/null -w httpcode=%{http_code} --location --request POST \"build-succeed-eventsource-svc.argo-events.svc.cluster.local\" \\\n --header 'Content-Type: application/json' \\\n --data-raw \"$JSON_PAYLOAD\")\n\nSTATUS_CODE=$(echo \"${OUTPUT}\" | sed -e 's/.*\\httpcode=//')\nif [ ${STATUS_CODE} -ne 204 ]; then\n echo \"Curl operation/command failed due to server return code - ${STATUS_CODE}\"\n exit 1\nfi\n\necho \"Sent 'build-succeed' webhook\"\n"` | |
| buildpacks.generate.buildpackDjangoBuildPipeline.postDeployTaskSteps[0].securityContext.privileged | bool | `true` | |
| buildpacks.generate.buildpackDotnetBuildPipeline.buildTaskName | string | `"buildpack-dotnet"` | the generated name of the tekton task implementing the "build" step |
| buildpacks.generate.buildpackDotnetBuildPipeline.buildTaskSteps | list | see values.yaml for the default values of it | steps to run in the `buildpack-dotnet` task prior to executing /cnb/lifecycle/creator CLI |
| buildpacks.generate.buildpackDotnetBuildPipeline.enabled | bool | `false` | should we enable the dotnet buildpack pipeline |
Expand All @@ -173,6 +179,12 @@ After configuring these values, you will have an extra `sentry-release` step aft
| buildpacks.generate.buildpackFrontendBuildPipeline.buildTaskSteps | list | see values.yaml for the default values of it | steps to run in the `buildpack-frontend` task prior to executing /cnb/lifecycle/creator CLI |
| buildpacks.generate.buildpackFrontendBuildPipeline.enabled | bool | `false` | should we enable the frontend buildpack pipeline |
| buildpacks.generate.buildpackFrontendBuildPipeline.name | string | `"buildpack-frontend-build-pipeline"` | the name of the generated pipeline |
| buildpacks.generate.buildpackFrontendBuildPipeline.postDeployTaskSteps[0].image | string | `"badouralix/curl-jq"` | |
| buildpacks.generate.buildpackFrontendBuildPipeline.postDeployTaskSteps[0].imagePullPolicy | string | `"IfNotPresent"` | |
| buildpacks.generate.buildpackFrontendBuildPipeline.postDeployTaskSteps[0].name | string | `"argo-events"` | |
| buildpacks.generate.buildpackFrontendBuildPipeline.postDeployTaskSteps[0].resources | object | `{}` | |
| buildpacks.generate.buildpackFrontendBuildPipeline.postDeployTaskSteps[0].script | string | `"#!/usr/bin/env bash\n\n# add extra params from env and convert them to lowercase to work with this\n# data later in argo workflow\nEXTRA=$(jq -n env | jq 'walk(if type==\"object\" then with_entries(.key|=ascii_downcase) else . end)')\nJSON_PAYLOAD='{\n \"project\": \"$(params.project)\",\n \"environment\": \"$(params.environment)\",\n \"application\": \"$(params.application)\",\n \"sha\": \"$(params.sha)\",\n \"extra\": ${EXTRA}\n}'\n\necho \"Payload: $JSON_PAYLOAD\"\n\nOUTPUT=$(curl -s -o /dev/null -w httpcode=%{http_code} --location --request POST \"build-succeed-eventsource-svc.argo-events.svc.cluster.local\" \\\n --header 'Content-Type: application/json' \\\n --data-raw \"$JSON_PAYLOAD\")\n\nSTATUS_CODE=$(echo \"${OUTPUT}\" | sed -e 's/.*\\httpcode=//')\nif [ ${STATUS_CODE} -ne 204 ]; then\n echo \"Curl operation/command failed due to server return code - ${STATUS_CODE}\"\n exit 1\nfi\n\necho \"Sent 'build-succeed' webhook\"\n"` | |
| buildpacks.generate.buildpackFrontendBuildPipeline.postDeployTaskSteps[0].securityContext.privileged | bool | `true` | |
| buildpacks.generate.buildpackGoBuildPipeline.buildTaskName | string | `"buildpack-go"` | the generated name of the tekton task implementing the "build" step |
| buildpacks.generate.buildpackGoBuildPipeline.enabled | bool | `false` | should we enable the GO buildpack pipeline |
| buildpacks.generate.buildpackGoBuildPipeline.name | string | `"buildpack-go-build-pipeline"` | the name of the generated pipeline |
Expand Down Expand Up @@ -205,6 +217,12 @@ After configuring these values, you will have an extra `sentry-release` step aft
| images.slack | string | `"cloudposse/slack-notifier:0.4.0"` | slack notifier |
| images.yamlfix | string | `"public.ecr.aws/saritasa/yamlfix:1.8.1"` | yamlfix image - format yaml files |
| kaniko.enabled | bool | `false` | should we enable the kaniko pipeline |
| kaniko.postDeployTaskSteps[0].image | string | `"badouralix/curl-jq"` | |
| kaniko.postDeployTaskSteps[0].imagePullPolicy | string | `"IfNotPresent"` | |
| kaniko.postDeployTaskSteps[0].name | string | `"argo-events"` | |
| kaniko.postDeployTaskSteps[0].resources | object | `{}` | |
| kaniko.postDeployTaskSteps[0].script | string | `"#!/usr/bin/env bash\n\n# add extra params from env and convert them to lowercase to work with this\n# data later in argo workflow\nEXTRA=$(jq -n env | jq 'walk(if type==\"object\" then with_entries(.key|=ascii_downcase) else . end)')\nJSON_PAYLOAD='{\n \"project\": \"$(params.project)\",\n \"environment\": \"$(params.environment)\",\n \"application\": \"$(params.application)\",\n \"sha\": \"$(params.sha)\",\n \"extra\": ${EXTRA}\n}'\n\necho \"Payload: $JSON_PAYLOAD\"\n\nOUTPUT=$(curl -s -o /dev/null -w httpcode=%{http_code} --location --request POST \"build-succeed-eventsource-svc.argo-events.svc.cluster.local\" \\\n --header 'Content-Type: application/json' \\\n --data-raw \"$JSON_PAYLOAD\")\n\nSTATUS_CODE=$(echo \"${OUTPUT}\" | sed -e 's/.*\\httpcode=//')\nif [ ${STATUS_CODE} -ne 204 ]; then\n echo \"Curl operation/command failed due to server return code - ${STATUS_CODE}\"\n exit 1\nfi\n\necho \"Sent 'build-succeed' webhook\"\n"` | |
| kaniko.postDeployTaskSteps[0].securityContext.privileged | bool | `true` | |
| podTemplate | object | see values.yaml | default configuration to be added into each pod created by tekton engine we want to plave them in a specific node with added tolerations/taints. |
| podTemplate.nodeSelector | object | `{"ci":"true"}` | node selector for pods spawned by tekton |
| podTemplate.tolerations | list | `[{"effect":"NoSchedule","key":"ci","operator":"Equal","value":"true"}]` | tolerations |
Expand All @@ -216,3 +234,5 @@ After configuring these values, you will have an extra `sentry-release` step aft
| sentry.url | string | `"https://sentry.saritasa.rocks/"` | |
| wordpress.enabled | bool | `false` | should we enable the wordpress pipeline |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
23 changes: 21 additions & 2 deletions charts/tekton-pipelines/templates/_snippets.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
# │ slack notification reusable snippet in various pipelines │
# │ │
# └──────────────────────────────────────────────────────────────────────────────┘
{{- define "task.finalNotification" -}}
{{- define "pipeline.finalNotification" -}}
finally:
- name: slack-notification
taskRef:
Expand Down Expand Up @@ -261,7 +261,7 @@ finally:
# │ Sentry release reusable snippet in various pipelines │
# │ │
# └──────────────────────────────────────────────────────────────────────────────┘
{{- define "task.sentryRelease" -}}
{{- define "pipeline.sentryRelease" -}}
- name: sentry-release
taskRef:
name: sentry-release
Expand All @@ -282,3 +282,22 @@ finally:
runAfter:
- deploy
{{- end }}

# ┌──────────────────────────────────────────────────────────────────────────────┐
# │ post deploy reusable snippet in various pipelines │
# │ │
# └──────────────────────────────────────────────────────────────────────────────┘
{{- define "pipeline.postDeploy" -}}
- name: post-deploy
taskRef:
name: post-deploy
params:
- name: application
value: "$(params.application)"
- name: project
value: "$(params.project)"
- name: sha
value: "$(params.sha)"
- name: environment
value: "$(params.environment)"
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ spec:
{{ include "pipeline.defaultParams" . | nindent 4 }}
{{ include "pipeline.defaultDockerKubernetesParams" . | nindent 4 }}

- name: project
type: string
description: name of the project, which component is deployed

- name: repository_submodules
type: string
description: defines whether repository should be initialized with submodules or not (if false value is set, it means no repository submodules would be downloaded)
Expand Down Expand Up @@ -173,9 +177,13 @@ spec:
- kustomize

{{ if .sentry.enabled }}
{{ include "task.sentryRelease" . | nindent 4 }}
{{ include "pipeline.sentryRelease" . | nindent 4 }}
{{ end }}

{{ include "task.finalNotification" . | nindent 2 }}
{{ include "pipeline.finalNotification" . | nindent 2 }}

{{ if (.pipeline.postDeployTaskSteps) }}
{{ include "pipeline.postDeploy" . | nindent 4 }}
{{ end }}
---
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- range $pipeline := $.Values.buildpacks.generate }}
{{ $data := dict "steps" $pipeline.postDeployTaskSteps
"namespace" $.Release.Namespace
"namePrefix" $pipeline.name }}
{{ if and (and $.Values.buildpacks.enabled $pipeline.enabled) $pipeline.postDeployTaskSteps }}
{{ include "task.postDeploy" $data }}
{{ end }}
{{- end}}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ spec:
name: {{ .pipeline.name }}
params:
{{- include "pipeline.defaultTTBoundParams" (dict "docker" true "kubernetes" true) | nindent 8 }}
- name: project
value: "$(tt.params.project)"
- name: buildpack_builder_image
value: "$(tt.params.buildpack_builder_image)"
- name: buildpack_runner_image
Expand Down
42 changes: 42 additions & 0 deletions charts/tekton-pipelines/templates/common/tasks/_post-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- define "task.postDeploy" -}}
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: {{ .namePrefix }}-post-deploy
namespace: {{ .namespace }}

spec:
description: >-
Task performs custom post deploy actions, which are set from values.yaml
(for ex. run selenium tests or etc)
params:

- name: application
type: string
description: name of the argocd application we're going to deploy/sync

- name: project
type: string
description: name of the project, which component is deployed

- name: sha
type: string
description: sha commit ID of the image deployed in cluster

- name: environment
type: string
description: environment name of the app being built, i.e. dev/staging/prod

stepTemplate:
envFrom:
- configMapRef:
name: $(params.application)-build-pipeline-config # project specific values

# insert customized steps as defined in the values.yaml of the helm chart
{{ if .steps }}
steps:
{{ .steps | toYaml | nindent 4}}
{{ end }}
---
{{- end }}
12 changes: 10 additions & 2 deletions charts/tekton-pipelines/templates/kaniko/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ spec:
{{ include "pipeline.defaultParams" . | nindent 4 }}
{{ include "pipeline.defaultDockerKubernetesParams" . | nindent 4 }}

- name: project
type: string
description: name of the project, which component is deployed

- name: docker_file
type: string
default: Dockerfile
Expand Down Expand Up @@ -108,9 +112,13 @@ spec:
- kustomize

{{ if .Values.sentry.enabled }}
{{ include "task.sentryRelease" . | nindent 4 }}
{{ include "pipeline.sentryRelease" . | nindent 4 }}
{{ end }}

{{ include "task.finalNotification" . | nindent 2 }}
{{ include "pipeline.finalNotification" . | nindent 2 }}

{{ if .Values.kaniko.postDeployTaskSteps }}
{{ include "pipeline.postDeploy" . | nindent 4 }}
{{ end }}

{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ if and .Values.kaniko.enabled .Values.kaniko.postDeployTaskSteps }}
{{ $data := dict "steps" .Values.kaniko.postDeployTaskSteps
"namespace" $.Release.Namespace
"namePrefix" "kaniko" }}
{{ include "task.postDeploy" $data }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ spec:
name: kaniko-build-pipeline
params:
{{- include "pipeline.defaultTTBoundParams" (dict "docker" true "kubernetes" true) | nindent 8 }}
- name: project
value: "$(tt.params.project)"
- name: docker_file
value: "$(tt.params.docker_file)"
- name: docker_context
Expand Down
2 changes: 1 addition & 1 deletion charts/tekton-pipelines/templates/wordpress/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ spec:
- name: kubernetes_namespace
value: "$(params.kubernetes_namespace)"

{{ include "task.finalNotification" . | nindent 2 }}
{{ include "pipeline.finalNotification" . | nindent 2 }}

{{ end }}
Loading

0 comments on commit 16a9d0c

Please sign in to comment.