Skip to content

Commit

Permalink
Merge pull request #270 from ONLYOFFICE/release/v3.3.0
Browse files Browse the repository at this point in the history
Merge Helm Chart release/v3.3.0 into master
  • Loading branch information
agolybev authored Aug 2, 2023
2 parents d00fb8c + d5ec596 commit 7cd8848
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 135 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/helm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,34 @@ env:
HEAD_BRANCH: ${{ github.head_ref }}

jobs:
selective-check:
name: selective-check
runs-on: ubuntu-latest
outputs:
images-present: ${{ steps.selective-check.outputs.images-present }}
steps:
- name: Checkout chart
uses: actions/checkout@v3
- name: selective-check
id: selective-check
run: |
tag=$(yq -r .docservice.image.tag ./values.yaml)
if docker buildx imagetools inspect onlyoffice/docs-docservice:${tag} > /dev/null; then
IMAGE_PRESENT=true
echo "Images present, continue..."
else
echo "Image not present, skip integration tests"
IMAGE_PRESENT=false
fi
echo "images-present=${IMAGE_PRESENT}" >> "$GITHUB_OUTPUT"
spin-up:
name: integration-test
runs-on: ubuntu-latest
needs: [selective-check]
if: needs.selective-check.outputs.images-present == 'true'
steps:
- name: Checkout chart
uses: actions/checkout@v3
Expand Down
49 changes: 21 additions & 28 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lint

run-name: >
lint tests on PR: "${{ github.event.pull_request.title }}" by @${{ github.actor }}
Tests on PR: "${{ github.event.pull_request.title }}" by @${{ github.actor }}
on:
pull_request:
Expand All @@ -12,6 +12,13 @@ on:
- '**/CHANGELOG.md'
- '**/LICENSE'

workflow_dispatch:
inputs:
kubernetes_version:
description: 'Choose k8s version (example v1.22)'
type: string
required: true

jobs:
lint-chart:
name: lint chart ${{ github.event.repository.name }}
Expand All @@ -22,30 +29,16 @@ jobs:
enable_kube_lint: true

validate-manifests:
name: "Validate manifests with k8s versions"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: install helm
id: helm-setup
uses: azure/setup-helm@v3
with:
version: 3.11.3
token: ${{ secrets.GITHUB_TOKEN }}

- uses: cpanato/[email protected]

- name: Check manifests
run: |
helm template -f values.yaml . \
--set grafana.enabled=true \
--set grafana.dashboard.enabled=true \
--set example.enabled=true \
--set proxy.welcomePage.enabled=true \
--set converter.autoscaling.enabled=true \
--set ingress.enabled=true \
--set serviceAccount.create=true \
| kubepug --error-on-deprecated --error-on-deleted --input-file /dev/stdin
shell: bash
name: "k8s manifests api validation"
uses: ONLYOFFICE/ga-common/.github/workflows/deprecated-recources.yaml@master
with:
manual_k8s: ${{ github.event.inputs.kubernetes_version }}
set_keys: |
"--set grafana.enabled=true \
--set grafana.dashboard.enabled=true \
--set example.enabled=true \
--set proxy.welcomePage.enabled=true \
--set docservice.autoscaling.enabled=true \
--set converter.autoscaling.enabled=true \
--set ingress.enabled=true \
--set serviceAccount.create=true"
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change log

## 3.3.0

### New Features

* Added the ability to connect to the ONLYOFFICE Docs via a virtual path
* Added the ability to connect to Redis Sentinel

### Changes

* Released [v7.4.1](https://github.com/ONLYOFFICE/DocumentServer/blob/master/CHANGELOG.md#741) of ONLYOFFICE Docs

### Fixes

* Fixed Ingress Class definition

## 3.2.0

### New Features
Expand Down
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description: Helm chart for installing ONLYOFFICE Docs in Kubernetes

type: application

version: 3.2.0
version: 3.3.0

appVersion: 7.4.0
appVersion: 7.4.1
160 changes: 84 additions & 76 deletions README.md

Large diffs are not rendered by default.

64 changes: 51 additions & 13 deletions sources/scripts/test_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import logging

url = 'http://docservice:8000/healthcheck'

redisConnectorName = os.environ.get('REDIS_CONNECTOR_NAME')
redisHost = os.environ.get('REDIS_SERVER_HOST')
redisPort = os.environ.get('REDIS_SERVER_PORT')
redisUser = os.environ.get('REDIS_SERVER_USER')
redisPassword = os.environ.get('REDIS_SERVER_PWD')
redisDBNum = os.environ.get('REDIS_SERVER_DB_NUM')
redisConnectTimeout = 15
if redisConnectorName == 'ioredis':
redisSentinelGroupName = os.environ.get('REDIS_SENTINEL_GROUP_NAME')

dbType = os.environ.get('DB_TYPE')
dbHost = os.environ.get('DB_HOST')
Expand Down Expand Up @@ -75,21 +79,55 @@ def get_redis_status():
return rc.ping()


def get_redis_sentinel_status():
install_module('redis')
import redis
from redis import Sentinel
global rc
try:
sentinel = Sentinel([(redisHost, redisPort)], socket_timeout=redisConnectTimeout)
master_host, master_port = sentinel.discover_master(redisSentinelGroupName)
rc = redis.Redis(
host=master_host,
port=master_port,
db=redisDBNum,
password=redisPassword,
username=redisUser,
socket_connect_timeout=redisConnectTimeout,
retry_on_timeout=True
)
rc.ping()
except Exception as msg_redis:
logger_test_ds.error(f'Failed to check the availability of the Redis... {msg_redis}\n')
total_result['CheckRedis'] = 'Failed'
else:
logger_test_ds.info('Successful connection to Redis')
return rc.ping()


def check_redis_key():
try:
rc.set('testDocsServer', 'ok')
test_key = rc.get('testDocsServer').decode('utf-8')
logger_test_ds.info(f'Test Key: {test_key}')
except Exception as msg_check_redis:
logger_test_ds.error(f'Error when trying to write a key to Redis... {msg_check_redis}\n')
total_result['CheckRedis'] = 'Failed'
else:
rc.delete('testDocsServer')
logger_test_ds.info('The test key was successfully recorded and deleted from Redis\n')
rc.close()
total_result['CheckRedis'] = 'Success'


def check_redis():
logger_test_ds.info('Checking Redis availability...')
if get_redis_status() is True:
try:
rc.set('testDocsServer', 'ok')
test_key = rc.get('testDocsServer').decode('utf-8')
logger_test_ds.info(f'Test Key: {test_key}')
except Exception as msg_check_redis:
logger_test_ds.error(f'Error when trying to write a key to Redis... {msg_check_redis}\n')
total_result['CheckRedis'] = 'Failed'
else:
rc.delete('testDocsServer')
logger_test_ds.info('The test key was successfully recorded and deleted from Redis\n')
rc.close()
total_result['CheckRedis'] = 'Success'
if redisConnectorName == 'redis':
if get_redis_status() is True:
check_redis_key()
elif redisConnectorName == 'ioredis':
if get_redis_sentinel_status() is True:
check_redis_key()


def check_db_postgresql(tbl_dict):
Expand Down
2 changes: 1 addition & 1 deletion sources/shutdown-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
defaultMode: 0755
containers:
- name: shutdown-ds
image: onlyoffice/docs-utils:7.4.0-1
image: onlyoffice/docs-utils:7.4.1-2
command: ["/bin/sh", "-c"]
args: ["/scripts/stop.sh"]
volumeMounts:
Expand Down
22 changes: 22 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,25 @@ Get the ds Grafana Namespace
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}

