Skip to content

Commit e963154

Browse files
committed
feat: add gitlab related annotations when CI is gitlab
check for Chart.lock instead of requirements.lock add .dockerignore Signed-off-by: Siddharth Tiwari <[email protected]>
1 parent cb412dd commit e963154

File tree

7 files changed

+54
-41
lines changed

7 files changed

+54
-41
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git*
2+
*.md
3+
LICENSE
4+
Dockerfile
5+
*ignore

auto-deploy

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function download_chart() {
5454
cp -R "$ASSETS_CHART_DIR" chart
5555
fi
5656

57-
if [[ -f chart/requirements.lock ]]; then
57+
if [[ -f chart/Chart.lock ]]; then
5858
helm dependency build chart/
5959
else
6060
helm dependency update chart/
@@ -101,6 +101,11 @@ function initialize_tiller() {
101101

102102
function write_environment_values_file() {
103103

104+
export GITLAB_CI=${GITLAB_CI:-false}
105+
if test "${GITLAB_CI}" == "true"; then
106+
echo "gitlab: true" >"$AUTO_DEPLOY_ENVIRONMENT_VALUES_FILE"
107+
fi
108+
104109
# Helm 3 does not like `--set image.secrets[0]=""`
105110
if [[ "$CI_PROJECT_VISIBILITY" != "public" ]]; then
106111
echo "image: { secrets: [ { name: gitlab-registry-${CI_PROJECT_PATH_SLUG} } ] }" >>"$AUTO_DEPLOY_ENVIRONMENT_VALUES_FILE"
@@ -260,10 +265,10 @@ function deploy() {
260265
"${atomic_flag[@]}" \
261266
"${debug_flag[@]}" \
262267
--wait \
263-
--set gitlab.app="$CI_PROJECT_PATH_SLUG" \
264-
--set gitlab.env="$CI_ENVIRONMENT_SLUG" \
265-
--set gitlab.envName="$CI_ENVIRONMENT_NAME" \
266-
--set gitlab.envURL="$CI_ENVIRONMENT_URL" \
268+
--set project.repo="$CI_PROJECT_PATH_SLUG" \
269+
--set project.slug="$CI_ENVIRONMENT_SLUG" \
270+
--set project.env="$CI_ENVIRONMENT_NAME" \
271+
--set project.url="$CI_ENVIRONMENT_URL" \
267272
--set releaseOverride="$RELEASE_NAME" \
268273
--set image.repository="$image_repository" \
269274
--set-string image.tag="$image_tag" \
@@ -292,10 +297,10 @@ function deploy() {
292297
"${atomic_flag[@]}" \
293298
"${debug_flag[@]}" \
294299
--wait \
295-
--set gitlab.app="$CI_PROJECT_PATH_SLUG" \
296-
--set gitlab.env="$CI_ENVIRONMENT_SLUG" \
297-
--set gitlab.envName="$CI_ENVIRONMENT_NAME" \
298-
--set gitlab.envURL="$CI_ENVIRONMENT_URL" \
300+
--set project.repo="$CI_PROJECT_PATH_SLUG" \
301+
--set project.slug="$CI_ENVIRONMENT_SLUG" \
302+
--set project.env="$CI_ENVIRONMENT_NAME" \
303+
--set project.url="$CI_ENVIRONMENT_URL" \
299304
--set releaseOverride="$RELEASE_NAME" \
300305
--set image.repository="$image_repository" \
301306
--set-string image.tag="$image_tag" \
@@ -466,20 +471,20 @@ function get_replicas() {
466471
option=$1
467472
case $option in
468473

469-
check_kube_domain) check_kube_domain ;;
470-
download_chart) download_chart ;;
471-
ensure_namespace) ensure_namespace ;;
472-
initialize_tiller) initialize_tiller ;;
473-
create_secret) create_secret ;;
474-
persist_environment_url) persist_environment_url ;;
475-
auto_database_url) auto_database_url ;;
476-
install_postgresql) install_postgresql "${@:2}" ;;
477-
deploy) deploy "${@:2}" ;;
478-
scale) scale "${@:2}" ;;
479-
delete) delete "${@:2}" ;;
480-
create_application_secret) create_application_secret "${@:2}" ;;
481-
deploy_name) deploy_name "${@:2}" ;;
482-
get_replicas) get_replicas "${@:2}" ;;
483-
check_old_postgres_exist) check_old_postgres_exist ;;
484-
*) exit 1 ;;
474+
check_kube_domain) check_kube_domain ;;
475+
download_chart) download_chart ;;
476+
ensure_namespace) ensure_namespace ;;
477+
initialize_tiller) initialize_tiller ;;
478+
create_secret) create_secret ;;
479+
persist_environment_url) persist_environment_url ;;
480+
auto_database_url) auto_database_url ;;
481+
install_postgresql) install_postgresql "${@:2}" ;;
482+
deploy) deploy "${@:2}" ;;
483+
scale) scale "${@:2}" ;;
484+
delete) delete "${@:2}" ;;
485+
create_application_secret) create_application_secret "${@:2}" ;;
486+
deploy_name) deploy_name "${@:2}" ;;
487+
get_replicas) get_replicas "${@:2}" ;;
488+
check_old_postgres_exist) check_old_postgres_exist ;;
489+
*) exit 1 ;;
485490
esac

