Skip to content

Commit

Permalink
Merge pull request #34 from fmidev/4300-add-support-for-custom-config…
Browse files Browse the repository at this point in the history
…uration

Add custom configuration support to taf-backend chart
  • Loading branch information
Jusaa authored Oct 27, 2023
2 parents 1eeca4a + a4ed899 commit c727b8d
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/geoweb-taf-backend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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: 0.0.3
version: 0.1.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
Expand Down
44 changes: 40 additions & 4 deletions charts/geoweb-taf-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ helm repo update

# Create requried dependencies

Create values.yaml file for required variables:
Create your own values file for required variables:
* Using aws as the secret provider
```yaml
taf:
Expand All @@ -27,19 +27,44 @@ taf:
db_secret: base64_encoded_postgresql_connection_string
```
* Using custom configuration files stored locally
```yaml
taf:
env:
TAF_CONFIG: custom/config.ini
url: geoweb.example.com
useCustomConfigurationFiles: true
customConfigurationFolderPath: /example/path/
```
* Using custom configuration files stored in AWS S3
```yaml
taf:
url: geoweb.example.com
env:
TAF_CONFIG: custom/config.ini
useCustomConfigurationFiles: true
customConfigurationLocation: s3
s3bucketName: example-bucket
customConfigurationFolderPath: /example/path/
awsAccessKeyId: <AWS_ACCESS_KEY_ID>
awsAccessKeySecret: <AWS_SECRET_ACCESS_KEY>
awsDefaultRegion: <AWS_DEFAULT_REGION>
```
# Testing the Chart
Execute the following for testing the chart:
```bash
helm install geoweb-taf-backend fmi/geoweb-taf-backend --dry-run --debug -n geoweb --values=./values.yaml
helm install geoweb-taf-backend fmi/geoweb-taf-backend --dry-run --debug -n geoweb --values=./<yourvaluesfile>.yaml
```

# Installing the Chart

Execute the following for installing the chart:

```bash
helm install geoweb-taf-backend fmi/geoweb-taf-backend -n geoweb --values=./values.yaml
helm install geoweb-taf-backend fmi/geoweb-taf-backend -n geoweb --values=./<yourvaluesfile>.yaml
```