{{/*
Get the ds virtual path
*/}}
{{- define "ds.ingress.path" -}}
{{- if eq .Values.ingress.path "/" -}}
{{- printf "/" -}}
{{- else }}
{{- printf "%s(/|$)(.*)" .Values.ingress.path -}}
{{- end -}}
{{- end -}}

{{/*
Get ds url for example
*/}}
{{- define "ds.example.dsUrl" -}}
{{- if and (ne .Values.ingress.path "/") (eq .Values.example.dsUrl "/") -}}
{{- printf "%s/" (tpl .Values.ingress.path $) -}}
{{- else }}
{{- printf "%s" (tpl .Values.example.dsUrl $) -}}
{{- end -}}
{{- end -}}
4 changes: 4 additions & 0 deletions templates/configmaps/documentserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ data:
DB_HOST: {{ .Values.connections.dbHost }}
DB_PORT: {{ .Values.connections.dbPort | quote }}
DB_NAME: {{ .Values.connections.dbName }}
REDIS_CONNECTOR_NAME: {{ .Values.connections.redisConnectorName }}
REDIS_SERVER_HOST: {{ .Values.connections.redisHost }}
REDIS_SERVER_PORT: {{ .Values.connections.redisPort | quote }}
REDIS_SERVER_USER: {{ .Values.connections.redisUser }}
REDIS_SERVER_DB_NUM: {{ .Values.connections.redisDBNum | quote }}
{{- if eq .Values.connections.redisConnectorName "ioredis" }}
REDIS_SENTINEL_GROUP_NAME: {{ .Values.connections.redisSentinelGroupName }}
{{- end }}
AMQP_TYPE: {{ .Values.connections.amqpType }}
AMQP_PORT: {{ .Values.connections.amqpPort | quote }}
AMQP_VHOST: {{ .Values.connections.amqpVhost | quote }}
Expand Down
2 changes: 1 addition & 1 deletion templates/configmaps/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ metadata:
{{- include "ds.labels.commonLabels" . | trim | nindent 4 }}
{{- end }}
data:
DS_URL: {{ .Values.example.dsUrl }}
DS_URL: {{ include "ds.example.dsUrl" . }}
{{- end }}
13 changes: 9 additions & 4 deletions templates/ingresses/documentserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ metadata:
{{- if .Values.commonLabels }}
labels:
{{- include "ds.labels.commonLabels" . | trim | nindent 4 }}
{{- end }}
{{- if .Values.ingress.annotations }}
{{- end }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ tpl $value $ }}
{{- end }}
{{- end }}
{{- if not (eq .Values.ingress.path "/") }}
nginx.ingress.kubernetes.io/x-forwarded-prefix: {{ .Values.ingress.path }}
nginx.ingress.kubernetes.io/rewrite-target: /$2
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
{{- if .Values.ingress.ssl.enabled }}
tls:
- hosts:
Expand All @@ -29,7 +34,7 @@ spec:
{{- end }}
http:
paths:
- path: /
- path: {{ template "ds.ingress.path" . }}
pathType: Prefix
backend:
service:
Expand Down
3 changes: 3 additions & 0 deletions templates/ingresses/grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ metadata:
{{- end }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
{{- if .Values.ingress.ssl.enabled }}
tls:
- hosts:
Expand Down
2 changes: 1 addition & 1 deletion templates/jobs/dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
defaultMode: 0755
containers:
- name: grafana-dashboard
image: onlyoffice/docs-utils:7.4.0-1
image: onlyoffice/docs-utils:7.4.1-2
command: ["/bin/sh", "-c"]
{{- if .Values.webProxy.enabled }}
args: ["http_proxy={{ .Values.webProxy.http }} https_proxy={{ .Values.webProxy.https }} no_proxy={{ .Values.webProxy.noProxy }} /scripts/get_dashboard.sh"]
Expand Down
Loading

0 comments on commit 7cd8848

Please sign in to comment.