-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
407 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: scicat-to-pss | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
commit: | ||
description: 'Commit of the CI repo to deploy' | ||
required: false | ||
pull_request: | ||
branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
|
||
set_env: | ||
uses: ./.github/workflows/reusable.environment.yml | ||
with: | ||
commit: ${{ github.event.inputs.commit }} | ||
|
||
check_changed: | ||
needs: set_env | ||
uses: ./.github/workflows/reusable.changes.yml | ||
with: | ||
files: | | ||
.github/workflows/scicat-to-pss.yml | ||
helm_configs/scicat-to-pss/${{ needs.set_env.outputs.environment }}/** | ||
helm_configs/scicat-to-pss/values.yaml | ||
scicat-to-pss/** | ||
commit: ${{ needs.set_env.outputs.commit }} | ||
|
||
build_deploy: | ||
if: (needs.check_changed.outputs.changed == 'true' && !needs.set_env.outputs.component) || needs.set_env.outputs.component == 'sp' | ||
needs: | ||
- check_changed | ||
- set_env | ||
uses: ./.github/workflows/reusable.build-deploy.yml | ||
with: | ||
context: scicat-to-pss/. | ||
image_name: ${{ github.repository }}/scicat-to-pss | ||
release_name: scicat-to-pss | ||
tag: ${{ needs.set_env.outputs.tag }} | ||
environment: ${{ needs.set_env.outputs.environment }} | ||
helm_chart: cron_chart | ||
commit: ${{ needs.set_env.outputs.commit }} | ||
secrets: | ||
KUBECONFIG: ${{ secrets.KUBECONFIG }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: cron-chart | ||
description: A Helm chart for scheduling cron jobs | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
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: 1.0.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# 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: "1.16.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Cron-chart | ||
|
||
A simple chart to deploy a cronJob runner mounting secrets | ||
|
||
## Installing the Chart | ||
|
||
To install the chart with the release name `my-release`: | ||
|
||
```bash | ||
$ helm install my-release cron_chart | ||
``` | ||
|
||
The command deploys a cron chart on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation. | ||
|
||
> **Tip**: List all releases using `helm list` | ||
## Uninstalling the Chart | ||
|
||
To uninstall/delete the `my-release` deployment: | ||
|
||
```bash | ||
$ helm delete my-release | ||
``` | ||
|
||
The command removes all the Kubernetes components associated with the chart and deletes the release. | ||
|
||
## Parameters | ||
|
||
The following table lists the configurable parameters of the chart and their default values. | ||
|
||
### Common parameters | ||
|
||
| Parameter | Description | Default | | ||
|---------------------|----------------------------------------------------------------------|--------------------------------| | ||
| `nameOverride` | String to partially override fullname | `nil` | | ||
| `fullnameOverride` | String to fully override fullname | `nil` | | ||
|
||
### cron-chart parameters | ||
|
||
| Parameter | Description | Default | | ||
|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------| | ||
| `image.repository` | Image name | `busybox` | | ||
| `image.tag` | Image tag | `latest` | | ||
| `image.pullPolicy` | Image pull policy | `Always` | | ||
| `cronjob.restartPolicy` | Set the cronjob restart policy | `OnFailure` | | ||
| `cronjob.schedule` | Set the schedule of the cronjob in the usual cron format command | `0 7 * * 1` | | ||
| `cronjob.secret` | Name of the secret used by the cronjob to fetch env vars | `nil` | | ||
| `secrets` | Object of objects which create secrets, in the form: { secretName:{ type:Opaque,data:{ key1:value1,key2:value2,key3:value3 } } } | ||
| `nil` | | ||
| `volumes` | Object of arrays with volumes to mount, in the form: https://kubernetes.io/docs/concepts/storage/volumes/#background | `nil` | | ||
| `volumeMounts` | Object of arrays with volumes to mount and where, in the form: https://kubernetes.io/docs/concepts/storage/volumes/#background | `nil` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
1. Get the application resources by running: | ||
$ kubectl get all -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm_chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" | ||
2. Get the application configmaps by running: | ||
$ kubectl get configmaps -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm_chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" | ||
3. Get the application secrets by running: | ||
$ kubectl get secrets -n {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm_chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "helm_chart.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "helm_chart.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- .Release.Name }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "helm_chart.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "helm_chart.labels" -}} | ||
helm.sh/chart: {{ include "helm_chart.chart" . }} | ||
{{ include "helm_chart.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "helm_chart.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "helm_chart.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "helm_chart.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "helm_chart.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Validate the secret, checking if base64 encoded | ||
*/}} | ||
{{- define "validateSecret" -}} | ||
{{ $secret := regexReplaceAllLiteral "\u0026#x3D;" (regexReplaceAllLiteral "\u0026#x2F;" . "/") "=" }} | ||
{{- if (b64dec $secret | hasPrefix "illegal base64") -}} | ||
{{ fail "Please b64 encode your secrets!" }} | ||
{{- else }} | ||
{{- $secret }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ include "helm_chart.fullname" . }} | ||
labels: | ||
{{- include "helm_chart.labels" $ | nindent 4 }} | ||
spec: | ||
successfulJobsHistoryLimit: 1 | ||
failedJobsHistoryLimit: 1 | ||
schedule: {{ .Values.cronjob.schedule | quote }} | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "helm_chart.selectorLabels" . | nindent 12 }} | ||
spec: | ||
restartPolicy: {{ .Values.cronjob.restartPolicy }} | ||
containers: | ||
- name: {{ include "helm_chart.fullname" . }} | ||
image: {{ tpl .Values.image.repository $ }}:{{ tpl .Values.image.tag $ }} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
{{- with .Values.env }} | ||
env: | ||
{{- tpl (toYaml .) $ | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.volumeMounts }} | ||
volumeMounts: | ||
{{- tpl (toYaml .) $ | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.volumes}} | ||
volumes: | ||
{{- tpl (toYaml .) $ | nindent 10 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{- range $name, $values := $.Values.secrets }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ tpl $name $ }} | ||
labels: | ||
{{- include "helm_chart.labels" $ | nindent 4 }} | ||
type: {{ $values.type }} | ||
data: | ||
{{- range $k, $v := $values.data }} | ||
{{ $k }}: | ||
{{- tpl (printf "%s" $v) $ | include "validateSecret" | indent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Default values for search-api. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
replicaCount: 1 | ||
|
||
image: | ||
repository: "busybox" | ||
pullPolicy: Always | ||
# Overrides the image tag whose default is the chart appVersion. | ||
tag: latest | ||
|
||
nameOverride: "" | ||
fullnameOverride: "" | ||
|
||
cronjob: | ||
restartPolicy: OnFailure | ||
schedule: 0 7 * * 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
scicatBaseUrl: http://backend.scicat-development/api/v3 | ||
pssBaseUrl: http://pss.scicat-development | ||
|
||
cronjob: | ||
restartPolicy: OnFailure | ||
schedule: 0 5 * * 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
scicatBaseUrl: http://backend.scicat-production/api/v3 | ||
pssBaseUrl: http://pss.scicat-production | ||
|
||
cronjob: | ||
restartPolicy: OnFailure | ||
schedule: 30 5 * * 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
scicatBaseUrl: http://backend.scicat-qa/api/v3 | ||
pssBaseUrl: http://pss.scicat-qa | ||
|
||
cronjob: | ||
restartPolicy: OnFailure | ||
schedule: 15 5 * * 6 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
replicaCount: 1 | ||
|
||
image: | ||
repository: "{{ .Values.ciRepository }}" | ||
pullPolicy: Always | ||
tag: "{{ .Values.ciTag }}" | ||
|
||
env: | ||
- name: SCICAT_BASE_URL | ||
value: "{{ .Values.scicatBaseUrl }}" | ||
- name: PSS_BASE_URL | ||
value: "{{ .Values.pssBaseUrl }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM python:3.10-slim | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
WORKDIR /usr/src/app | ||
# copy and install dependencies | ||
COPY requirements.txt copy_public_ds.py ./ | ||
RUN pip install -r requirements.txt | ||
|
||
CMD ["python", "copy_public_ds.py"] |
Oops, something went wrong.