Skip to content

Commit

Permalink
initial release bety helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Oct 11, 2021
0 parents commit 3b9ff5e
Show file tree
Hide file tree
Showing 19 changed files with 869 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get dependencies
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add ncsa https://opensource.ncsa.illinois.edu/charts/
helm dep build
- name: get release info
id: release_info
run: |
version="$(awk '/^version:/ { print $2} ' Chart.yaml)"
changelog="$(sed -e "1,/^### ${version}/d" -e "/^###/,\$d" -e '/^$/d' README.md)"
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/'%0A'}"
changelog="${changelog//$'\r'/'%0D'}"
echo "::set-output name=version::$version"
echo "::set-output name=changelog::$changelog"
- name: Publish to NCSA OpenSource
uses: bsord/helm-push@v3
with:
username: ${{ secrets.HELM_USERNAME }}
password: ${{ secrets.HELM_PASSWORD }}
repository-url: "https://opensource.ncsa.illinois.edu/charts"
chart-folder: "."
force: true

- name: create release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_info.outputs.version }}
release_name: Release ${{ steps.release_info.outputs.version }}
body: ${{ steps.release_info.outputs.changelog }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./clowder-${{ steps.release_info.outputs.version }}.tgz
asset_name: clowder-${{ steps.release_info.outputs.version }}.tgz
asset_content_type: application/zip
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# development
.idea

# generated helm charts folder
charts

# helm package
.cr-release-packages
bety-*.tgz

# custom values
secrets-*.yaml
values-*.yaml
*.values.yaml

# database dumps
*.sql
24 changes: 24 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
*.sql
values-*.yaml
6 changes: 6 additions & 0 deletions Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 8.9.9
digest: sha256:788b9c691c8d3254deb1ee2341c41b4ab6a50f5112b839896daa9aa2d7bf457d
generated: "2021-10-06T23:08:24.431682-05:00"
44 changes: 44 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: v2
type: application

# Information about chart.
name: betydb
icon: https://isda.ncsa.illinois.edu/~kooper/charts/images/betydb.png
home: https://www.betydb.org
description: >
Web-interface to the Biofuel Ecophysiological Traits and Yields Database
(used by PEcAn and TERRA REF)
# 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.5.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.
appVersion: "5.4.1"

# List of people that maintain this helm chart.
maintainers:
- name: Rob Kooper
email: kooper@illinois.edu

# location of source code
sources:
- https://github.com/pecanproject/bety

# Dependencies for chart. Some of the dependencies are only installed if they
# are enabled.
dependencies:
- name: postgresql
version: ~8.9
repository: https://charts.bitnami.com/bitnami
condition: postgres.enabled

annotations:
artifacthub.io/links: |
- name: Helm Chart
url: https://github.com/pecanproject/bety-helm
artifacthub.io/changes: |
- initial release of bety helm chart
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
THIS IS A PLACEHOLDER

## Upgrading BETY

If the password is generated you will need to save this secret before you upgrade. You can do this using the following commands. **If you do not do this, you will not be able to retrieve the previous secrets**.

```
BETY_PASSWORD=$(kubectl get secrets betydb -o json | jq -r '.data.betyPassword' | base64 -d)
BETY_SECRETKEY=$(kubectl get secrets betydb -o json | jq -r '.data.secretKey' | base64 -d)
POSTGRESQL_PASSWORD=$(kubectl get secrets betydb-postgresql -o json | jq -r '.data."postgresql-password"' | base64 -d)
```

now you can upgrade and use the secrets retrieved.

```
helm upgrade betydb ncsa/betydb \
--set betyPassword="${BETY_PASSWORD}" \
--set secretKey="${BETY_SECRETKEY}" \
--set postgresql.postgresqlPassword="${POSTGRESQL_PASSWORD}"
```

## ChangeLog

### 0.5.0
- initial release of the BETY helm chart.
- build on bety 5.4.1
2 changes: 2 additions & 0 deletions cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#sign: true
#key: Chart Releaser Test Key
11 changes: 11 additions & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See https://github.com/helm/chart-testing#configuration
remote: origin
target-branch: main
chart-dirs:
- .
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
- ncsa=https://opensource.ncsa.illinois.edu/charts/
helm-extra-args: --timeout 600s
validate-yaml: true
check-version-increment: true
33 changes: 33 additions & 0 deletions templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "betydb.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "betydb.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "betydb.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
kubectl port-forward service/{{ include "betydb.fullname" . }} 8080:{{ .Values.service.port }}
echo "Visit http://127.0.0.1:8080 to use your application"
{{- end }}

{{- if .Values.users }}

Following users have been created:
{{- range $index, $element := .Values.users }}
- {{ .username }} : {{ .fullname }} <{{ .email }}>
{{- end }}
{{- end }}

To upgrade please make sure to save the passwords for BETY, postgresql and the secret key for BETY.

BETY_PASSWORD=$(kubectl get secrets betydb -o json | jq -r '.data.betyPassword' | base64 -d)
BETY_SECRETKEY=$(kubectl get secrets betydb -o json | jq -r '.data.secretKey' | base64 -d)
POSTGRESQL_PASSWORD=$(kubectl get secrets betydb-postgresql -o json | jq -r '.data."postgresql-password"' | base64 -d)

108 changes: 108 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "betydb.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 "betydb.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 "betydb.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "betydb.labels" -}}
app.kubernetes.io/name: {{ include "betydb.name" . }}
helm.sh/chart: {{ include "betydb.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
postgresql Host
*/}}
{{- define "betydb.postgresqlHost" -}}
{{- if .Values.postgresql.enabled -}}
{{ .Release.Name }}-postgresql
{{- else -}}
{{ .Values.postgresql.postgresqlHost }}
{{- end -}}
{{- end -}}

{{/*
postgresql Port
*/}}
{{- define "betydb.postgresqlPort" -}}
{{- if .Values.postgresql.service -}}
{{ .Values.postgresql.service.port }}
{{- else -}}
{{ .Values.postgresql.postgresqlPort | default "5432" }}
{{- end -}}
{{- end -}}

{{/*
Environment variables for PostgreSQL
*/}}
{{- define "betydb.postgresqlEnv" -}}
- name: PGHOST
value: {{ include "betydb.postgresqlHost" . | quote }}
- name: PGPORT
value: {{ include "betydb.postgresqlPort" . | quote }}
- name: PGUSER
value: {{ .Values.postgresql.postgresqlUsername | default "postgres" | quote }}
- name: PGPASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.postgresql.enabled }}
name: {{ .Release.Name }}-postgresql
key: postgresql-password
{{- else }}
name: {{ include "betydb.fullname" . }}
key: postgresqlPassword
{{- end }}
{{- end }}

{{/*
Environment variables for BetyDB
*/}}
{{- define "betydb.betydbEnv" -}}
- name: BETYUSER
value: {{ .Values.betyUser | quote }}
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "betydb.fullname" . }}
key: betyPassword
- name: BETYDATABASE
value: {{ .Values.betyDatabase | quote }}
- name: LOCAL_SERVER
value: {{ .Values.localServer | quote }}
- name: REMOTE_SERVERS
value: {{ .Values.remoteServers | quote }}
{{- end }}
27 changes: 27 additions & 0 deletions templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.customization }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "betydb.fullname" . }}-application
labels:
{{ include "betydb.labels" . | nindent 4 }}
data:
{{- if .Values.customization.application }}
application.yml: |
{{- .Values.customization.application | nindent 4}}
{{- end }}
---
{{- if .Values.customization }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "betydb.fullname" . }}-logos
labels:
{{ include "betydb.labels" . | nindent 4 }}
binaryData:
{{- range $key, $val := .Values.customization.logos }}
{{ $key }}: |
{{- $val | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit 3b9ff5e

Please sign in to comment.