Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add latest tag #100

Merged
merged 14 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# Changelog

## 2023-10-27
## 2023-12-26

[prod]

- [associated PR](https://github.com/saritasa-nest/saritasa-devops-helm-charts/pull/99)
- Added GitHub mergeable bot for checking PR version `0.2.0`
- [associated PR](https://github.com/saritasa-nest/saritasa-devops-helm-charts/pull/100)
- Added push image to registry with additional tag `latest`
## 2023-12-22

[prod]

- [associated PR](https://github.com/saritasa-nest/saritasa-devops-helm-charts/pull/104)
- Release terraform-pod chart with 1.6.6 terraform version `0.0.21`

## 2023-10-27

[prod]

- [associated PR](https://github.com/saritasa-nest/saritasa-devops-helm-charts/pull/99)
- Added GitHub mergeable bot for checking PR version `0.2.0`

- [associated PR](https://github.com/saritasa-nest/saritasa-devops-helm-charts/pull/98)
- Changed tekton-apps version to 0.2.15
40 changes: 39 additions & 1 deletion charts/tekton-apps/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ appVersion: "v0.29.0"
# This is the chart version. This version number should be incremented each time you make changes
dmitry-mightydevops marked this conversation as resolved.
Show resolved Hide resolved
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.15
version: 0.2.17

maintainers:
- url: https://www.saritasa.com/
Expand Down Expand Up @@ -1164,6 +1164,44 @@ description: |
- CreateNamespace=true
```

We can add both tags `${env}-${commit_hash}` (i.e. `:dev-dsjfh43`) and `:latest` on the built image in tekton-pipelines:
```bash
Saving 190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:staging-802d5f2...
*** Images (sha256:9e15b5041fec79448e25948503ddd68ee8563d7d3bacacb4f3f20c1e5a23b891):
190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:staging-802d5f2
190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:latest
```

1. For buildpacks pipelines:
Set `add_tag_latest` parameter to "true" in `triggerBinding` as shown below:
```yaml
triggerBinding:
- name: docker_registry_repository
value: 190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend
....
....
- name: add_tag_latest
value: 'true'
```

2. For kaniko pipelines:
We tag image by this argument by default:
`--destination=$(resources.outputs.image.url`
We can use this argument twice, so set `kaniko_extra_args` with
`--destination` equals full image path plus `:latest`. It will be
added as additional tag and pushed to the registry.
```yaml
triggerBinding:
- name: docker_registry_repository
value: 190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend
- name: docker_file
value: Dockerfile
- name: docker_context
value: .
- name: kaniko_extra_args
value: "--destination=190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:latest"
```

Simple wordpress application example filled by default:

```yaml
Expand Down
256 changes: 253 additions & 3 deletions 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.15-dev.10](https://img.shields.io/badge/Version-0.2.15-dev.10-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)
![Version: 0.2.17](https://img.shields.io/badge/Version-0.2.17-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 @@ -717,6 +717,218 @@ spec:
- CreateNamespace=true
```

Component namespace can be set in 2 ways:
1. From `project.argocd.namespace` - this is useful when all project components share the same project namespace. Example:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: tekton-apps
namespace: argo-cd
finalizers:
- resources-finalizer.argocd.argoproj.io
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
argocd.argoproj.io/sync-wave: "41"
spec:
destination:
server: https://kubernetes.default.svc
namespace: ci
project: default
source:
chart: saritasa-tekton-apps
helm:
values: |
environment: staging
...
apps:
- project: xxx
enabled: true
argocd:
labels:
created-by: xxx
ops-main: xxx
ops-secondary: xxx
pm: xxx
tm: xxx
namespace: xxx
notifications:
annotations:
# In rocks/cloud cluster use slack-token integration:
notifications.argoproj.io/subscribe.on-health-degraded.slack: project-xxx; project-xxx-alarms
notifications.argoproj.io/subscribe.on-sync-failed.slack: project-xxx-ci; project-xxx-alarms
notifications.argoproj.io/subscribe.on-sync-status-unknown.slack: project-xxx; project-xxx-alarms
notifications.argoproj.io/subscribe.on-deployed.slack: project-xxx-ci
# In staging/prod client cluster use webhook integration:
notifications.argoproj.io/subscribe.on-health-degraded.project-webhook: enabled
mailList: xxx@saritasa.com
devopsMailList: devops+xxx@saritasa.com
jiraURL: https://saritasa.atlassian.net/browse/xxx
tektonURL: https://tekton.saritasa.rocks/#/namespaces/ci/pipelineruns
slack: client-xxx-ci
kubernetesRepository:
name: xxx-kubernetes-aws
branch: main
url: git@github.com:saritasa-nest/xxx-kubernetes-aws.git

components:
- name: backend
repository: xxx-backend
pipeline: buildpack-django-build-pipeline
applicationURL: https://xxx.site.url
eventlistener:
template: buildpack-django-build-pipeline-trigger-template
gitWebhookBranches:
- develop
triggerBinding:
- name: docker_registry_repository
value: xxx.dkr.ecr.us-west-2.amazonaws.com/xxx/backend
- name: buildpack_builder_image
value: public.ecr.aws/saritasa/buildpacks/google/builder:v1
- name: buildpack_runner_image
value: public.ecr.aws/saritasa/buildpacks/google/runner:v1
- name: frontend
repository: xxx-frontend
pipeline: buildpack-django-build-pipeline
applicationURL: https://xxx.site.url
eventlistener:
template: buildpack-django-build-pipeline-trigger-template
gitWebhookBranches:
- develop
triggerBinding:
- name: docker_registry_repository
value: xxx.dkr.ecr.us-west-2.amazonaws.com/xxx/frontend
- name: buildpack_builder_image
value: public.ecr.aws/saritasa/buildpacks/google/builder:v1
- name: buildpack_runner_image
value: public.ecr.aws/saritasa/buildpacks/google/runner:v1

repoURL: https://saritasa-nest.github.io/saritasa-devops-helm-charts/
targetRevision: "0.1.16"
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
```

2. From `component.argocd.destionationNamespaces` - this can be useful when component has different namespace from the project. For example:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: tekton-apps
namespace: argo-cd
finalizers:
- resources-finalizer.argocd.argoproj.io
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
argocd.argoproj.io/sync-wave: "41"
spec:
destination:
server: https://kubernetes.default.svc
namespace: ci
project: default
source:
chart: saritasa-tekton-apps
helm:
values: |
environment: staging
...
apps:
- project: xxx
enabled: true
argocd:
labels:
created-by: xxx
ops-main: xxx
ops-secondary: xxx
pm: xxx
tm: xxx
namespace: xxx
extraDestinationNamespaces:
- jitsi
notifications:
annotations:
# In rocks/cloud cluster use slack-token integration:
notifications.argoproj.io/subscribe.on-health-degraded.slack: project-xxx; project-xxx-alarms
notifications.argoproj.io/subscribe.on-sync-failed.slack: project-xxx-ci; project-xxx-alarms
notifications.argoproj.io/subscribe.on-sync-status-unknown.slack: project-xxx; project-xxx-alarms
notifications.argoproj.io/subscribe.on-deployed.slack: project-xxx-ci
# In staging/prod client cluster use webhook integration:
notifications.argoproj.io/subscribe.on-health-degraded.project-webhook: enabled
mailList: xxx@saritasa.com
devopsMailList: devops+xxx@saritasa.com
jiraURL: https://saritasa.atlassian.net/browse/xxx
tektonURL: https://tekton.saritasa.rocks/#/namespaces/ci/pipelineruns
slack: client-xxx-ci
kubernetesRepository:
name: xxx-kubernetes-aws
branch: main
url: git@github.com:saritasa-nest/xxx-kubernetes-aws.git

components:
- name: backend
repository: xxx-backend
pipeline: buildpack-django-build-pipeline
applicationURL: https://xxx.site.url
eventlistener:
template: buildpack-django-build-pipeline-trigger-template
gitWebhookBranches:
- develop
triggerBinding:
- name: docker_registry_repository
value: xxx.dkr.ecr.us-west-2.amazonaws.com/xxx/backend
- name: buildpack_builder_image
value: public.ecr.aws/saritasa/buildpacks/google/builder:v1
- name: buildpack_runner_image
value: public.ecr.aws/saritasa/buildpacks/google/runner:v1
- name: frontend
repository: xxx-frontend
pipeline: buildpack-django-build-pipeline
applicationURL: https://xxx.site.url
eventlistener:
template: buildpack-django-build-pipeline-trigger-template
gitWebhookBranches:
- develop
triggerBinding:
- name: docker_registry_repository
value: xxx.dkr.ecr.us-west-2.amazonaws.com/xxx/frontend
- name: buildpack_builder_image
value: public.ecr.aws/saritasa/buildpacks/google/builder:v1
- name: buildpack_runner_image
value: public.ecr.aws/saritasa/buildpacks/google/runner:v1
- name: jitsi
repository: xxx-jitsi
pipeline: buildpack-django-build-pipeline
argocd:
destinationNamespace: jitsi
applicationURL: https://xxx.site.url
eventlistener:
template: buildpack-django-build-pipeline-trigger-template
gitWebhookBranches:
- develop
triggerBinding:
- name: docker_registry_repository
value: xxx.dkr.ecr.us-west-2.amazonaws.com/xxx/jitsi
- name: buildpack_builder_image
value: public.ecr.aws/saritasa/buildpacks/google/builder:v1
- name: buildpack_runner_image
value: public.ecr.aws/saritasa/buildpacks/google/runner:v1

repoURL: https://saritasa-nest.github.io/saritasa-devops-helm-charts/
targetRevision: "0.1.16"
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
```

If you want to enable ignoring deployment replicas count differences in ArgoCD application of your component add `apps[PROJECT].components[NAME].argocd.ignoreDeploymentReplicasDiff: true` flag like in the below example (it may be needed for `staging` and `prod` envs, where you have horizontal pod autoscheduling - HPA):

```yaml
Expand Down Expand Up @@ -973,6 +1185,44 @@ spec:
- CreateNamespace=true
```

We can add both tags `${env}-${commit_hash}` (i.e. `:dev-dsjfh43`) and `:latest` on the built image in tekton-pipelines:
```bash
Saving 190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:staging-802d5f2...
*** Images (sha256:9e15b5041fec79448e25948503ddd68ee8563d7d3bacacb4f3f20c1e5a23b891):
190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:staging-802d5f2
190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:latest
```

1. For buildpacks pipelines:
Set `add_tag_latest` parameter to "true" in `triggerBinding` as shown below:
```yaml
triggerBinding:
- name: docker_registry_repository
value: 190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend
....
....
- name: add_tag_latest
value: 'true'
```

2. For kaniko pipelines:
We tag image by this argument by default:
`--destination=$(resources.outputs.image.url`
We can use this argument twice, so set `kaniko_extra_args` with
`--destination` equals full image path plus `:latest`. It will be
added as additional tag and pushed to the registry.
```yaml
triggerBinding:
- name: docker_registry_repository
value: 190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend
- name: docker_file
value: Dockerfile
- name: docker_context
value: .
- name: kaniko_extra_args
value: "--destination=190499200307.dkr.ecr.us-west-2.amazonaws.com/ygm/staging/backend:latest"
```

Simple wordpress application example filled by default:

```yaml
Expand Down Expand Up @@ -1136,7 +1386,7 @@ spec:
```

More complicated example of project containing `wordpress` and `frontend` component.
If you need to deploy wordpress component in a namespace different from ArgoCD project's one (i.e. `wordpress`), you need to add `extraDestinationNamespaces: ["wordpress"]` and `argocd.namespace=wordpress`, like in the example below
If you need to deploy wordpress component in a namespace different from ArgoCD project's one (i.e. `wordpress`), you need to add `project.argocd.extraDestinationNamespaces: ["wordpress"]` and `components.argocd.destinationNamespace=wordpress`, like in the example below
Also defined sample of all extra wordpress params that could be set:

```yaml
Expand Down Expand Up @@ -1363,4 +1613,4 @@ whitelistIP: |
| 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.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
10 changes: 6 additions & 4 deletions charts/tekton-apps/templates/general/triggerbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ spec:
{{- end }}
{{- toYaml $component.triggerBinding | nindent 2 }}

{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "source_subpath" "default" "." ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "buildpack_config_filename" "default" "buildpack.yml" ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "project_config_filename" "default" "project.toml" ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "sentry_project_name" "default" (printf "%s-%s" $project.project $component.name) ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "add_tag_latest" "default" "'false'" ) | nindent 2 }}

{{- if $argocdSource }}
# ! OLD WAY:
# If you see this message - pls transfer kubernetes manifests into dedicated kubernetes git repo
Expand All @@ -61,10 +67,6 @@ spec:
value: {{ $project.kubernetesRepository.url }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "kubernetes_branch" "default" ($project.kubernetesRepository).branch ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "kubernetes_repository_kustomize_path" "default" (printf "apps/%s/manifests/%s" $component.name $projectEnvironment) ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "source_subpath" "default" "." ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "buildpack_config_filename" "default" "buildpack.yml" ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "project_config_filename" "default" "project.toml" ) | nindent 2 }}
{{- include "tekton-apps.get-triggerbinding-value-or-default" (dict "triggerBinding" $component.triggerBinding "name" "sentry_project_name" "default" (printf "%s-%s" $project.project $component.name) ) | nindent 2 }}
{{- end}}
---

Expand Down
Loading
Loading