# Deleting the Chart
Expand All @@ -53,7 +78,7 @@ kubectl delete namespace geoweb
```

# Chart Configuration
The following table lists the configurable parameters of the Taf backend chart and their default values.
The following table lists the configurable parameters of the Taf backend chart and their default values specified in file values.yaml.

| Parameter | Description | Default |
| - | - | - |
Expand Down Expand Up @@ -82,6 +107,17 @@ The following table lists the configurable parameters of the Taf backend chart a
| `taf.env.GEOWEB_KNMI_AVI_MESSAGESERVICES_HOST` | - | `"localhost:8081"` |
| `taf.env.OAUTH2_USERINFO` | - | |
| `taf.env.AVIATION_TAF_PUBLISH_HOST` | - | `"localhost:8090"` |
| `taf.env.TAF_CONFIG` | Location of configuration file that is used (application defaults to `config.ini`) | |
| `taf.useCustomConfigurationFiles` | Use custom configurations | `false` |
| `taf.customConfigurationLocation` | Where custom configurations are located *(local\|s3)* | `local` |
| `taf.volumeAccessMode` | Permissions of the application for the custom configurations PersistentVolume used | `ReadOnlyMany` |
| `taf.volumeSize` | Size of the custom configurations PersistentVolume | `100Mi` |
| `taf.customConfigurationFolderPath` | Path to the folder which contains custom configurations | |
| `taf.customConfigurationMountPath` | Folder used to mount custom configurations | `/app/custom` |
| `taf.s3bucketName` | Name of the S3 bucket where custom configurations are stored | |
| `taf.awsAccessKeyId` | AWS_ACCESS_KEY_ID for authenticating to S3 | |
| `taf.awsAccessKeySecret` | AWS_SECRET_ACCESS_KEY for authenticating to S3 | |
| `taf.awsDefaultRegion` | Region where your S3 bucket is located | |
| `taf.messageconverter.name` | Name of messageconverter container | `taf-messageconverter` |
| `taf.messageconverter.registry` | Registry to fetch image | `registry.gitlab.com/opengeoweb/avi-msgconverter/geoweb-knmi-avi-messageservices` |
| `taf.messageconverter.version` | Possibility to override application version | `"0.1.1"` |
Expand Down
1 change: 1 addition & 0 deletions charts/geoweb-taf-backend/templates/taf-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ data:
GEOWEB_KNMI_AVI_MESSAGESERVICES_HOST: {{ .Values.taf.env.GEOWEB_KNMI_AVI_MESSAGESERVICES_HOST | quote }}
AVIATION_TAF_PORT_HTTP: {{ .Values.taf.env.AVIATION_TAF_PORT_HTTP | quote }}
AVIATION_TAF_PUBLISH_HOST: {{ .Values.taf.env.AVIATION_TAF_PUBLISH_HOST | quote }}
TAF_CONFIG: {{ .Values.taf.env.TAF_CONFIG | quote }}
VERSION: {{ .Values.versions.taf | quote }}
AVI_VERSION: {{ .Values.taf.messageconverter.version | quote }}
29 changes: 29 additions & 0 deletions charts/geoweb-taf-backend/templates/taf-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ spec:
spec:
{{- if eq .Values.secretProvider "aws" }}
serviceAccountName: {{ .Values.taf.secretServiceAccount }}
{{- end }}
{{- if and .Values.taf.useCustomConfigurationFiles (eq .Values.taf.customConfigurationLocation "s3")}}
initContainers:
- name: init
image: amazon/aws-cli
command: ["/bin/sh"]
args:
- -c
- |
export AWS_ACCESS_KEY_ID={{ .Values.taf.awsAccessKeyId }};
export AWS_SECRET_ACCESS_KEY={{ .Values.taf.awsAccessKeySecret }};
AWS_DEFAULT_REGION={{ .Values.taf.awsDefaultRegion }};
aws s3 cp --recursive --exclude "*/*" s3://{{ .Values.taf.s3bucketName }}{{ .Values.taf.customConfigurationFolderPath }} /taf;
volumeMounts:
- mountPath: "/taf/"
name: {{ .Values.taf.name }}-volume
{{- end }}
containers:
- name: {{ .Values.taf.name }}
Expand Down Expand Up @@ -58,6 +74,10 @@ spec:
- name: secrets-store-inline
mountPath: "/mnt/secrets-store"
readOnly: true
{{- if and .Values.taf.useCustomConfigurationFiles }}
- mountPath: {{ .Values.taf.customConfigurationMountPath }}
name: {{ .Values.taf.name }}-volume
{{- end }}
- name: {{ .Values.taf.placeholder.name }}
image: {{ .Values.taf.placeholder.registry }}:{{ .Values.versions.taf }}
{{- if .Values.taf.imagePullPolicy }}
Expand Down Expand Up @@ -164,6 +184,15 @@ spec:
value: {{ .Values.taf.db.POSTGRES_PASSWORD }}
{{- end }}
volumes:
{{- if .Values.taf.useCustomConfigurationFiles }}
- name: {{ .Values.taf.name }}-volume
{{- if eq .Values.taf.customConfigurationLocation "s3"}}
emptyDir: {}
{{- else if eq .Values.taf.customConfigurationLocation "local"}}
persistentVolumeClaim:
claimName: {{ .Values.taf.name }}-claim
{{- end }}
{{- end }}
- name: secrets-store-inline
{{- if .Values.secretProvider }}
csi:
Expand Down
29 changes: 29 additions & 0 deletions charts/geoweb-taf-backend/templates/taf-volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if and .Values.taf.useCustomConfigurationFiles (eq .Values.taf.customConfigurationLocation "local")}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.taf.name }}-claim
spec:
storageClassName: ""
accessModes:
- {{ .Values.taf.volumeAccessMode }}
resources:
requests:
storage: {{ .Values.taf.volumeSize }}
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.taf.name }}-volume
spec:
storageClassName: manual
capacity:
storage: {{ .Values.taf.volumeSize }}
accessModes:
- {{ .Values.taf.volumeAccessMode }}
claimRef:
namespace: {{ .Release.Namespace }}
name: {{ .Values.taf.name }}-claim
hostPath:
path: {{ .Values.taf.customConfigurationFolderPath | quote }}
{{- end }}
5 changes: 5 additions & 0 deletions charts/geoweb-taf-backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ taf:
POSTGRES_DB: taf
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
useCustomConfigurationFiles: false
customConfigurationLocation: local
customConfigurationMountPath: /app/custom
volumeAccessMode: ReadOnlyMany
volumeSize: 100Mi

ingress:
name: nginx-ingress-controller
Expand Down

0 comments on commit c727b8d

Please sign in to comment.