Skip to content

Commit

Permalink
Add minimally viable CDOGS helm chart
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Ho <[email protected]>
  • Loading branch information
jujaga committed Oct 31, 2023
1 parent 2483bd4 commit 4a3e855
Show file tree
Hide file tree
Showing 18 changed files with 671 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/environments/values.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
config:
enabled: true
configMap:
KC_ENABLED: "true"
KC_PUBLICKEY: >-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsmuiI3bzde2avKEZd8P/ivnUFL9JxwfykQ9eC6qULkkALW4Nj+m0rH+yTuWTWPwZsYyICtWXbQui6Yh+EP0+bTeDzeDaD1oSUgqC4c9EySs64sGPQLE3sHllwONo8AegNQSiPw+KHE2Rf3ky61KuQHOhrszHKq1qT71ct5iPK9oeZ4vkr6A0XfNNOzih6Jp+XrmNmU85+ssNJ7Oy9plwxHBC73Ff3Jw8UF2dRPPLOJT3oAtYJYD4uuQebPq3bKv2n8iQftLG80l1frM1iG/jddoKItSYBRYsi4Mc65gGgkfsTQGk+Up0SULpO/nIASHWLSYNZOTiqAqMgkWQ+Ga9vQIDAQAB
KC_REALM: comsvcauth
KC_SERVERURL: "https://dev.loginproxy.gov.bc.ca/auth"

SERVER_BODYLIMIT: 100mb
SERVER_LOGLEVEL: http
SERVER_PORT: "3000"

CACHE_DIR: "/tmp/carbone-files"
CACHE_SIZE: 2GB
CONVERTER_FACTORY_TIMEOUT: "60000"
START_CARBONE: "true"
UPLOAD_FIELD_NAME: template
UPLOAD_FILE_COUNT: "1"
UPLOAD_FILE_SIZE: 25MB
1 change: 1 addition & 0 deletions .github/environments/values.pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
20 changes: 20 additions & 0 deletions .github/environments/values.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
config:
enabled: true
configMap:
KC_ENABLED: "true"
KC_PUBLICKEY: ~
KC_REALM: comsvcauth
KC_SERVERURL: "https://loginproxy.gov.bc.ca/auth"

SERVER_BODYLIMIT: 100mb
SERVER_LOGLEVEL: http
SERVER_PORT: "3000"

CACHE_DIR: "/tmp/carbone-files"
CACHE_SIZE: 2GB
CONVERTER_FACTORY_TIMEOUT: "60000"
START_CARBONE: "true"
UPLOAD_FIELD_NAME: template
UPLOAD_FILE_COUNT: "1"
UPLOAD_FILE_SIZE: 25MB
20 changes: 20 additions & 0 deletions .github/environments/values.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
config:
enabled: true
configMap:
KC_ENABLED: "true"
KC_PUBLICKEY: ~
KC_REALM: comsvcauth
KC_SERVERURL: "https://test.loginproxy.gov.bc.ca/auth"

SERVER_BODYLIMIT: 100mb
SERVER_LOGLEVEL: http
SERVER_PORT: "3000"

CACHE_DIR: "/tmp/carbone-files"
CACHE_SIZE: 2GB
CONVERTER_FACTORY_TIMEOUT: "60000"
START_CARBONE: "true"
UPLOAD_FIELD_NAME: template
UPLOAD_FILE_COUNT: "1"
UPLOAD_FILE_SIZE: 25MB
23 changes: 23 additions & 0 deletions charts/cdogs/.helmignore
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/
38 changes: 38 additions & 0 deletions charts/cdogs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v2
name: common-document-generation-service
# 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.1
kubeVersion: ">= 1.13.0"
description: A microservice for merging JSON data into xml-based templates (powered by Carbone.io)
# 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
keywords:
- nodejs
- javascript
- docker
- microservice
- document-generation
- templating
- cdogs
home: https://github.com/bcgov/common-document-generation-service
sources:
- https://github.com/bcgov/common-document-generation-service
dependencies: []
maintainers:
- name: NR Common Service Showcase Team
email: [email protected]
url: https://bcgov.github.io/common-service-showcase/team.html
# 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: "2.4.2"
deprecated: false
annotations: {}
68 changes: 68 additions & 0 deletions charts/cdogs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# common-document-generation-service

