Skip to content

Commit

Permalink
[sophora-seo-check]: add Sophora SEO Check (#60)
Browse files Browse the repository at this point in the history
* add Sophora SEO Check

* use StatefulSet instead of Deployment; use emptyDir volume to store downloaded additional data files

* remove unnecessary headless service
  • Loading branch information
blizzy78 authored Nov 14, 2023
1 parent 735f589 commit 2efb80a
Show file tree
Hide file tree
Showing 11 changed files with 433 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/sophora-seo-check/.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/
6 changes: 6 additions & 0 deletions charts/sophora-seo-check/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: sophora-seo-check
description: Sophora SEO Check
type: application
version: 1.0.0
appVersion: 4.12.0
51 changes: 51 additions & 0 deletions charts/sophora-seo-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Sophora SEO Check

The [SEO Check] module supports the editorial team in the on-page content optimization of individual documents in the Sophora CMS.
The SEO Check checks the documents for occurrences of SEO keywords, readability, cross-linking and multimedia. Additionally,
the SEO Check shows relevant information about the document.


## Deployment of Additional Data Files

SEO Check requires additional data files to run. These can be downloaded from the
[documentation](https://subshell.com/docs/seocheck/4/seocheck104.html#Example-Word-Lists-in-German-and-English)
and can then by modified by the administrator.


### Google Cloud Storage Credentials

This chart runs an init container to make the additional files available to SEO Check. The files will be downloaded
from a Google Cloud Storage bucket, where they must be placed by the administrator.

To authenticate with Google Cloud Storage, the init container will use the secret `<chart release name>-init-gcp-credentials`.
This secret must be created prior to the installation of the chart.

To create the credentials secret, have your credentials JSON file ready. You can export this file
in the IAM section in Google Cloud Platform.

To create the secret, run the following command:

```
kubectl create secret generic <chart release name>-init-gcp-credentials \
--from-literal "credentials.json=$(cat my-project-credentials.json)"
```

Replace `<chart release name>` with the name of your release.
Replace the path to `my-project-credentials.json` with the path to your actual credentials JSON file.


### Google Cloud Storage Base URI

The init container needs to know the base URI of the Google Cloud Storage bucket where it can find the
additional data files. In your `values.yaml` file, you must set `seoCheck.init.googleStorageBaseURI`.

The data files must be placed inside the subfolder `<seoCheck.init.googleStorageBaseURI>/seo-check-data`.

For example:

- `seoCheck.init.googleStorageBaseURI: gs://sophora-seo-check`
- Folder to place additional data files in: `gs://sophora-seo-check/seo-check-data`



[SEO Check]: https://subshell.com/sophora/modules/sophora-seo-check104.html
64 changes: 64 additions & 0 deletions charts/sophora-seo-check/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "sophora-seo-check.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 "sophora-seo-check.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 "sophora-seo-check.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "sophora-seo-check.labels" -}}
helm.sh/chart: {{ include "sophora-seo-check.chart" . }}
{{ include "sophora-seo-check.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{/*
Renders a value that contains template.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "common.tplvalues.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
8 changes: 8 additions & 0 deletions charts/sophora-seo-check/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "sophora-seo-check.fullname" . }}
labels:
{{- include "sophora-seo-check.labels" . | nindent 4 }}
data:
application.yaml: |- {{ toYaml (required "A valid application.yaml config is required" .Values.sophora.configuration) | nindent 4 }}
4 changes: 4 additions & 0 deletions charts/sophora-seo-check/templates/extra-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- range .Values.extraDeploy }}
---
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
41 changes: 41 additions & 0 deletions charts/sophora-seo-check/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "sophora-seo-check.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "sophora-seo-check.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
- path: {{ .path }}
pathType: {{ default "ImplementationSpecific" .pathType }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/sophora-seo-check/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "sophora-seo-check.fullname" . }}
labels:
{{- include "sophora-seo-check.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
{{- include "sophora-seo-check.selectorLabels" . | nindent 4 }}
type: {{ .Values.service.type }}
ports:
- protocol: TCP
targetPort: http
port: {{ .Values.service.port }}
106 changes: 106 additions & 0 deletions charts/sophora-seo-check/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "sophora-seo-check.fullname" . }}
labels:
{{- include "sophora-seo-check.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "sophora-seo-check.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "sophora-seo-check.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
- name: seo-check-init
image: docker.subshell.com/sophora/seocheck-k8s-init:latest
imagePullPolicy: IfNotPresent
restartPolicy: Always
env:
- name: GOOGLE_STORAGE_BASE_URI
value: {{ .Values.seoCheck.init.googleStorageBaseURI }}
volumeMounts:
- name: init-gcp-credentials
mountPath: /init-data
readOnly: true
- name: data
mountPath: /seo-check-data
containers:
- name: seo-check
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: persistent-data
mountPath: /data
- name: config
mountPath: /data/config
readOnly: true
- name: data
mountPath: /init-data
readOnly: true
ports:
- name: http
protocol: TCP
containerPort: 8080
env:
- name: JDK_JAVA_OPTIONS
value: {{ .Values.javaOptions }}
- name: SOPHORA_CLIENT_SERVERCONNECTION_USERNAME
valueFrom:
secretKeyRef:
name: {{ required "A valid secret name must be provided in .Values.sophora.authentication.secret.name" .Values.sophora.authentication.secret.name | quote }}
key: {{ .Values.sophora.authentication.secret.usernameKey | quote }}
- name: SOPHORA_CLIENT_SERVERCONNECTION_PASSWORD
valueFrom:
secretKeyRef:
name: {{ required "A valid secret name must be provided in .Values.sophora.authentication.secret.name" .Values.sophora.authentication.secret.name | quote }}
key: {{ .Values.sophora.authentication.secret.passwordKey | quote }}
{{- if .Values.seoCheck.extraEnv }}
{{- toYaml .Values.seoCheck.extraEnv | nindent 12 }}
{{- end }}
startupProbe:
httpGet:
port: http
path: /actuator/health
periodSeconds: 1
failureThreshold: 30
livenessProbe:
httpGet:
port: http
path: /actuator/health
readinessProbe:
httpGet:
port: http
path: /actuator/health
volumes:
- name: config
configMap:
name: {{ include "sophora-seo-check.fullname" . }}
- name: init-gcp-credentials
secret:
secretName: {{ include "sophora-seo-check.fullname" . }}-init-gcp-credentials
- name: data
emptyDir:
sizelimit: {{ .Values.storage.dataSize }}
volumeClaimTemplates:
- metadata:
name: persistent-data
spec:
accessModes:
- ReadWriteOnce
storageClassName: {{ .Values.storage.storageClass }}
resources:
requests:
storage: {{ .Values.storage.persistentDataSize }}
51 changes: 51 additions & 0 deletions charts/sophora-seo-check/test-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
nameOverride: ""
fullnameOverride: ""

image:
repository: docker.subshell.com/sophora/seocheck
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: latest

imagePullSecrets: []

javaOptions: -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem

sophora:
authentication:
secret:
name: sophora-secret

# Represents the application.yaml of Sophora SEO Check
configuration:
# Settings for the Sophora server connection.
sophora:
client:
server-connection:
urls: []
username: # in secret
password: # in secret

# Settings for the SEO Check.
seo-check:

seoCheck:
extraEnv:

service:
type: ClusterIP
port: 8080
annotations: {}

ingress:
enabled: false
ingressClassName: nginx
annotations: {}
hosts:
tls: []

extraDeploy: []

podAnnotations: {}

pvcAnnotations: {}
Loading

0 comments on commit 2efb80a

Please sign in to comment.