Skip to content

Commit

Permalink
Releasing swoop-bundle chart (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectormachin authored Jul 26, 2023
1 parent 37a27ef commit 99fcc86
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
# - name: Add repositories
# run: |
# for dir in $(ls -d charts/*/); do
# helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
# done
- name: Add repositories
run: |
for dir in $(ls -d charts/*/); do
helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
done
- name: Run chart-releaser
uses: helm/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
requirements.lock
22 changes: 22 additions & 0 deletions charts/swoop-bundle/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: swoop-bundle
description: A Helm Chart for SWOOP Components (https://github.com/Element84/swoop)
version: 0.1.0
apiVersion: v1
appVersion: "0.1.0"
keywords:
- swoop-bundle
sources:
home:
dependencies:
- name: swoop-api
condition: swoop-api.enabled
version: "0.1.0"
repository: "https://element84.github.io/filmdrop-k8s-helm-charts/"
# - name: swoop-caboose
# condition: swoop-caboose.enabled
# version: "0.1.0"
# repository: "https://element84.github.io/filmdrop-k8s-helm-charts/"
# - name: swoop-conductor
# condition: swoop-conductor.enabled
# version: "0.1.0"
# repository: "https://element84.github.io/filmdrop-k8s-helm-charts/"
132 changes: 132 additions & 0 deletions charts/swoop-bundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Deployment

This helm chart will the following components into a kubernetes cluster:
* [swoop-api](https://github.com/Element84/swoop)
* [argo-workflows](https://github.com/argoproj/argo-workflows/)
* [swoop-caboose](https://github.com/Element84/swoop-go)
* [swoop-conductor](https://github.com/Element84/swoop-go)

## Adding FilmDrop Helm Chart Repository
To add the FilmDrop Helm Chart repository, do:

`helm repo add e84 https://element84.github.io/filmdrop-k8s-helm-charts`


## Installing SWOOP and its dependencies
The [SWOOP API](https://github.com/Element84/swoop) will need an object storage for workflow artifacts and a postgres state database present.

You can either choose to install the MinIO and Postgres Helm Chart available on the FilmDrop Helm Chart Repository or you will need to have an existing MinIO/S3 backend with a Postgres installed and reachable to your SWOOP API.

To install the MinIO dependency run:
`helm install minio e84/minio`

To install the Postgres dependency run:
`helm install postgres e84/postgres`

To install SWOOP components:
`helm dep up e84/swoop-bundle`
`helm install swoop-bundle e84/swoop-bundle`

Once the chart has been deployed, you should see at least 3 deployments: postgres, minio and swoop-api.
<br></br>
<p align="center">
<img src="../../images/swoop-api-deployment-services.png" alt="SWOOP Deployment" width="1776">
</p>
<br></br>

In order to start using the services used by this helm chart, you will need to port-forward `postgres` onto localhost port `5432`, port-forward `minio` onto localhost ports `9000` & `9001` and port-forward `swoop-api` onto localhost port `8000`.
<br></br>
<p align="center">
<img src="../../images/swoop-api-port-forwarding.png" alt="Port forwarding SWOOP" width="1776">
</p>
<br></br>

You will see now, that if you reach the swoop api [http://localhost:8000/](http://localhost:8000/), you should see a sample response:
```
$ curl http://localhost:8000/
{"title":"Example processing server","description":"Example server implementing the OGC API - Processes 1.0 Standard","links":[{"href":"http://localhost:8000/conformance","rel":"http://www.opengis.net/def/rel/ogc/1.0/conformance","type":"application/json","hreflang":null,"title":null}]}%
```
<br></br>

## API tests with Database

To test the API endpoints that make use of data in the postgres database, you will need to load data into the postgres state database or use [swoop-db](https://github.com/Element84/swoop-db) to initialize the schema and load test migrations.

If you want database sample data to test the API, run the following swoop-db commands on the postgres pods to apply the migrations and load the fixtures:
```
kubectl exec -it --namespace=default $(kubectl get pods -o=name --namespace=default | grep postgres) -- /bin/sh -c "swoop-db up"
kubectl exec -it --namespace=default $(kubectl get pods -o=name --namespace=default | grep postgres) -- /bin/sh -c "swoop-db load-fixture base_01"
```

After loading the database, you should be able to see the jobs in the swoop api jobs endpoint [http://localhost:8000/jobs/](http://localhost:8000/jobs/):
```
$ curl http://localhost:8000/jobs/
{"jobs":[{"processID":"action_2","type":"process","jobID":"81842304-0aa9-4609-89f0-1c86819b0752","status":"accepted","message":null,"created":null,"started":null,"finished":null,"updated":"2023-04-28T15:49:00+00:00","progress":null,"links":null,"parentID":"2595f2da-81a6-423c-84db-935e6791046e"},{"processID":"action_1","type":"process","jobID":"2595f2da-81a6-423c-84db-935e6791046e","status":"successful","message":null,"created":null,"started":null,"finished":null,"updated":"2023-04-28T15:49:03+00:00","progress":null,"links":null,"parentID":"cf8ff7f0-ce5d-4de6-8026-4e551787385f"}],"links":[{"href":"http://www.example.com","rel":null,"type":null,"hreflang":null,"title":null}]}%
```

## API tests with Object Storage
In order to load data into MinIO, follow these steps:

### Install First the MinIO client by running:
```
brew install minio/stable/mc
```

### Then set the MinIO alias, find the ACCESS_KEY and SECRET_KEY by quering the Helm values
```
export MINIO_ACCESS_KEY=`helm get values swoop-api -a -o json | jq -r .minio.service.accessKeyId | base64 --decode`
export MINIO_SECRET_KEY=`helm get values swoop-api -a -o json | jq -r .minio.service.secretAccessKey | base64 --decode`
mc alias set swoopminio http://127.0.0.1:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
```

### Test MinIO connection by running:
```
$ mc admin info swoopminio
● 127.0.0.1:9000
Uptime: 23 minutes
Version: 2023-06-02T23:17:26Z
Network: 1/1 OK
Drives: 1/1 OK
Pool: 1
Pools:
1st, Erasure sets: 1, Drives per erasure set: 1
0 B Used, 1 Bucket, 0 Objects
1 drive online, 0 drives offline
```

### Load data into MinIO by running:
First clone the [https://github.com/Element84/swoop](https://github.com/Element84/swoop) repository locally, and then run the following from the top level of the your local swoop clone:

```
$ mc cp --recursive tests/fixtures/io/base_01/ swoopminio/swoop/execution/2595f2da-81a6-423c-84db-935e6791046e/
...fixtures/io/base_01/output.json: 181 B / 181 B ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.67 KiB/s 0s
```

### View your data on MinIO by opening your browser on [http://localhost:9001/](http://localhost:9001/) and logging into MinIO
<p align="center">
<img src="../../images/swoop-minio-data.png" alt="SWOOP MinIO" width="1776">
</p>
<br></br>

### Test API with MinIO by running:
```
$ curl http://localhost:8000/jobs/2595f2da-81a6-423c-84db-935e6791046e/payload
{"process_id":"2595f2da-81a6-423c-84db-935e6791046e","payload":"test_input"}%
```

```
$ curl http://localhost:8000/jobs/2595f2da-81a6-423c-84db-935e6791046e/results
{"process_id":"2595f2da-81a6-423c-84db-935e6791046e","payload":"test_output"}%
```
<br></br>
## Uninstall swoop-api

To uninstall the release, do `helm uninstall swoop-api`.
8 changes: 8 additions & 0 deletions charts/swoop-bundle/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

To learn more about the release, try:

$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}
39 changes: 39 additions & 0 deletions charts/swoop-bundle/templates/helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "swoop-bundle.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 "swoop-bundle.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 }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "swoop-bundle.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}

{{- define "swoop-bundle.labels" -}}
app: swoop-bundle
{{- end }}
45 changes: 45 additions & 0 deletions charts/swoop-bundle/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Default values for swoop-api.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
nameOverride: ""
fullnameOverride: ""

swoop-api:
enabled: true
nameOverride: ""
fullnameOverride: ""

postgres:
service:
name: postgres
dbName: swoop
dbUser: cG9zdGdyZXM=
dbPassword: cGFzc3dvcmQ=
sslMode: disable
authMethod: trust
schemaVersionTable: swoop.schema_version

minio:
service:
name: minio
bucketName: swoop
accessKeyId: bWluaW8=
secretAccessKey: cGFzc3dvcmQ=

swoopApi:
image:
repository: quay.io/element84/swoop
tag: latest
container:
port: 8000
service:
type: ClusterIP
port: 8000
targetPort: 8000
swoopExecutionDir: s3://swoop/execution
swoopS3Endpoint: http://minio:9000
swoopWorkflowConfigFile: workflow-config.yml
name: swoop-api
deployment:
name: swoop-api
replicaCount: 1

0 comments on commit 99fcc86

Please sign in to comment.