![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.4.2](https://img.shields.io/badge/AppVersion-2.4.2-informational?style=flat-square)

A microservice for merging JSON data into xml-based templates (powered by Carbone.io)

**Homepage:** <https://github.com/bcgov/common-document-generation-service>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| NR Common Service Showcase Team | <[email protected]> | <https://bcgov.github.io/common-service-showcase/team.html> |

## Source Code

* <https://github.com/bcgov/common-document-generation-service>

## Requirements

Kubernetes: `>= 1.13.0`

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| autoscaling.behavior | object | `{"scaleDown":{"policies":[{"periodSeconds":120,"type":"Pods","value":1}],"selectPolicy":"Max","stabilizationWindowSeconds":120},"scaleUp":{"policies":[{"periodSeconds":30,"type":"Pods","value":2}],"selectPolicy":"Max","stabilizationWindowSeconds":0}}` | behavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). |
| autoscaling.enabled | bool | `false` | Specifies whether the Horizontal Pod Autoscaler should be created |
| autoscaling.maxReplicas | int | `16` | |
| autoscaling.minReplicas | int | `2` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| config.configMap | object | `{"CACHE_DIR":"/tmp/carbone-files","CACHE_SIZE":"2GB","CONVERTER_FACTORY_TIMEOUT":"60000","KC_PUBLICKEY":null,"KC_REALM":null,"KC_SERVERURL":null,"SERVER_BODYLIMIT":"100mb","SERVER_LOGLEVEL":"http","SERVER_PORT":"3000","START_CARBONE":"true","UPLOAD_FIELD_NAME":"template","UPLOAD_FILE_COUNT":"1","UPLOAD_FILE_SIZE":"25MB"}` | These values will be wholesale added to the configmap as is; refer to the cdogs documentation for what each of these values mean and whether you need them defined. Ensure that all values are represented explicitly as strings, as non-string values will not translate over as expected into container environment variables. For configuration keys named `*_ENABLED`, either leave them commented/undefined, or set them to string value "true". |
| config.enabled | bool | `false` | |
| config.releaseScoped | bool | `false` | This should be set to true if and only if you require configmaps and secrets to be release scoped. In the event you want all instances in the same namespace to share a similar configuration, this should be set to false |
| failurePolicy | string | `"Retry"` | |
| fluentBit.enabled | bool | `false` | |
| fullnameOverride | string | `nil` | String to fully override fullname |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"docker.io/bcgovimages"` | |
| image.tag | string | `nil` | |
| imagePullSecrets | list | `[]` | Specify docker-registry secret names as an array |
| keycloakSecretOverride.password | string | `nil` | |
| keycloakSecretOverride.username | string | `nil` | |
| nameOverride | string | `nil` | String to partially override fullname |
| networkPolicy.enabled | bool | `true` | Specifies whether a network policy should be created |
| podAnnotations | object | `{}` | Annotations for cdogs pods |
| podSecurityContext | object | `{}` | |
| replicaCount | int | `2` | |
| resources.limits.cpu | string | `"1000m"` | |
| resources.limits.memory | string | `"1Gi"` | |
| resources.requests.cpu | string | `"50m"` | |
| resources.requests.memory | string | `"256Mi"` | |
| route.annotations | object | `{}` | Annotations to add to the route |
| route.enabled | bool | `true` | Specifies whether a route should be created |
| route.host | string | `"chart-example.local"` | |
| route.tls.insecureEdgeTerminationPolicy | string | `"Redirect"` | |
| route.tls.termination | string | `"edge"` | |
| route.wildcardPolicy | string | `"None"` | |
| securityContext | object | `{}` | |
| service.port | int | `3000` | |
| service.portName | string | `"http"` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.enabled | bool | `false` | Specifies whether a service account should be created |
| serviceAccount.name | string | `nil` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
24 changes: 24 additions & 0 deletions charts/cdogs/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- $configMapName := printf "%s-%s" (include "cdogs.configname" .) "config" }}
{{- $configMap := (lookup "v1" "ConfigMap" .Release.Namespace $configMapName ) }}
Get the application URL by running these commands:
{{- if .Values.route.enabled }}
http{{ if $.Values.route.tls }}s{{ end }}://{{ .Values.route.host }}{{ .Values.route.path }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "cdogs.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 "cdogs.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "cdogs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "cdogs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
{{- if not $configMap }}

Make sure that ConfigMap "{{ $configMapName }}" is defined in the namespace; the deployment will fail to run without it!
{{- end }}
77 changes: 77 additions & 0 deletions charts/cdogs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cdogs.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 "cdogs.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" $name .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Define the config pattern of the chart based on options.
*/}}
{{- define "cdogs.configname" -}}
{{- if .Values.config.releaseScoped }}
{{- include "cdogs.fullname" . }}
{{- else }}
{{- include "cdogs.name" . }}
{{- end }}
{{- end }}

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

{{/*
Common labels
*/}}
{{- define "cdogs.labels" -}}
helm.sh/chart: {{ include "cdogs.chart" . }}
app: {{ include "cdogs.fullname" . }}
{{ include "cdogs.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/component: app
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: {{ .Release.Name }}
app.openshift.io/runtime: nodejs
{{- end }}

{{/*
Selector labels
*/}}
{{- define "cdogs.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cdogs.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "cdogs.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cdogs.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/cdogs/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.config.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
{{- if not .Values.config.releaseScoped }}
annotations:
"helm.sh/resource-policy": keep
{{- else }}
labels: {{ include "cdogs.labels" . | nindent 4 }}
{{- end }}
name: {{ include "cdogs.configname" . }}-config
data: {{ toYaml .Values.config.configMap | nindent 2 }}
{{- end }}
Loading

0 comments on commit 4a3e855

Please sign in to comment.