Skip to content

Commit

Permalink
Merge pull request #5 from homeylab/bookstack-2.0.0-chart
Browse files Browse the repository at this point in the history
improve bookstack chart, breaking changes to values.yaml file
  • Loading branch information
pchang388 authored Sep 4, 2023
2 parents 17f2490 + 845beac commit 6320447
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 125 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM quay.io/helmpack/chart-testing:v3.9.0

RUN apk update && \
apk add make

RUN mkdir -p /root/.kube

COPY kube_config /root/.kube/config
58 changes: 14 additions & 44 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
// "name": "Debian",
// // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:bookworm",
// "features": {
// "ghcr.io/mpriscella/features/helm-chart-testing:1": {
// "version": "latest"
// }
// }
"name": "CT",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "quay.io/helmpack/chart-testing:v3.9.0",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
// "mounts": [
// "source=${localWorkspaceFolder}/.devcontainers,target=/root/.kube,type=bind,consistency=cached"
// ]

"postAttachCommand": {
"update": ["apk", "update", "&&", "apk", "add", "--no-cache", "make"],
"create_dir": ["mkdir", "-p", "/root/.kube"],
"cp_config": ["cp", "${containerWorkspaceFolder}/.devcontainer/config", "/root/.kube/config"],
"fix_perm": ["chmod", "0600", "/root/.kube/config"]
}
}

// mounts following docker compose options
// Use cached: when the host performs changes, the container is in read only mode.
// Use delegated: when docker container performs changes, host is in read only mode.
// Use default: When both container and host actively and continuously perform changes on data.

// bind = on host
// volume = create docker volume
"build": { "dockerfile": "Dockerfile" },
"name": "CT",

"customizations": {
"vscode": {
"extensions": ["streetsidesoftware.code-spell-checker"]
}
},
"runArgs": [
"--network=host"
]

// "forwardPorts": [3000]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For local testing or deploys
local-values.yaml
local_vars
.devcontainer/config
kube_config