chart/lambda/Chart.yaml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,17 @@ engine: gotpl
2727
home: https://github.com/opencloudengineer/lambda/tree/main/chart/lambda
2828
icon: https://helm.sh/img/helm.svg
2929
keywords:
30-
- database
31-
- mongodb
32-
- nosql
33-
- postgres
34-
- mysql
35-
- mariadb
36-
- sql
37-
- redis
38-
- caching
30+
- REST
31+
- GraphQL
32+
- gRPC
33+
- deployments
34+
- daemonsets
35+
- statefulsets
3936
maintainers:
4037
4138
name: opencloudengineer
4239
name: lambda
4340
sources:
44-
- https://www.mysql.com/
45-
- https://www.mongodb.com/
46-
- https://www.postgresql.org/
47-
- https://redis.io/
48-
- https://mariadb.org/
41+
- https://helm.sh/docs/topics/charts
42+
- https://gitlab.com/gitlab-org/cluster-integration/auto-deploy-image/-/tree/master/assets/auto-deploy-app
4943
version: 0.1.0

chart/lambda/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
| service.annotations | Service annotations | `{}` |
3030
| service.name | | `web` |
3131
| service.type | | `ClusterIP` |
32-
| service.url | | `http://my.host.com/` |
32+
| service.url | | `http://app.namespace.cluster.local/` |
3333
| service.additionalHosts | If present, this list will add additional hostnames to the server configuration. | `nil` |
3434
| service.commonName | If present, this will define the ssl certificate common name to be used by CertManager. `service.url` and `service.additionalHosts` will be added as Subject Alternative Names (SANs) | `nil` |
3535
| service.externalPort | | `5000` |

chart/lambda/templates/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ metadata:
66
annotations:
77
{{ if .Values.project.repo }}repo: {{ .Values.project.repo | quote }}{{ end }}
88
{{ if .Values.project.slug }}slug: {{ .Values.project.slug | quote }}{{ end }}
9+
{{ if .Values.gitlab }}app.gitlab.com/app: {{ .Values.project.repo | quote }}{{ end }}
10+
{{ if .Values.gitlab }}app.gitlab.com/env: {{ .Values.project.slug | quote }}{{ end }}
911
labels:
1012
app: {{ template "appname" . }}
1113
track: "{{ .Values.application.track }}"
@@ -31,6 +33,9 @@ spec:
3133
checksum/application-secrets: "{{ .Values.application.secretChecksum }}"
3234
{{ if .Values.project.repo }}repo: {{ .Values.project.repo | quote }}{{ end }}
3335
{{ if .Values.project.slug }}slug: {{ .Values.project.slug | quote }}{{ end }}
36+
{{ if .Values.gitlab }}app.gitlab.com/app: {{ .Values.project.repo | quote }}{{ end }}
37+
{{ if .Values.gitlab }}app.gitlab.com/env: {{ .Values.project.slug | quote }}{{ end }}
38+
3439
{{- if .Values.podAnnotations }}
3540
{{ toYaml .Values.podAnnotations | indent 8 }}
3641
{{- end }}

chart/lambda/templates/worker-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ items:
1010
annotations:
1111
{{ if $.Values.project.repo }}repo: {{ $.Values.project.repo | quote }}{{ end }}
1212
{{ if $.Values.project.slug }}slug: {{ $.Values.project.slug | quote }}{{ end }}
13+
{{ if $.Values.gitlab }}app.gitlab.com/app: {{ $.Values.project.repo | quote }}{{ end }}
14+
{{ if $.Values.gitlab }}app.gitlab.com/env: {{ $.Values.project.slug | quote }}{{ end }}
1315
labels:
1416
track: "{{ $.Values.application.track }}"
1517
tier: worker
@@ -33,6 +35,8 @@ items:
3335
checksum/application-secrets: "{{ $.Values.application.secretChecksum }}"
3436
{{ if $.Values.project.repo }}repo: {{ $.Values.project.repo | quote }}{{ end }}
3537
{{ if $.Values.project.slug }}slug: {{ $.Values.project.slug | quote }}{{ end }}
38+
{{ if $.Values.gitlab }}app.gitlab.com/app: {{ $.Values.project.repo | quote }}{{ end }}
39+
{{ if $.Values.gitlab }}app.gitlab.com/env: {{ $.Values.project.slug | quote }}{{ end }}
3640
{{- if $.Values.podAnnotations }}
3741
{{ toYaml $.Values.podAnnotations | indent 10 }}
3842
{{- end }}

chart/lambda/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ service:
2929
annotations: {}
3030
name: web
3131
type: ClusterIP
32-
url: http://my.host.com/
32+
url: http://app.namespace.cluster.local/
3333
additionalHosts:
3434
commonName:
3535
externalPort: 5000

0 commit comments

Comments
 (0)