Automatically set values for Nginx sub-chart based on install name (#370)

* Automatically set serverblock from IN chart

* Automatically set nginx PVC

* Bump chart version

* Upgrade dependencies

* Updated k8s test versions
This commit is contained in:
Ween Jiann
2021-07-07 04:19:03 +08:00
committed by GitHub
parent 5a1bf5c430
commit 7238e521e6
8 changed files with 116 additions and 99 deletions

View File

@@ -3,4 +3,4 @@ chart-dirs:
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
check-version-increment: true
debug: true
debug: false

View File

@@ -13,9 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch history
run: git fetch --prune --unshallow
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v1
@@ -41,6 +40,7 @@ jobs:
- name: Run chart-testing (lint)
run: ct lint --config .github/ct-lint.yaml
kubeval-chart:
runs-on: ubuntu-latest
needs:
@@ -49,9 +49,9 @@ jobs:
matrix:
chart: ${{ fromJson(needs.lint-chart.outputs.matrix) }}
k8s:
- v1.17.11
- v1.18.8
- v1.19.4
- v1.19.11
- v1.20.7
- v1.21.2
steps:
- name: Checkout
uses: actions/checkout@v1
@@ -79,20 +79,26 @@ jobs:
strategy:
matrix:
k8s:
- v1.17.11
- v1.18.8
- v1.19.4
- v1.19.11
- v1.20.7
- v1.21.2
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create kind ${{ matrix.k8s }} cluster
uses: helm/kind-action@v1.1.0
uses: helm/kind-action@v1.2.0
with:
node_image: kindest/node:${{ matrix.k8s }}
- name: Run chart-testing (install)
uses: helm/chart-testing-action@v2.0.1
- uses: actions/setup-python@v2
with:
command: install
config: .github/ct-install.yaml
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.0.1
- name: Run chart-testing (install)
run: ct install --config .github/ct-install.yaml

View File

@@ -1,15 +1,15 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 1.4.3
version: 1.7.0
- name: nginx
repository: https://charts.bitnami.com/bitnami
version: 8.8.5
version: 9.3.5
- name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 9.3.11
version: 9.3.16
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 12.9.2
digest: sha256:4255a558312b033e820635f491b0960bd4ec8e716164025212af06adafbd4cb9
generated: "2021-05-11T09:31:45.433+08:00"
version: 12.10.1
digest: sha256:d5605fef85b764ec25c0a486df1228f0d7946a3e029d361514d3582b779cbce6
generated: "2021-07-07T02:14:37.758095+08:00"

View File

@@ -13,11 +13,11 @@ 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.5.1
version: 0.6.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.1.64
appVersion: 5.2.10
keywords:
- invoiceninja
home: https://invoiceninja.github.io/dockerfiles
@@ -32,7 +32,7 @@ dependencies:
version: 1.x.x
- name: nginx
repository: https://charts.bitnami.com/bitnami
version: 8.8.x
version: 9.x.x
- condition: mariadb.enabled
name: mariadb
repository: https://charts.bitnami.com/bitnami
@@ -40,7 +40,7 @@ dependencies:
- condition: redis.enabled
name: redis
repository: https://charts.bitnami.com/bitnami
version: 12.9.x
version: 12.x.x
maintainers:
- email: lwj5@hotmail.com
name: lwj5

View File

@@ -13,7 +13,7 @@ Please read [Upgrading](#upgrading) section before upgrading MAJOR versions.
- The Bitnami [mariadb](https://github.com/bitnami/charts/tree/master/bitnami/mariadb) helm chart
- The Bitnami [nginx](https://github.com/bitnami/charts/tree/master/bitnami/nginx) helm chart
- The Bitnami [redis](https://github.com/bitnami/charts/tree/master/bitnami/redis) helm chart
- Tested on Kubernetes 1.17+
- Tested on Kubernetes 1.19+
## Installing the Chart
@@ -21,7 +21,7 @@ To install the chart with the release name `invoiceninja`:
```bash
helm repo add invoiceninja https://invoiceninja.github.io/dockerfiles
helm install invoiceninja invoiceninja/invoiceninja
helm install invoiceninja invoiceninja/invoiceninja --set appKey=changeit --set mariadb.auth.rootPassword=changeit --set mariadb.auth.password=changeit --set redis.password=changeit
```
The command deploys Invoice Ninja on the Kubernetes cluster in the default namespace. The [Parameters](#parameters) section lists the parameters that can be configured during installation.
@@ -71,7 +71,7 @@ The following table shows the configuration options for the Invoice Ninja helm c
### Invoice Ninja parameters
| Parameter | Description | Default |
| -------------------- | ---------------------------------------------------------------- | ------------------------------------------------------- |
| -------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------- |
| `image.registry` | Invoice Ninja image registry | `docker.io` |
| `image.repository` | Invoice Ninja image name | `invoiceninja/invoiceninja` |
| `image.tag` | Invoice Ninja image tag | Check `values.yaml` file |
@@ -148,14 +148,12 @@ The following table shows the configuration options for the Invoice Ninja helm c
### Ingress parameters
| Parameter | Description | Default |
| ------------------------------------------------------- | ------------------------------------- | ------------------------ |
| ------------------------------------ | ------------------------------------- | ------------------------------------------------------- |
| `nginx.service.type` | Kubernetes Service type | `ClusterIP` |
| `nginx.ingress.enabled` | Enable ingress controller resource | `true` |
| `nginx.ingress.hostname` | Default host for the ingress resource | `invoiceninja.local` |
| `nginx.serverBlock` | Custom NGINX server block | `nil` |
| `nginx.extraVolumes` | Array to add extra volumes | Check `values.yaml` file |
| `nginx.extraVolumes[0].persistentVolumeClaim.claimName` | Name of Invoice Ninja public PVC | `invoiceninja-public` |
| `nginx.extraVolumeMounts` | Array to add extra mount | Check `values.yaml` file |
| `nginx.existingServerBlockConfigmap` | Custom NGINX server block config map | `{{ include "invoiceninja.nginx.serverBlockName" . }}` |
| `nginx.staticSitePVC` | Name of Invoice Ninja public PVC | `{{ include "invoiceninja.public.storageName" . }}` |
> See [Dependencies](#dependencies) for more.

View File

@@ -248,3 +248,11 @@ Return the Session Connection Name
{{- printf "default" -}}
{{- end -}}
{{- end -}}
{{/*
Server block configmap name for nignx.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "invoiceninja.nginx.serverBlockName" -}}
{{- printf "%s-%s" .Release.Name "server-block" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@@ -0,0 +1,39 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "invoiceninja.nginx.serverBlockName" . }}
labels:
{{- include "common.labels.standard" $ | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
server-block.conf: |-
server {
listen 8080 default_server;
server_name _;
root /app;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass {{ include "common.names.fullname" . }}:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/app/public$fastcgi_script_name;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}

View File

@@ -18,7 +18,7 @@
image:
registry: docker.io
repository: invoiceninja/invoiceninja
tag: 5.1.64
tag: 5.2.10
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
@@ -469,43 +469,9 @@ nginx:
ingress:
enabled: true
hostname: invoiceninja.local
## Configure the serverblock for Invoice Ninja
## Note: you may need to replace the fastcgi_pass value if the release name is different
## Use the serverblock config map from Invoice Ninja
##
serverBlock: |
server {
listen 8080 default_server;
server_name _;
root /var/www/app/public/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass invoiceninja:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}
## Configure the extraVolumes and extraVolumeMounts for Invoice Ninja
## Note: you may need to replace the claimName if the release name is different
existingServerBlockConfigmap: '{{ include "invoiceninja.nginx.serverBlockName" . }}'
## Use the public PVC created by Invoice Ninja
##
extraVolumes:
- name: public
persistentVolumeClaim:
claimName: invoiceninja-public
extraVolumeMounts:
- mountPath: /var/www/app/public
name: public
readOnly: true
staticSitePVC: '{{ include "invoiceninja.public.storageName" . }}'