# Chart dependencies
/charts/*/Chart.lock
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ LOCAL_NAMESPACE_SUFFIX=-local
LOCAL_CONTEXT=rancher-desktop
LOCAL_VARS_DIR=local_vars

## Docker image for dev containers
IMAGE_REPO=quay.io/helmpack/chart-testing
IMAGE_TAG=v3.9.0

## Replace image in dev

## lint
## replace with `ct lint` once we have json schema file
Expand All @@ -22,8 +27,11 @@ test:
test_custom:
ct install --chart-dirs ${CHART_DIR} --charts ${CHART_DIR}/$(app)

dryrun_install_local:
helm install $(app) ${CHART_DIR}/$(app) -n $(app)${LOCAL_NAMESPACE_SUFFIX} --create-namespace --dry-run

install_local:
helm install -f ${LOCAL_VARS_DIR}/$(app) $(app) -n $(app)-${LOCAL_NAMESPACE} --create-namespace
helm install $(app) ${CHART_DIR}/$(app) -n $(app)-${LOCAL_NAMESPACE} --create-namespace

clean_local:
helm delete $(app) -n $(app)-${LOCAL_NAMESPACE}
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ All charts are currently tested on:
- Helm `v3.12.1`

### Chart Testing
WIP Section
```
## update depedencies
helm dep update bookstack
**WIP Section**
To contribute, there are a many ways to do testing and many are valid. I am using Dev Containers extension from VScode to set up a consistent environment across my devices.

To use the same Dev Containers, ensure you have the extension enabled and add a copy of your kubectl config in `.devcontainer/`. Name it `kube_config` and it will be ignored by git (in .gitignore) and will be used during Dev Container build.

## simple test
ct install --chart-dirs bookstack --charts bookstack/
The provided makefile can then be used for testing via helm and [chart-testing](https://github.com/helm/chart-testing).

Example:
```
# Use `app=` for targeting a chart
# below runs chart-testing for the specified chart/app
make test app=bookstack
```
2 changes: 1 addition & 1 deletion charts/bookstack/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: "1.2.3"
version: 2.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
Expand Down
27 changes: 10 additions & 17 deletions charts/bookstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ helm repo add homeylab https://homeylab.github.io/helm-charts/
helm repo update homeylab
```

## Prerequisites
Ensure you either enable mariadb dependency, `mariadb.enabled`, or have an existing compatible DB server ready for bookstack.

This chart provides the option to install mariadb by default from [bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mariadb).

## Install
**Note it is recommended to set your own variables as required and store them in a custom values.yaml file.**
```
helm install bookstack homeylab/bookstack -n bookstack --create-namespace
Expand All @@ -18,31 +24,18 @@ helm install -f my-values.yaml bookstack homeylab/bookstack -n bookstack --creat
```

## Upgrade
It is recommended to make a backup of mariadb database and also configuration files used by bookstack on it's pvc.

See _Backup and Restore_ section for more details. After doing so, you can upgrade via helm.
```
helm upgrade bookstack homeylab/bookstack -n bookstack
# with own values file - recommended
helm upgrade -f my-values.yaml bookstack homeylab/bookstack -n bookstack
```

## Prerequisites
Ensure you either enable mariadb dependency, `mariadb.enabled`, or have an existing compatible DB server ready for bookstack. This chart provides the option to install mariadb by default from [bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mariadb).

## Simple Deploy
If you just want to deploy as simple as possible, create your own values.yaml file
1. Uncomment all the key/value variables in `config` section of values.yaml
2. Ensure `mariadb.enabled` is set to true for chart dependency
3. Change APP_URL in config and ingress-nginx (if used) to your preferred hostname
4. Change any relevant persistence options for `persistence.storageClass``

After first install, initial admin account will be set to:
```
email: admin@admin.com
passsword: password
```

## Configuration Options
For more configuration options, refer to the documented env variables available for bookstack [here](https://github.com/BookStackApp/BookStack/blob/development/.env.example.complete)
For more configuration options, refer to the documented env variables available for bookstack [here](https://github.com/BookStackApp/BookStack/blob/development/.env.example.complete).

## Backup And Restore Of MariaDB
When upgrading to different versions, you should do a back up of your mariadb data and have that available just in case. This can be used for other siturations like PVC resizing as well.
Expand Down
38 changes: 27 additions & 11 deletions charts/bookstack/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ spec:
image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- range $key, $val := .Values.config }}
- name: {{ $key | upper }}
value: {{ $val | quote }}
{{- if not .Values.existingSecret }}
- name: DB_USER
value: {{ .Values.config.dbUser | quote}}
- name: DB_PASS
value: {{ .Values.config.dbPass | quote}}
{{- end }}
- name: DB_HOST
value: {{ .Values.config.dbHost | quote }}
- name: DB_PORT
value: {{ .Values.config.dbPort | quote }}
- name: DB_DATABASE
value: {{ .Values.config.dbDatabase | quote }}
- name: CACHE_DRIVER
value: {{ .Values.config.cacheDriver | quote }}
- name: SESSION_DRIVER
value: {{ .Values.config.sessionDriver | quote }}
{{- range $key, $val := .Values.extraEnv }}
- name: {{ $key | upper }}
value: {{ $val | quote }}
Expand All @@ -53,14 +65,18 @@ spec:
- name: "{{ .Values.service.name }}"
containerPort: {{ .Values.service.port }}
protocol: TCP
# livenessProbe:
# httpGet:
# path: /
# port: "{{ .Values.service.name }}"
# readinessProbe:
# httpGet:
# path: /
# port: "{{ .Values.service.name }}"
{{- if .Values.livenessProbe }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
{{- end }}
{{- if .Values.startupProbe }}
startupProbe:
{{- toYaml .Values.startupProbe | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion charts/bookstack/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ spec:
- name: wget
image: "{{ .Values.testCurlImage.repository}}/{{ .Values.testCurlImage.name }}:{{ .Values.testCurlImage.tag }}"
command: ['wget']
args: ['{{ include "bookstack.fullname" . }}:{{ .Values.service.port }}']
args: ["{{ include "bookstack.fullname" . }}:{{ .Values.service.port }}{{ .Values.testCurlImage.path }}"]
restartPolicy: Never
Loading

0 comments on commit 6320447

Please sign in to comment.