Skip to content

Commit

Permalink
Updated AppSet name and namespace values (#89)
Browse files Browse the repository at this point in the history
This allows us to to be in compliance with K8s restrictions on name and namespace values length as PR / MR branch name values can vary
  • Loading branch information
saidsef authored Feb 8, 2023
1 parent b96d6df commit 889c860
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 51 deletions.
8 changes: 5 additions & 3 deletions charts/applicationset/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: argocd-applicationsets-services
description: A HELM Chart for ArgoCD ApplicationSets for Kubernetes
type: application
version: &version "0.8.16"
version: &version "0.8.17"
appVersion: *version
kubeVersion: ">= 1.23"
home: https://github.com/saidsef/argocd-applicationsets-services
Expand All @@ -22,8 +22,10 @@ sources:
annotations:
artifacthub.io/license: "Apache-2.0"
artifacthub.io/changes: |
- kind: fixed
description: Truncated deployment name to 50 chars to complay with max length
- kind: removed
description: Removed duplicate variables
- kind: changed
description: Changed values for image tag name(s)
artifacthub.io/links: |
- name: README
url: https://raw.githubusercontent.com/saidsef/argocd-applicationsets-services/main/README.md
Expand Down
4 changes: 2 additions & 2 deletions charts/applicationset/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# argocd-applicationsets-services

![Version: 0.8.16](https://img.shields.io/badge/Version-0.8.16-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.8.16](https://img.shields.io/badge/AppVersion-0.8.16-informational?style=flat-square)
![Version: 0.8.17](https://img.shields.io/badge/Version-0.8.17-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.8.17](https://img.shields.io/badge/AppVersion-0.8.17-informational?style=flat-square)

A HELM Chart for ArgoCD ApplicationSets for Kubernetes

Expand Down Expand Up @@ -40,7 +40,7 @@ Kubernetes: `>= 1.23`
| project.destinations | list | `[{"name":"*","namespace":"previews","server":"*"}]` | Only permit applications to deploy to the previews namespace in the same cluster |
| project.namespaceResourceBlacklist | list | `[{"group":"argoproj.io","kind":"AppProject"}]` | Allow all namespaced-scoped resources to be created, except for AppProject |
| project.sourceRepos | list | `["*"]` | Allow from all repositories |
| repos | object | `{"github":[{"images":["docker.io/saidsef/node-webserver:{{branch_slug}}"],"name":"node-webserver"},{"name":"alpine-jenkins-dockerfile","path":"deployment/preview"},{"images":["docker.io/saidsef/aws-kinesis-local:{{branch_slug}}"],"name":"aws-kinesis-local"},{"images":["docker.io/saidsef/aws-dynamodb-local:{{branch_slug}}"],"name":"aws-dynamodb-local"},{"name":"tika-document-to-text","path":"deployment/preview"},{"images":["docker.io/saidsef/k8s-spot-termination-notice:merge"],"name":"k8s-spot-termination-notice"},{"name":"scapy-containerised","path":"charts/scapy","values":{"image":{"tag":"{{branch_slug}}"}}},{"chart":"reverse-geocoding","name":"faas-reverse-geocoding","parameters":[{"name":"image.tag","value":"{{branch_slug}}"},{"name":"ingress.enabled","value":"true"},{"name":"ingress.enabled","value":"true"},{"name":"ingress.hosts[0].host","value":"{{branch_slug}}"}],"repoUrl":"https://saidsef.github.io/faas-reverse-geocoding"}],"gitlab":{}}` | List of repo names and override images for preview environment to dynamically pass the branch of the pull request head use '{{branch_slug}}' variable see: https://argocd-applicationset.readthedocs.io/en/stable/Generators-Pull-Request/#template |
| repos | object | `{"github":[{"images":["docker.io/saidsef/node-webserver:{{branch}}"],"name":"node-webserver"},{"name":"alpine-jenkins-dockerfile","path":"deployment/preview"},{"images":["docker.io/saidsef/aws-kinesis-local:{{branch}}"],"name":"aws-kinesis-local"},{"images":["docker.io/saidsef/aws-dynamodb-local:{{branch}}"],"name":"aws-dynamodb-local"},{"name":"tika-document-to-text","path":"deployment/preview"},{"images":["docker.io/saidsef/k8s-spot-termination-notice:merge"],"name":"k8s-spot-termination-notice"},{"name":"scapy-containerised","path":"charts/scapy","values":{"image":{"tag":"{{branch}}"}}},{"chart":"reverse-geocoding","name":"faas-reverse-geocoding","parameters":[{"name":"image.tag","value":"{{branch}}"},{"name":"ingress.enabled","value":"true"},{"name":"ingress.enabled","value":"true"},{"name":"ingress.hosts[0].host","value":"{{branch}}"}],"repoUrl":"https://saidsef.github.io/faas-reverse-geocoding"}],"gitlab":{}}` | List of repo names and override images for preview environment to dynamically pass the branch of the pull request head use '{{branch}}' variable see: https://argocd-applicationset.readthedocs.io/en/stable/Generators-Pull-Request/#template |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
37 changes: 17 additions & 20 deletions charts/applicationset/templates/github-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,35 @@ spec:
generators:
- pullRequest:
github:
api: '{{ $github.api }}'
owner: '{{ required "A valid repo organization / owner is required" $github.owner }}'
repo: '{{ required "A valid repo name is required" $repo.name }}'
api: {{ $github.api }}
owner: {{ required "A valid repo organization / owner is required" $github.owner }}
repo: {{ required "A valid repo name is required" $repo.name }}
labels:
- '{{ required "A valied label(s) for PRs is required" (coalesce $github.label $globals.label) }}'
- {{ required "A valied label(s) for PRs is required" (coalesce $github.label $globals.label) }}
{{- if and ($github.secretName) ($github.secretKey) }}
tokenRef:
secretName: '{{ $github.secretName }}'
key: '{{ $github.secretKey }}'
secretName: {{ $github.secretName }}
key: {{ $github.secretKey }}
{{- end }}
requeueAfterSeconds: {{ $refresh | default 500 }}
template:
metadata:
{{- $appName := printf "%s-%sbranch_slug%s-%snumber%s" $repo.name $dqf $dqb $dqf $dqb }}
name: {{$appName | trunc 50 | squote }}
name: {{ printf "pr-%sbranch_slug%s-%snumber%s" $dqf $dqb $dqf $dqb }}
annotations:
app.kubernetes.io/created-by: 'applicationset'
app.kubernetes.io/name: '{{ $dqf }}branch_slug{{ $dqb }}'
app.kubernetes.io/part-of: '{{ $name }}'
app.kubernetes.io/name: {{ $branchSlug }}
app.kubernetes.io/part-of: {{ $name }}
argocd-image-updater.argoproj.io/force-update: 'true'
argocd-image-updater.argoproj.io/update-strategy: 'latest'
argocd-image-updater.argoproj.io/write-back-method: 'argocd'
argocd.argoproj.io/application-set-refresh: "true"
argocd.argoproj.io/head: '{{ $dqf }}head_short_sha{{ $dqb }}'
argocd.argoproj.io/tracking-id: '{{$repo.name}}:{{ $dqf }}head_short_sha{{ $dqb }}'
argocd.argoproj.io/application-set-refresh: 'true'
argocd.argoproj.io/head: {{ $headShortSha }}
link.argocd.argoproj.io/external-link: '{{ $pr }}/{{ $github.owner }}/{{or $repo.name $repo.path}}/pull/{{ $dqf }}number{{ $dqb }}'
notifications.argoproj.io/subscribe.on-deleted.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-deployed.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-health-degraded.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-sync-failed.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-sync-running.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-deleted.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-deployed.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-health-degraded.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-sync-failed.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-sync-running.slack: {{ $notificationChannel }}
spec:
revisionHistoryLimit: {{ $globals.revisionHistoryLimit }}
source:
Expand Down Expand Up @@ -113,7 +111,6 @@ spec:
duration: {{ $retryBackoffDuration }}
destination:
server: {{ $server }}
{{- $deployToNamespace := printf "%s-%sbranch_slug%s-%snumber%s" $repo.name $dqf $dqb $dqf $dqb }}
namespace: {{ coalesce $.Values.globals.deployToNamespace $deployToNamespace }}
namespace: {{ printf "pr-%sbranch_slug%s-%snumber%s" $dqf $dqb $dqf $dqb }}
{{- end }}
{{- end }}
35 changes: 16 additions & 19 deletions charts/applicationset/templates/gitlab-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,35 @@ spec:
generators:
- pullRequest:
gitlab:
api: '{{ $gitlab.api }}'
project: '{{ coalesce $repo.project $gitlab.group | required "A valid repo project / group ID is required" }}'
api: {{ $gitlab.api }}
project: {{ coalesce $repo.project $gitlab.group | required "A valid repo project / group ID is required" }}
pullRequestState: 'opened'
labels:
- '{{ required "A valied label(s) for PRs is required" (coalesce $gitlab.label $globals.label) }}'
- {{ required "A valied label(s) for PRs is required" (coalesce $gitlab.label $globals.label) }}
{{- if and ($gitlab.secretName) ($gitlab.secretKey) }}
tokenRef:
secretName: '{{ $gitlab.secretName }}'
key: '{{ $gitlab.secretKey }}'
secretName: {{ $gitlab.secretName }}
key: {{ $gitlab.secretKey }}
{{- end }}
requeueAfterSeconds: {{ $refresh | default 500 }}
template:
metadata:
{{- $appName := printf "%s-%sbranch_slug%s-%snumber%s" $repo.name $dqf $dqb $dqf $dqb }}
name: {{ $appName | trunc 50 | squote }}
name: {{ printf "mr-%sbranch_slug%s-%snumber%s" $dqf $dqb $dqf $dqb }}
annotations:
app.kubernetes.io/created-by: 'applicationset'
app.kubernetes.io/name: '{{ $dqf }}branch_slug{{ $dqb }}'
app.kubernetes.io/part-of: '{{ $name }}'
app.kubernetes.io/name: {{ $branchSlug }}
app.kubernetes.io/part-of: {{ $name }}
argocd-image-updater.argoproj.io/force-update: 'true'
argocd-image-updater.argoproj.io/update-strategy: 'latest'
argocd-image-updater.argoproj.io/write-back-method: 'argocd'
argocd.argoproj.io/application-set-refresh: "true"
argocd.argoproj.io/head: '{{ $dqf }}head_short_sha{{ $dqb }}'
argocd.argoproj.io/tracking-id: '{{$repo.name}}:{{ $dqf }}head_short_sha{{ $dqb }}'
argocd.argoproj.io/application-set-refresh: 'true'
argocd.argoproj.io/head: {{ $headShortSha }}
link.argocd.argoproj.io/external-link: '{{ $gitlab.api }}/{{ $gitlab.group }}/{{or $repo.name $repo.path}}/-/merge_requests/{{ $dqf }}number{{ $dqb }}'
notifications.argoproj.io/subscribe.on-deleted.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-deployed.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-health-degraded.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-sync-failed.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-sync-running.slack: '{{ $notificationChannel }}'
notifications.argoproj.io/subscribe.on-deleted.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-deployed.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-health-degraded.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-sync-failed.slack: {{ $notificationChannel }}
notifications.argoproj.io/subscribe.on-sync-running.slack: {{ $notificationChannel }}
spec:
revisionHistoryLimit: {{ $globals.revisionHistoryLimit }}
source:
Expand Down Expand Up @@ -112,7 +110,6 @@ spec:
duration: {{ $retryBackoffDuration }}
destination:
server: {{ $server }}
{{- $deployToNamespace := printf "%s-%sbranch_slug%s-%snumber%s" $repo.name $dqf $dqb $dqf $dqb }}
namespace: {{ coalesce $.Values.globals.deployToNamespace $deployToNamespace | trunc 50 }}
namespace: {{ printf "mr-%sbranch_slug%s-%snumber%s" $dqf $dqb $dqf $dqb }}
{{- end }}
{{- end }}
14 changes: 7 additions & 7 deletions charts/applicationset/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ gitlab:
secretKey: ''

# -- List of repo names and override images for preview environment
# to dynamically pass the branch of the pull request head use '{{branch_slug}}' variable
# to dynamically pass the branch of the pull request head use '{{branch}}' variable
# see: https://argocd-applicationset.readthedocs.io/en/stable/Generators-Pull-Request/#template
repos:
gitlab: {}
Expand All @@ -87,15 +87,15 @@ repos:
github:
- name: node-webserver
images:
- 'docker.io/saidsef/node-webserver:{{branch_slug}}'
- 'docker.io/saidsef/node-webserver:{{branch}}'
- name: alpine-jenkins-dockerfile
path: 'deployment/preview'
- name: aws-kinesis-local
images:
- 'docker.io/saidsef/aws-kinesis-local:{{branch_slug}}'
- 'docker.io/saidsef/aws-kinesis-local:{{branch}}'
- name: aws-dynamodb-local
images:
- 'docker.io/saidsef/aws-dynamodb-local:{{branch_slug}}'
- 'docker.io/saidsef/aws-dynamodb-local:{{branch}}'
- name: tika-document-to-text
path: 'deployment/preview'
- name: k8s-spot-termination-notice
Expand All @@ -105,16 +105,16 @@ repos:
path: 'charts/scapy'
values:
image:
tag: '{{branch_slug}}'
tag: '{{branch}}'
- name: faas-reverse-geocoding
chart: 'reverse-geocoding'
repoUrl: 'https://saidsef.github.io/faas-reverse-geocoding'
parameters:
- name: "image.tag"
value: "{{branch_slug}}"
value: "{{branch}}"
- name: "ingress.enabled"
value: "true"
- name: "ingress.enabled"
value: "true"
- name: "ingress.hosts[0].host"
value: "{{branch_slug}}"
value: "{{branch}}"

0 comments on commit 889c860

Please sign in to comment.