Skip to content

Commit

Permalink
Use magda-common for docker image related logic as per ticket: magda-…
Browse files Browse the repository at this point in the history
  • Loading branch information
t83714 committed Oct 11, 2021
1 parent a56ea33 commit d736ba3
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ magda-tenant-api/lib/

#typescript
tsconfig.tsbuildinfo

deploy/*/charts
1 change: 1 addition & 0 deletions .helmdocsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deploy/*/charts
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- Upgrade dependencies
- Upgrade CI scripts
- Related to https://github.com/magda-io/magda/issues/3229, Use magda-common for docker image related logic
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,29 @@ Docker image releases can be found from Docker Hub:
https://hub.docker.com/r/data61/magda-csw-connector/

Development releases (per commit) are also available from [GitHub Registry](https://github.com/magda-io/magda-csw-connector/packages) and accessible with access token.

## Requirements

Kubernetes: `>= 1.14.0-0`

| Repository | Name | Version |
| ----------------------- | ------------ | ------------- |
| https://charts.magda.io | magda-common | 1.0.0-alpha.4 |

## Values

| Key | Type | Default | Description |
| ---------------------------------- | ------ | ------------------------- | ----------- |
| config.id | string | `"default-csw-connector"` | |
| defaultImage.imagePullSecret | bool | `false` | |
| defaultImage.pullPolicy | string | `"IfNotPresent"` | |
| defaultImage.repository | string | `"docker.io/data61"` | |
| defaultSettings.includeCronJobs | bool | `true` | |
| defaultSettings.includeInitialJobs | bool | `false` | |
| defaultTenantId | int | `0` | |
| global.connectors.image | object | `{}` | |
| global.image | object | `{}` | |
| image.name | string | `"magda-csw-connector"` | |
| resources.limits.cpu | string | `"100m"` | |
| resources.requests.cpu | string | `"50m"` | |
| resources.requests.memory | string | `"30Mi"` | |
37 changes: 37 additions & 0 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Magda CSW Connector

![CI Workflow](https://github.com/magda-io/magda-csw-connector/workflows/Main%20CI%20Workflow/badge.svg?branch=master) [![Release](https://img.shields.io/github/release/magda-io/magda-csw-connector.svg)](https://github.com/magda-io/magda-csw-connector/releases)

[Magda](https://github.com/magda-io/magda) connectors go out to external datasources and copy their metadata into the Registry, so that they can be searched and have other aspects attached to them. A connector is simply a docker-based microservice that is invoked as a job. It scans the target datasource (usually an open-data portal), then completes and shuts down.

Magda CSW Connector is created for crawling data from [CSW(Catalog Service for the Web)](https://en.wikipedia.org/wiki/Catalogue_Service_for_the_Web) data source.

### Helm Chart

It's recommanded to deploy connectors with as [dependencies](https://helm.sh/docs/topics/chart_best_practices/dependencies/) of a Magda helm deployment. Example can be found from [here](https://github.com/magda-io/magda-config).

- Magda Helm Charts Repository Url: https://charts.magda.io

The [helm chart](https://helm.sh/docs/topics/charts/) for this connector is auto released when a [Github Release](https://help.github.com/en/github/administering-a-repository/creating-releases) is created for this repo.

- Add repository to helm:

```bash
helm repo add magda-io https://charts.magda.io
```

### Docker Image

Docker image releases can be found from Docker Hub:

https://hub.docker.com/r/data61/magda-csw-connector/

Development releases (per commit) are also available from [GitHub Registry](https://github.com/magda-io/magda-csw-connector/packages) and accessible with access token.

{{ template "chart.maintainersSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesHeader" . }}

{{ template "chart.valuesTable" . }}
6 changes: 6 additions & 0 deletions deploy/magda-csw-connector/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: magda-common
repository: https://charts.magda.io
version: 1.0.0-alpha.4
digest: sha256:a5dcf2df16ca5a3972f92d91434c2e78be0ce411994d2a3cb89c674a711ddc24
generated: "2021-10-11T15:49:02.778334+11:00"
6 changes: 6 additions & 0 deletions deploy/magda-csw-connector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ version: "0.0.57-0"
kubeVersion: ">= 1.14.0-0"
home: "https://github.com/magda-io/magda-csw-connector"
sources: ["https://github.com/magda-io/magda-csw-connector"]
annotations:
magdaModuleType: "connector"
dependencies:
- name: magda-common
version: "1.0.0-alpha.4"
repository: "https://charts.magda.io"
13 changes: 3 additions & 10 deletions deploy/magda-csw-connector/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@ spec:
metadata:
name: connector-{{ .Values.config.id }}
spec:
{{- /*
See chart value file for details of the logic used to generate this setting value below.!!!
*/}}
{{- $imagePullSecret := (ne (.Values.image.imagePullSecret | typeOf) "<nil>") | ternary .Values.image.imagePullSecret ( (ne (.Values.global.connectors.image.imagePullSecret | typeOf) "<nil>") | ternary .Values.global.connectors.image.imagePullSecret ( (ne (.Values.global.image.imagePullSecret | typeOf) "<nil>") | ternary .Values.global.image.imagePullSecret .Values.defaultImage.imagePullSecret ) ) -}}
{{- if ne ($imagePullSecret | toString) "false" }}
imagePullSecrets:
- name: {{ $imagePullSecret }}
{{- end }}
{{- include "magda.imagePullSecrets" . | indent 10 }}
containers:
- name: connector-{{ .Values.config.id }}
image: "{{ .Values.image.repository | default .Values.global.connectors.image.repository | default .Values.global.image.repository | default .Values.defaultImage.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Values.global.connectors.image.tag | default .Values.global.image.tag | default .Values.defaultImage.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.connectors.image.pullPolicy | default .Values.global.image.pullPolicy | default .Values.defaultImage.pullPolicy }}
image: {{ include "magda.image" . | quote }}
imagePullPolicy: {{ include "magda.imagePullPolicy" . | quote }}
command:
- "node"
- "/usr/src/app/component/dist/index.js"
Expand Down
13 changes: 3 additions & 10 deletions deploy/magda-csw-connector/templates/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ spec:
metadata:
name: connector-{{ .Values.config.id }}
spec:
{{- /*
See chart value file for details of the logic used to generate this setting value below.!!!
*/}}
{{- $imagePullSecret := (ne (.Values.image.imagePullSecret | typeOf) "<nil>") | ternary .Values.image.imagePullSecret ( (ne (.Values.global.connectors.image.imagePullSecret | typeOf) "<nil>") | ternary .Values.global.connectors.image.imagePullSecret ( (ne (.Values.global.image.imagePullSecret | typeOf) "<nil>") | ternary .Values.global.image.imagePullSecret .Values.defaultImage.imagePullSecret ) ) -}}
{{- if ne ($imagePullSecret | toString) "false" }}
imagePullSecrets:
- name: {{ $imagePullSecret }}
{{- end }}
{{- include "magda.imagePullSecrets" . | indent 10 }}
containers:
- name: connector-{{ .Values.config.id }}
image: "{{ .Values.image.repository | default .Values.global.connectors.image.repository | default .Values.global.image.repository | default .Values.defaultImage.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Values.global.connectors.image.tag | default .Values.global.image.tag | default .Values.defaultImage.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.connectors.image.pullPolicy | default .Values.global.image.pullPolicy | default .Values.defaultImage.pullPolicy }}
image: {{ include "magda.image" . | quote }}
imagePullPolicy: {{ include "magda.imagePullPolicy" . | quote }}
command:
- "node"
- "/usr/src/app/component/dist/index.js"
Expand Down
2 changes: 0 additions & 2 deletions deploy/magda-csw-connector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ global:
# image setting loadding order: (from higher priority to lower priority)
# - Values.image.x
# - Values.global.connectors.image.x
# - Values.global.image.x
# - Values.defaultImage.x
# You can set `imagePullSecret` value to `false` (bool) to reset the value (see example below)

Expand All @@ -20,7 +19,6 @@ image:

defaultImage:
repository: docker.io/data61
tag: 0.0.57-0
pullPolicy: IfNotPresent
imagePullSecret: false

Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
"watch": "tsc -b --watch",
"start": "node dist/index.js",
"dev": "run-typescript-in-nodemon src/index.ts",
"test": "mocha --require ts-node/register --require tsconfig-paths/register \"src/test/**/*.spec.ts\"",
"docker-build-local": "create-docker-context-for-node-component --build --push --tag auto --local",
"docker-build-prod": "create-docker-context-for-node-component --build --push --tag auto",
"retag-and-push": "retag-and-push",
"helm-lint": "helm lint deploy/magda-csw-connector -f deploy/test-deploy.yaml",
"test": "mocha --require ts-node/register --require tsconfig-paths/register \"src/test/**/*.spec.ts\""
"helm-docs": "helm-docs -t ./README.md.gotmpl -o ../../README.md",
"update-all-charts": "helm dep up ./deploy/magda-csw-connector",
"add-all-chart-version-changes": "git ls-files -m | grep Chart.yaml | xargs git add && git ls-files -m | grep Chart.lock | xargs git add",
"add-all-helm-docs-changes": "yarn helm-docs && git ls-files -m | grep -i readme.md | xargs git add",
"version": "yarn update-helm-chart-version && yarn update-all-charts && yarn add-all-chart-version-changes && yarn add-all-helm-docs-changes"
},
"license": "Apache-2.0",
"devDependencies": {
Expand Down

0 comments on commit d736ba3

Please sign in to comment.